Beispiel #1
0
    def test_get_configuration(self):
        config_fields = [
            x for x in dir(core.config.config)
            if not x.startswith('__') and type(getattr(
                core.config.config, x)).__name__ in ['str', 'unicode', 'int']
        ]
        path_fields = [
            x for x in dir(core.config.paths)
            if (not x.startswith('__') and type(getattr(
                core.config.paths, x)).__name__ in ['str', 'unicode'])
        ]
        config_fields = list(set(config_fields) - set(path_fields))
        configs = {
            key: getattr(core.config.config, key)
            for key in config_fields
        }
        paths = {key: getattr(core.config.paths, key) for key in path_fields}
        for key, value in paths.items():
            response = self.app.get('/configuration/{0}'.format(key),
                                    headers=self.headers)
            self.assertEqual(response.status_code, SUCCESS)
            response = json.loads(response.get_data(as_text=True))
            self.assertEqual(response[key], value)

        for key, value in configs.items():
            response = self.app.get('/configuration/{0}'.format(key),
                                    headers=self.headers)
            self.assertEqual(response.status_code, SUCCESS)
            response = json.loads(response.get_data(as_text=True))
            self.assertEqual(response[key], str(value))

        self.get_with_status_check('/configuration/junkName',
                                   error='Configuration key does not exist.',
                                   headers=self.headers,
                                   status_code=OBJECT_DNE_ERROR)
Beispiel #2
0
    def test_get_configuration(self):
        config_fields = [x for x in dir(core.config.config) if
                         not x.startswith('__')
                         and type(getattr(core.config.config, x)).__name__ in ['str', 'unicode', 'int']]
        path_fields = [x for x in dir(core.config.paths) if
                       (not x.startswith('__')
                        and type(getattr(core.config.paths, x)).__name__ in ['str', 'unicode'])]
        config_fields = list(set(config_fields) - set(path_fields))
        configs = {key: getattr(core.config.config, key) for key in config_fields}
        paths = {key: getattr(core.config.paths, key) for key in path_fields}
        for key, value in paths.items():
            response = self.app.get('/configuration/{0}'.format(key), headers=self.headers)
            self.assertEqual(response.status_code, 200)
            response = json.loads(response.get_data(as_text=True))
            self.assertEqual(response[key], value)

        for key, value in configs.items():
            response = self.app.get('/configuration/{0}'.format(key), headers=self.headers)
            self.assertEqual(response.status_code, 200)
            response = json.loads(response.get_data(as_text=True))
            self.assertEqual(response[key], str(value))

        response = self.app.get('/configuration/junkName', headers=self.headers)
        self.assertEqual(response.status_code, 200)
        response = json.loads(response.get_data(as_text=True))
        self.assertEqual(response['junkName'], "Error: key not found")
Beispiel #3
0
    def test_set_configuration(self):
        original_config_fields = [x for x in dir(core.config.config) if (not x.startswith('__') and
                                                                         type(getattr(core.config.config, x)).__name__
                                                                         in ['str', 'unicode'])]
        original_path_fields = [x for x in dir(core.config.paths) if (not x.startswith('__') and
                                                                      type(getattr(core.config.paths, x)).__name__
                                                                      in ['str', 'unicode'])]
        data = {"templates_path": 'templates_path_reset',
                "workflows_path": 'workflows_path_reset',
                "apps_path": core.config.paths.apps_path,
                "profile_visualizations_path": 'profile_visualizations_path_reset',
                "keywords_path": 'keywords_path_reset',
                "db_path": 'db_path_reset',
                "tls_version": 'tls_version_reset',
                "https": 'true',
                "private_key_path": 'private_key_path',
                "debug": 'false',
                "default_server": 'default_server_reset',
                "host": 'host_reset',
                "port": 'port_reset'}

        self.post_with_status_check('/configuration/set', 'success', headers=self.headers, data=data)

        config_fields = [x for x in dir(core.config.config) if (not x.startswith('__') and
                                                                type(getattr(core.config.config, x)).__name__
                                                                in ['str', 'unicode'])]
        path_fields = [x for x in dir(core.config.paths) if (not x.startswith('__') and
                                                             type(getattr(core.config.paths, x)).__name__
                                                             in ['str', 'unicode'])]
        orderless_list_compare(self, config_fields, original_config_fields)
        orderless_list_compare(self, path_fields, original_path_fields)

        for key in data.keys():
            self.assertIn(key, (set(config_fields) | set(path_fields)))

        config_fields = list(set(config_fields) - set(path_fields))
        configs = {key: getattr(core.config.config, key) for key in config_fields}
        paths = {key: getattr(core.config.paths, key) for key in path_fields}

        for key, value in configs.items():
            if key in data:
                self.assertEqual(value, data[key])

        for key, value in paths.items():
            if key in data:
                self.assertEqual(value, data[key])