raise error for collections without queryables (#1757)

This commit is contained in:
Tom Kralidis
2024-07-24 16:11:44 -04:00
committed by GitHub
parent af8483a25b
commit 6c538ca330
2 changed files with 11 additions and 0 deletions
+6
View File
@@ -134,6 +134,12 @@ def get_collection_queryables(api: API, request: Union[APIRequest, Any],
LOGGER.debug('Loading record provider')
p = load_plugin('provider', get_provider_by_type(
api.config['resources'][dataset]['providers'], 'record'))
finally:
msg = 'queryables not available for this collection'
return api.get_exception(
HTTPStatus.BAD_REQUEST, headers, request.format,
'NoApplicableError', msg)
except ProviderGenericError as err:
return api.get_exception(
err.http_status_code, headers, request.format,
+5
View File
@@ -62,6 +62,11 @@ def test_get_collection_queryables(config, api_):
api_, req, 'notfound')
assert code == HTTPStatus.NOT_FOUND
req = mock_api_request()
rsp_headers, code, response = get_collection_queryables(
api_, req, 'mapserver_world_map')
assert code == HTTPStatus.BAD_REQUEST
req = mock_api_request({'f': 'html'})
rsp_headers, code, response = get_collection_queryables(api_, req, 'obs')
assert rsp_headers['Content-Type'] == FORMAT_TYPES[F_HTML]