From fa8561b1e7eb6f6ef31d52700b282b8d4d5ef1e2 Mon Sep 17 00:00:00 2001 From: Adrien Perrin Date: Wed, 6 Mar 2024 07:00:03 +0000 Subject: [PATCH] adapt unit tests --- tests/converters/test_syntool_converters.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/converters/test_syntool_converters.py b/tests/converters/test_syntool_converters.py index 43dbe576..57527c37 100644 --- a/tests/converters/test_syntool_converters.py +++ b/tests/converters/test_syntool_converters.py @@ -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']): @@ -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): @@ -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 @@ -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""" @@ -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', @@ -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):