diff --git a/pygeoapi/resources/schemas/config/pygeoapi-config-0.x.yml b/pygeoapi/resources/schemas/config/pygeoapi-config-0.x.yml index c1e925c39..6a5f068df 100644 --- a/pygeoapi/resources/schemas/config/pygeoapi-config-0.x.yml +++ b/pygeoapi/resources/schemas/config/pygeoapi-config-0.x.yml @@ -1,5 +1,5 @@ $schema: https://json-schema.org/draft/2020-12/schema -$id: https://raw.githubusercontent.com/geopython/pygeoapi/master/pygeoapi/schemas/config/pygeoapi-config-0.x.yml +$id: https://raw.githubusercontent.com/geopython/pygeoapi/refs/heads/master/pygeoapi/resources/schemas/config/pygeoapi-config-0.x.yml title: pygeoapi configuration schema description: pygeoapi configuration schema @@ -132,7 +132,9 @@ properties: type: string description: plugin name (see `pygeoapi.plugin` for supported process_managers) connection: - type: string + oneOf: + - type: string + - type: object description: connection info to store jobs (e.g. filepath) output_dir: type: string diff --git a/tests/other/test_config.py b/tests/other/test_config.py index 0ab728ffe..c7e80fcf2 100644 --- a/tests/other/test_config.py +++ b/tests/other/test_config.py @@ -99,3 +99,39 @@ def test_validate_config(config): } with pytest.raises(ValidationError): validate_config(cfg_copy) + + +def test_validate_config_process_manager(config): + """ + Test that the process manager config can be validated + as both a string or an object (i.e. PostgreSQL or TinyDB) + """ + cfg_copy = deepcopy(config) + cfg_copy['server']['manager'] = { + 'name': 'TinyDB', + 'connection': '/tmp/pygeoapi_test.db', + 'output_dir': '/tmp/', + } + assert validate_config(cfg_copy) + + with pytest.raises(ValidationError): + # make sure an int is validated as invalid + cfg_copy['server']['manager'] = { + 'name': 'TinyDB', + 'connection': 12345, + 'output_dir': '/tmp/', + } + validate_config(cfg_copy) + + cfg_copy['server']['manager'] = { + 'name': 'PostgreSQL', + 'connection': { + 'host': 'localhost', + 'port': 5432, + 'database': 'pygeoapi', + 'user': 'pygeoapi', + 'password': 'pygeoapi', + }, + 'output_dir': '/tmp/', + } + assert validate_config(cfg_copy)