From d0e02a79297a7040c0ad5b00fa413a3f4b59b5c6 Mon Sep 17 00:00:00 2001 From: Tom Kralidis Date: Sat, 16 Dec 2023 04:15:02 -0500 Subject: [PATCH] fix EDR parameter names (#1433) --- pygeoapi/api.py | 10 +++++----- tests/test_api.py | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pygeoapi/api.py b/pygeoapi/api.py index d5bf3673e0..8e76b0f5f2 100644 --- a/pygeoapi/api.py +++ b/pygeoapi/api.py @@ -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({ @@ -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(',') @@ -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) diff --git a/tests/test_api.py b/tests/test_api.py index cd6070ad20..b3bb09aca1 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -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'] @@ -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') @@ -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') @@ -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', })