Skip to content

Commit

Permalink
fix EDR parameter names (#1433)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkralidis committed Dec 16, 2023
1 parent 0e7a836 commit d0e02a7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions pygeoapi/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1194,9 +1194,9 @@ def describe_collections(self, request: Union[APIRequest, Any],
LOGGER.debug('Adding EDR links')
parameters = p.get_fields()
if parameters:
collection['parameter-names'] = {}
collection['parameter_names'] = {}
for f in parameters['field']:
collection['parameter-names'][f['id']] = f
collection['parameter_names'][f['id']] = f

for qt in p.get_query_types():
collection['links'].append({
Expand Down Expand Up @@ -3766,8 +3766,8 @@ def get_collection_edr_query(
HTTPStatus.BAD_REQUEST, headers, request.format,
'InvalidParameterValue', msg)

LOGGER.debug('Processing parameter-name parameter')
parameternames = request.params.get('parameter-name') or []
LOGGER.debug('Processing parameter_names parameter')
parameternames = request.params.get('parameter_names') or []
if isinstance(parameternames, str):
parameternames = parameternames.split(',')

Expand Down Expand Up @@ -3843,7 +3843,7 @@ def get_collection_edr_query(

if parameternames and not any((fld['id'] in parameternames)
for fld in p.get_fields()['field']):
msg = 'Invalid parameter-name'
msg = 'Invalid parameter_names'
return self.get_exception(
HTTPStatus.BAD_REQUEST, headers, request.format,
'InvalidParameterValue', msg)
Expand Down
10 changes: 5 additions & 5 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1863,7 +1863,7 @@ def test_get_collection_edr_query(config, api_):
req = mock_request()
rsp_headers, code, response = api_.describe_collections(req, 'icoads-sst')
collection = json.loads(response)
parameter_names = list(collection['parameter-names'].keys())
parameter_names = list(collection['parameter_names'].keys())
parameter_names.sort()
assert len(parameter_names) == 4
assert parameter_names == ['AIRT', 'SST', 'UWND', 'VWND']
Expand All @@ -1885,9 +1885,9 @@ def test_get_collection_edr_query(config, api_):
req, 'icoads-sst', None, 'position')
assert code == HTTPStatus.BAD_REQUEST

# bad parameter-name parameter
# bad parameter_names parameter
req = mock_request({
'coords': 'POINT(11 11)', 'parameter-name': 'bad'
'coords': 'POINT(11 11)', 'parameter_names': 'bad'
})
rsp_headers, code, response = api_.get_collection_edr_query(
req, 'icoads-sst', None, 'position')
Expand Down Expand Up @@ -1918,7 +1918,7 @@ def test_get_collection_edr_query(config, api_):

# single parameter
req = mock_request({
'coords': 'POINT(11 11)', 'parameter-name': 'SST'
'coords': 'POINT(11 11)', 'parameter_names': 'SST'
})
rsp_headers, code, response = api_.get_collection_edr_query(
req, 'icoads-sst', None, 'position')
Expand Down Expand Up @@ -2035,7 +2035,7 @@ def test_get_collection_edr_query(config, api_):
# cube decreasing latitude coords and S3
req = mock_request({
'bbox': '-100,40,-99,45',
'parameter-name': 'tmn',
'parameter_names': 'tmn',
'datetime': '1994-01-01/1994-12-31',
})

Expand Down

0 comments on commit d0e02a7

Please sign in to comment.