Skip to content

Commit

Permalink
adapt unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aperrin66 committed Mar 6, 2024
1 parent bc14097 commit fa8561b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tests/converters/test_syntool_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ def test_ingest(self):
"""Test that the right command is called"""
converter = syntool_converter.SyntoolConverter()
with mock.patch('subprocess.run') as mock_run, \
mock.patch('os.remove') as mock_remove, \
mock.patch('tempfile.TemporaryDirectory') as mock_tmp_dir, \
mock.patch.object(converter, 'move_results',
return_value=['3413_foo/1', '3413_foo/2']):
Expand All @@ -66,7 +65,6 @@ def test_ingest(self):
check=True,
capture_output=True,
env=None)
mock_remove.assert_called_with('/bar/foo.tiff')
self.assertEqual(result, ['ingested/3413_foo/1', 'ingested/3413_foo/2'])

def test_ingest_subprocess_error(self):
Expand Down Expand Up @@ -122,7 +120,7 @@ def test_find_ingest_config_str(self):
converter = syntool_converter.BasicSyntoolConverter(
converter_type='foo',
ingest_parameter_files='bar')
self.assertEqual(converter.find_ingest_config('baz'), 'bar')
self.assertEqual(converter.find_ingest_config('baz'), ['bar'])

def test_find_ingest_config_list(self):
"""Test getting the ingester parameters file from a list of
Expand All @@ -138,7 +136,7 @@ def test_find_ingest_config_list(self):
matches=lambda f: f.startswith('a'),
ingest_file='qux'),
])
self.assertEqual(converter.find_ingest_config('baz'), 'bar')
self.assertEqual(converter.find_ingest_config('baz'), ['bar'])

def test_find_ingest_config_error(self):
"""An exception must be raised if no config is found"""
Expand Down Expand Up @@ -205,7 +203,8 @@ def test_run(self):
return_value=['conv1.tiff', 'conv2.tiff']) as mock_convert, \
mock.patch.object(converter, 'ingest',
side_effect=[['ingested_dir1'], ['ingested_dir2']]) as mock_ingest, \
mock.patch.object(converter, 'post_ingest') as mock_post_ingest:
mock.patch.object(converter, 'post_ingest') as mock_post_ingest, \
mock.patch('os.remove') as mock_remove:
converter.run(
in_file='in.nc',
out_dir='out',
Expand All @@ -225,6 +224,7 @@ def test_run(self):
'--options-file', converter.PARAMETERS_DIR / 'bar']),
])
mock_post_ingest.assert_called_once_with(['ingested_dir1', 'ingested_dir2'], 'results')
mock_remove.assert_has_calls((mock.call('conv1.tiff'), mock.call('conv2.tiff')))


class Sentinel1SyntoolConverterTestCase(unittest.TestCase):
Expand Down

0 comments on commit fa8561b

Please sign in to comment.