From b0efeef90e72f730f9f7f51484e19e243d8dec27 Mon Sep 17 00:00:00 2001 From: Adrien Perrin Date: Fri, 18 Oct 2024 11:12:09 +0000 Subject: [PATCH 1/2] fix converter option parsing --- geospaas_processing/converters/syntool/converter.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/geospaas_processing/converters/syntool/converter.py b/geospaas_processing/converters/syntool/converter.py index 5f60cc73..286151d3 100644 --- a/geospaas_processing/converters/syntool/converter.py +++ b/geospaas_processing/converters/syntool/converter.py @@ -220,7 +220,11 @@ def parse_converter_options(self, kwargs): """ converter_options = self.converter_options.copy() converter_options_list = [] - converter_options.update(kwargs.pop('converter_options', {})) + kwargs_converter_options = kwargs.pop('converter_options', {}) + if not isinstance(kwargs_converter_options, dict): + logger.warning("'converter_options' should be a dictionary") + kwargs_converter_options = {} + converter_options.update(kwargs_converter_options) if converter_options: converter_options_list.append('-opt') for key, value in converter_options.items(): From 6bca7a565ae0d66facff79d766c482a554adf1ef Mon Sep 17 00:00:00 2001 From: Adrien Perrin Date: Fri, 18 Oct 2024 11:29:12 +0000 Subject: [PATCH 2/2] add test for converter_options --- tests/converters/test_syntool_converters.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/converters/test_syntool_converters.py b/tests/converters/test_syntool_converters.py index fde37761..6f60619b 100644 --- a/tests/converters/test_syntool_converters.py +++ b/tests/converters/test_syntool_converters.py @@ -198,6 +198,18 @@ def test_parse_converter_options_no_kwarg(self): result = converter.parse_converter_options({}) self.assertListEqual(result, ['-opt', 'bar=baz']) + def test_parse_converter_options_not_dict(self): + """Test parsing converter options when the converter_options + kwarg is not a dictionary + """ + converter = syntool_converter.BasicSyntoolConverter( + converter_type='foo', + converter_options={'bar': 'baz'}, + ingest_parameter_files='qux') + with self.assertLogs(level=logging.WARNING): + result = converter.parse_converter_options({'converter_options': None}) + self.assertListEqual(result, ['-opt', 'bar=baz']) + def test_parse_converter_args(self): """Test parsing converter arguments""" converter = syntool_converter.BasicSyntoolConverter(