Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix converter_options parsing #120

Merged
merged 2 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion geospaas_processing/converters/syntool/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
12 changes: 12 additions & 0 deletions tests/converters/test_syntool_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down