From 01f1b838108da5b01dc2421913283dc09528da0e Mon Sep 17 00:00:00 2001 From: Bernhard Mallinger Date: Thu, 14 Dec 2023 14:56:10 +0100 Subject: [PATCH] Handle missing 'example' in describe_processes Fixes #1424 --- pygeoapi/api.py | 2 +- tests/test_api.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/pygeoapi/api.py b/pygeoapi/api.py index c1b924c18..fa7cf90b5 100644 --- a/pygeoapi/api.py +++ b/pygeoapi/api.py @@ -3314,7 +3314,7 @@ def describe_processes(self, request: Union[APIRequest, Any], if process is None: p2.pop('inputs') p2.pop('outputs') - p2.pop('example') + p2.pop('example', None) p2['jobControlOptions'] = ['sync-execute'] if self.manager.is_async: diff --git a/tests/test_api.py b/tests/test_api.py index cd6070ad2..e92973076 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -1633,6 +1633,16 @@ def test_describe_processes(config, api_): assert data['code'] == 'NoSuchProcess' assert rsp_headers['Content-Type'] == FORMAT_TYPES[F_JSON] + # Test describe doesn't crash if example is missing + req = mock_request() + processor = api_.manager.get_processor("hello-world") + example = processor.metadata.pop("example") + rsp_headers, code, response = api_.describe_processes(req) + processor.metadata['example'] = example + data = json.loads(response) + assert code == HTTPStatus.OK + assert len(data['processes']) == 2 + def test_execute_process(config, api_): req_body_0 = {