def test_get_config(self):
        rest = _RestProxyForTest()
        configs = PropagatorConfigs(rest)

        rest.expect_get(f"{PropagatorConfigs.REST_ENDPOINT_PREFIX}/aaa", 200, {
            'uuid': 'aaa',
            'project': 'bbb'
        })
        config = configs.get_config('aaa')
        self.assertEqual('aaa', config.get_uuid())
        self.assertEqual('bbb', config.get_project())

        # the public config exists
        rest.expect_get(
            f"{PropagatorConfigs.REST_ENDPOINT_PREFIX}/00000000-0000-0000-0000-000000000003",
            200, FULL_CONFIG_JSON_OUTPUT)
        config = configs.get_config("00000000-0000-0000-0000-000000000003")
        self.assertEqual(FULL_CONFIG_JSON_OUTPUT, config.get_config_json())

        # propagator config with id "aaa" does not exist
        rest.expect_get(f"{PropagatorConfigs.REST_ENDPOINT_PREFIX}/aaa", 404,
                        {})
        config = configs.get_config('aaa')
        self.assertIsNone(config)

        rest.expect_get(f"{PropagatorConfigs.REST_ENDPOINT_PREFIX}/aaa", 403,
                        {})
        with self.assertRaises(RuntimeError):
            config = configs.get_config('aaa')
Example #2
0
    def test_get_public_configs(self, service):
        # Config management isn't very common, doesn't merit direct addition to service.
        configs = PropagatorConfigs(service.rest)

        public_config_1 = configs.get_config(PropagatorConfigs.PUBLIC_CONFIG_ALL_PLANETS_AND_MOON)
        assert "00000000-0000-0000-0000-000000000001" == public_config_1.get_uuid()

        public_config_2 = configs.get_config(PropagatorConfigs.PUBLIC_CONFIG_SUN_ONLY)
        assert "00000000-0000-0000-0000-000000000002" == public_config_2.get_uuid()

        public_config_3 = configs.get_config(
            PropagatorConfigs.PUBLIC_CONFIG_ALL_PLANETS_AND_MOON_AND_ASTEROIDS)
        assert "00000000-0000-0000-0000-000000000003" == public_config_3.get_uuid()
Example #3
0
    def test_get_config(self):
        rest = _RestProxyForTest()
        configs = PropagatorConfigs(rest)

        rest.expect_get("/config/aaa", 200, {'uuid': 'aaa', 'project': 'bbb'})
        config = configs.get_config('aaa')
        self.assertEqual('aaa', config.get_uuid())
        self.assertEqual('bbb', config.get_project())

        rest.expect_get("/config/00000000-0000-0000-0000-000000000003", 200,
                        FULL_CONFIG_JSON_OUTPUT)
        config = configs.get_config("00000000-0000-0000-0000-000000000003")
        self.assertEqual(FULL_CONFIG_JSON_OUTPUT, config.get_config_json())

        rest.expect_get("/config/aaa", 404, {})
        config = configs.get_config('aaa')
        self.assertIsNone(config)

        rest.expect_get("/config/aaa", 403, {})
        with self.assertRaises(RuntimeError):
            config = configs.get_config('aaa')
Example #4
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])