Skip to content

Commit

Permalink
raise error for collections without queryables
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkralidis committed Jul 24, 2024
1 parent af8483a commit 7904fda
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pygeoapi/api/itemtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions tests/api/test_itemtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 7904fda

Please sign in to comment.