diff --git a/src/openeo_pg_parser/translate.py b/src/openeo_pg_parser/translate.py index add5ca9..dd4418a 100644 --- a/src/openeo_pg_parser/translate.py +++ b/src/openeo_pg_parser/translate.py @@ -286,7 +286,7 @@ def translate_process_graph(pg_filepath, process_defs=None, parameters=None): # remove first layer of the process graph parameters = {} if parameters is None else parameters - if "parameters" in process_graph.keys(): + if process_graph.get("parameters"): for parameter_def in process_graph['parameters']: parameter = OpenEOParameter(parameter_def) parameters.update({parameter.name: parameter.default_value}) diff --git a/tests/process_graphs/none.json b/tests/process_graphs/none.json new file mode 100644 index 0000000..c7077d0 --- /dev/null +++ b/tests/process_graphs/none.json @@ -0,0 +1,23 @@ +{ + "id": "none-pg", + "summary": null, + "description": null, + "returns": null, + "parameters": null, + "process_graph": { + "sub": { + "process_id": "subtract", + "arguments": { + "data": [ + { + "from_argument": "nir" + }, + { + "from_argument": "red" + } + ] + }, + "result": true + } + } +} diff --git a/tests/test_translate.py b/tests/test_translate.py index bdbab8d..b3ddbff 100644 --- a/tests/test_translate.py +++ b/tests/test_translate.py @@ -17,6 +17,13 @@ def test_translate_process_graph(self): print(graph) assert True + def test_translate_process_graph_none_params(self): + """Translate a minimal process graph with all allowed values set to None.""" + pg_file = os.path.join(self.pg_dirpath, "none.json") + graph = translate_process_graph(pg_file) + print(graph) + assert True + def test_process_graph_not_found(self): """ Checks if an error is thrown when a process graph file cannot be found. """ pg_filepath = os.path.join(self.pg_dirpath, "does_not_exist.json")