当前位置: 首页>>代码示例>>Python>>正文


Python Environment.get_deployment_tasks方法代码示例

本文整理汇总了Python中fuelclient.objects.environment.Environment.get_deployment_tasks方法的典型用法代码示例。如果您正苦于以下问题:Python Environment.get_deployment_tasks方法的具体用法?Python Environment.get_deployment_tasks怎么用?Python Environment.get_deployment_tasks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fuelclient.objects.environment.Environment的用法示例。


在下文中一共展示了Environment.get_deployment_tasks方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestEnvironmentOstf

# 需要导入模块: from fuelclient.objects.environment import Environment [as 别名]
# 或者: from fuelclient.objects.environment.Environment import get_deployment_tasks [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']})
开发者ID:heartpandora,项目名称:python-fuelclient,代码行数:58,代码来源:test_environment.py

示例2: TestEnvironmentOstf

# 需要导入模块: from fuelclient.objects.environment import Environment [as 别名]
# 或者: from fuelclient.objects.environment.Environment import get_deployment_tasks [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']})
开发者ID:gdyuldin,项目名称:python-fuelclient,代码行数:44,代码来源:test_environment.py

示例3: TestEnvironmentOstf

# 需要导入模块: from fuelclient.objects.environment import Environment [as 别名]
# 或者: from fuelclient.objects.environment.Environment import get_deployment_tasks [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'})
开发者ID:aateem,项目名称:python-fuelclient,代码行数:43,代码来源:test_environment.py

示例4: TestEnvironmentOstf

# 需要导入模块: from fuelclient.objects.environment import Environment [as 别名]
# 或者: from fuelclient.objects.environment.Environment import get_deployment_tasks [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"]})
开发者ID:tinyxiao,项目名称:python-fuelclient,代码行数:39,代码来源:test_environment.py

示例5: deployment_tasks

# 需要导入模块: from fuelclient.objects.environment import Environment [as 别名]
# 或者: from fuelclient.objects.environment.Environment import get_deployment_tasks [as 别名]
 def deployment_tasks(self, params):
     """Modify deployment_tasks for environment:
             fuel env --env 1 --deployment-tasks --download
             fuel env --env 1 --deployment-tasks --upload
     """
     cluster = Environment(params.env)
     dir_path = self.full_path_directory(
         params.dir, 'cluster_{0}'.format(params.env))
     full_path = '{0}/deployment_tasks'.format(dir_path)
     if params.download:
         tasks = cluster.get_deployment_tasks()
         self.serializer.write_to_path(full_path, tasks)
         print("Deployment tasks for cluster {0} "
               "downloaded into {1}.yaml.".format(cluster.id, full_path))
     elif params.upload:
         tasks = self.serializer.read_from_file(full_path)
         cluster.update_deployment_tasks(tasks)
         print("Deployment tasks for cluster {0} "
               "uploaded from {1}.yaml".format(cluster.id, full_path))
开发者ID:tinyxiao,项目名称:python-fuelclient,代码行数:21,代码来源:environment.py


注:本文中的fuelclient.objects.environment.Environment.get_deployment_tasks方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。