def test_parse_invalid_event_type(monkeypatch, valid_config_json: str):
    monkeypatch.setattr(os, 'getenv', _get_env_mock)
    config_json = _replace_in_config(valid_config_json,
                                     key='events.query_something.type',
                                     value='INVALID')
    with pytest.raises(dataclasses_jsonschema.ValidationError):
        parse_app_config_json(config_json)
def test_invalid_app_version(monkeypatch, valid_config_json: str):
    monkeypatch.setattr(os, 'getenv', _get_env_mock)
    config_json = _replace_in_config(valid_config_json,
                                     key='app.version',
                                     value='')
    with pytest.raises(ValueError):
        parse_app_config_json(config_json)
Esempio n. 3
0
def config(path: Union[str, Path]) -> AppConfig:
    if isinstance(path, str):
        path = Path(path)
    with open(path, 'r') as f:
        app_config = parse_app_config_json(f.read())
        app_config.server = server_config()
        return app_config
Esempio n. 4
0
def _update_api_spec(config_files: str):
    """
    Computes and updates api module OpenAPI spec from specified config files argument.
    """
    apps_config = []
    config_files_list = config_files.split(',')
    with open(config_files_list[0], 'r', encoding="utf-8") as sf:
        server_config = parse_server_config_json(sf.read())
        api.register_server_config(server_config)
    for path in config_files_list[1:]:
        with open(path, 'r', encoding="utf-8") as f:
            app_config = parse_app_config_json(f.read())
            apps_config.append(app_config)
    api.register_apps(apps_config)
Esempio n. 5
0
def _load_app_config(path: str):
    """
    Load app configuration from json file
    """
    with open(path) as f:
        return parse_app_config_json(f.read())
Esempio n. 6
0
def _load_app_config(path: str) -> AppConfig:
    """
    Load app configuration from json file
    """
    with open(path, encoding="utf-8") as f:
        return parse_app_config_json(f.read())
Esempio n. 7
0
def plugin_config():
    with open('plugins/auth/basic-auth/config/plugin-config.json', 'r') as f:
        return parse_app_config_json(f.read())
def test_parse_app_config_json(monkeypatch, valid_config_json: str,
                               valid_result_app_config: AppConfig):
    monkeypatch.setattr(os, 'getenv', _get_env_mock)
    config = parse_app_config_json(valid_config_json)
    assert config == valid_result_app_config