本文整理汇总了Python中fuelclient.objects.environment.Environment.get_state_of_tests方法的典型用法代码示例。如果您正苦于以下问题:Python Environment.get_state_of_tests方法的具体用法?Python Environment.get_state_of_tests怎么用?Python Environment.get_state_of_tests使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fuelclient.objects.environment.Environment
的用法示例。
在下文中一共展示了Environment.get_state_of_tests方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestEnvironmentOstf
# 需要导入模块: from fuelclient.objects.environment import Environment [as 别名]
# 或者: from fuelclient.objects.environment.Environment import get_state_of_tests [as 别名]
class TestEnvironmentOstf(base.UnitTestCase):
def setUp(self):
super(TestEnvironmentOstf, self).setUp()
self.env = Environment(None)
@mock.patch.object(Environment.connection, 'post_request', mock.Mock(
return_value=[
{'id': 1},
{'id': 2}, ]))
def test_run_test_sets(self):
self.assertEqual(self.env._testruns_ids, [])
testruns = self.env.run_test_sets(['sanity', 'ha'])
self.assertEqual(len(testruns), 2)
self.assertIn(1, self.env._testruns_ids)
self.assertIn(2, self.env._testruns_ids)
@mock.patch.object(Environment.connection, 'get_request', mock.Mock(
side_effect=[
{'id': 1, 'status': 'running'},
{'id': 2, 'status': 'finished'}, ]))
def test_get_state_of_tests(self):
self.env._testruns_ids.extend([1, 2])
tests = self.env.get_state_of_tests()
self.env.connection.get_request.assert_has_calls([
mock.call('testruns/1', ostf=True),
mock.call('testruns/2', ostf=True)])
self.assertEqual(tests, [
{'id': 1, 'status': 'running'},
{'id': 2, 'status': 'finished'}])
示例2: check
# 需要导入模块: from fuelclient.objects.environment import Environment [as 别名]
# 或者: from fuelclient.objects.environment.Environment import get_state_of_tests [as 别名]
def check(self, params):
"""To run some health checks:
fuel --env 1 health --check smoke,sanity
"""
env = Environment(params.env)
if env.status not in self._allowed_statuses and not params.force:
exit_with_error(
"Environment is not ready to run health check "
"because it is in {0} state. "
"Health check is likely to fail because of "
"this. Use --force flag to proceed anyway.". format(env.status)
)
if env.is_customized and not params.force:
exit_with_error(
"Environment deployment facts were updated. "
"Health check is likely to fail because of "
"that. Use --force flag to proceed anyway."
)
test_sets_to_check = params.check or set(
ts["id"] for ts in env.get_testsets())
env.run_test_sets(test_sets_to_check)
tests_state = env.get_state_of_tests()
self.serializer.print_to_output(
tests_state,
env,
print_method=print_health_check
)
示例3: TestEnvironmentOstf
# 需要导入模块: from fuelclient.objects.environment import Environment [as 别名]
# 或者: from fuelclient.objects.environment.Environment import get_state_of_tests [as 别名]
class TestEnvironmentOstf(base.UnitTestCase):
def setUp(self):
super(TestEnvironmentOstf, self).setUp()
self.env = Environment(None)
@mock.patch.object(Environment.connection, 'post_request', mock.Mock(
return_value=[
{'id': 1},
{'id': 2}, ]))
def test_run_test_sets(self):
self.assertEqual(self.env._testruns_ids, [])
testruns = self.env.run_test_sets(['sanity', 'ha'])
self.assertEqual(len(testruns), 2)
self.assertIn(1, self.env._testruns_ids)
self.assertIn(2, self.env._testruns_ids)
@mock.patch.object(Environment.connection, 'post_request')
def test_credentials_are_passed_to_ostf(self, post_request):
self.env.run_test_sets(['sanity'], {'tenant': 't1',
'username': 'u1',
'password': 'p1'})
run_test_request = post_request.call_args[0][1]
self.assertTrue(len(run_test_request) > 0, 'Got empty request')
self.assertIn('metadata', run_test_request[0])
self.assertIn('ostf_os_access_creds', run_test_request[0]['metadata'])
creds = run_test_request[0]['metadata']['ostf_os_access_creds']
self.assertEqual(creds['ostf_os_tenant_name'], 't1')
self.assertEqual(creds['ostf_os_username'], 'u1')
self.assertEqual(creds['ostf_os_password'], 'p1')
@mock.patch.object(Environment.connection, 'get_request', mock.Mock(
side_effect=[
{'id': 1, 'status': 'running'},
{'id': 2, 'status': 'finished'}, ]))
def test_get_state_of_tests(self):
self.env._testruns_ids.extend([1, 2])
tests = self.env.get_state_of_tests()
self.env.connection.get_request.assert_has_calls([
mock.call('testruns/1', ostf=True),
mock.call('testruns/2', ostf=True)])
self.assertEqual(tests, [
{'id': 1, 'status': 'running'},
{'id': 2, 'status': 'finished'}])
def test_get_deployment_tasks_with_end(self):
end = 'task1'
get = self.m_request.get(rm.ANY, json={})
self.env.get_deployment_tasks(end=end)
self.assertEqual(get.last_request.qs, {'end': ['task1']})
示例4: TestEnvironmentOstf
# 需要导入模块: from fuelclient.objects.environment import Environment [as 别名]
# 或者: from fuelclient.objects.environment.Environment import get_state_of_tests [as 别名]
class TestEnvironmentOstf(base.UnitTestCase):
def setUp(self):
super(TestEnvironmentOstf, self).setUp()
self.env = Environment(None)
@mock.patch.object(Environment.connection, 'post_request', mock.Mock(
return_value=[
{'id': 1},
{'id': 2}, ]))
def test_run_test_sets(self):
self.assertEqual(self.env._testruns_ids, [])
testruns = self.env.run_test_sets(['sanity', 'ha'])
self.assertEqual(len(testruns), 2)
self.assertIn(1, self.env._testruns_ids)
self.assertIn(2, self.env._testruns_ids)
@mock.patch.object(Environment.connection, 'get_request', mock.Mock(
side_effect=[
{'id': 1, 'status': 'running'},
{'id': 2, 'status': 'finished'}, ]))
def test_get_state_of_tests(self):
self.env._testruns_ids.extend([1, 2])
tests = self.env.get_state_of_tests()
self.env.connection.get_request.assert_has_calls([
mock.call('testruns/1', ostf=True),
mock.call('testruns/2', ostf=True)])
self.assertEqual(tests, [
{'id': 1, 'status': 'running'},
{'id': 2, 'status': 'finished'}])
@mock.patch('fuelclient.client.requests')
def test_get_deployment_tasks_with_end(self, mrequests):
end = 'task1'
self.env.get_deployment_tasks(end=end)
kwargs = mrequests.get.call_args[1]
self.assertEqual(kwargs['params'], {'start': None, 'end': 'task1'})
示例5: check
# 需要导入模块: from fuelclient.objects.environment import Environment [as 别名]
# 或者: from fuelclient.objects.environment.Environment import get_state_of_tests [as 别名]
def check(self, params):
"""To run some health checks:
fuel --env 1 health --check smoke,sanity
"""
env = Environment(params.env)
if env.status not in self._allowed_statuses and not params.force:
raise EnvironmentException(
"Environment is not ready to run health check "
"because it is in {0} state. "
"Health check is likely to fail because of "
"this. Use --force flag to proceed anyway.". format(env.status)
)
if env.is_customized and not params.force:
raise EnvironmentException(
"Environment deployment facts were updated. "
"Health check is likely to fail because of "
"that. Use --force flag to proceed anyway."
)
test_sets_to_check = params.check or set(
ts["id"] for ts in env.get_testsets())
ostf_credentials = {}
if params.ostf_tenant_name is not None:
ostf_credentials['tenant'] = params.ostf_tenant_name
if params.ostf_username is not None:
ostf_credentials['username'] = params.ostf_username
if params.ostf_password is not None:
ostf_credentials['password'] = params.ostf_password
if not ostf_credentials:
six.print_("WARNING: ostf credentials are going to be",
"mandatory in the next release.", file=sys.stderr)
env.run_test_sets(test_sets_to_check, ostf_credentials)
tests_state = env.get_state_of_tests()
self.serializer.print_to_output(
tests_state,
env,
print_method=print_health_check
)
示例6: TestEnvironmentOstf
# 需要导入模块: from fuelclient.objects.environment import Environment [as 别名]
# 或者: from fuelclient.objects.environment.Environment import get_state_of_tests [as 别名]
class TestEnvironmentOstf(base.UnitTestCase):
def setUp(self):
super(TestEnvironmentOstf, self).setUp()
self.env = Environment(None)
@mock.patch.object(Environment.connection, "post_request", mock.Mock(return_value=[{"id": 1}, {"id": 2}]))
def test_run_test_sets(self):
self.assertEqual(self.env._testruns_ids, [])
testruns = self.env.run_test_sets(["sanity", "ha"])
self.assertEqual(len(testruns), 2)
self.assertIn(1, self.env._testruns_ids)
self.assertIn(2, self.env._testruns_ids)
@mock.patch.object(
Environment.connection,
"get_request",
mock.Mock(side_effect=[{"id": 1, "status": "running"}, {"id": 2, "status": "finished"}]),
)
def test_get_state_of_tests(self):
self.env._testruns_ids.extend([1, 2])
tests = self.env.get_state_of_tests()
self.env.connection.get_request.assert_has_calls(
[mock.call("testruns/1", ostf=True), mock.call("testruns/2", ostf=True)]
)
self.assertEqual(tests, [{"id": 1, "status": "running"}, {"id": 2, "status": "finished"}])
def test_get_deployment_tasks_with_end(self):
end = "task1"
get = self.m_request.get(rm.ANY, json={})
self.env.get_deployment_tasks(end=end)
self.assertEqual(get.last_request.qs, {"end": ["task1"]})