def test_get_configs(self):
        rest = _RestProxyForTest()
        configs_module = PropagatorConfigs(rest)

        rest.expect_get(PropagatorConfigs.REST_ENDPOINT_PREFIX, 200,
                        {'items': []})
        configs = configs_module.get_configs()
        self.assertEqual(0, len(configs))

        rest.expect_get(
            PropagatorConfigs.REST_ENDPOINT_PREFIX, 200, {
                'items': [{
                    'uuid': 'aaa',
                    'project': 'bbb'
                }, {
                    'uuid': 'ccc',
                    'project': 'ddd'
                }]
            })
        configs = configs_module.get_configs()
        self.assertEqual(2, len(configs))
        self.assertEqual('aaa', configs[0].get_uuid())
        self.assertEqual('bbb', configs[0].get_project())
        self.assertEqual('ccc', configs[1].get_uuid())
        self.assertEqual('ddd', configs[1].get_project())
Esempio n. 2
0
    def test_config_management(self, service):
        # Config management isn't very common, doesn't merit direct addition to service.
        configs = PropagatorConfigs(service.rest)

        project = service.new_working_project()
        assert project is not None

        config = configs.new_config({'project': project.get_uuid(), 'description': 'test config'})
        assert project.get_uuid() == config.get_project()

        my_configs = configs.get_configs()
        assert config.get_uuid() in [c.get_uuid() for c in my_configs]

        config_again = configs.get_config(config.get_uuid())
        assert config.get_config_json() == config_again.get_config_json()

        configs.delete_config(config.get_uuid())

        my_configs = configs.get_configs()
        assert config.get_uuid() not in [c.get_uuid() for c in my_configs]
    def test_config_management(self):
        # Config management isn't very common, doesn't merit direct addition to service.
        configs = PropagatorConfigs(self.service.rest)

        project = self.service.new_working_project()
        self.assertIsNotNone(project)

        config = configs.new_config({
            'project': project.get_uuid(),
            'description': 'test config'
        })
        self.assertEqual(project.get_uuid(), config.get_project())

        my_configs = configs.get_configs()
        self.assertIn(config.get_uuid(), [c.get_uuid() for c in my_configs])

        config_again = configs.get_config(config.get_uuid())
        self.assertEqual(config.get_config_json(),
                         config_again.get_config_json())

        configs.delete_config(config.get_uuid())

        my_configs = configs.get_configs()
        self.assertNotIn(config.get_uuid(), [c.get_uuid() for c in my_configs])