Skip to content

Commit

Permalink
Added missing test for cleanup call
Browse files Browse the repository at this point in the history
  • Loading branch information
schlunma committed Mar 2, 2023
1 parent a3daf9c commit f87e25e
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/unit/preprocessor/test_preprocessor_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,38 @@ def test_close():
product.save.assert_called_once_with()
product.save_provenance.assert_called_once_with()
assert product._cubes is None


@mock.patch('esmvalcore.preprocessor.preprocess', autospec=True)
def test_save_no_cleanup(mock_preprocess):
"""Test ``save``."""
product = mock.create_autospec(PreprocessorFile, instance=True)
product.settings = {'save': {}}
product._cubes = mock.sentinel.cubes
product._input_files = mock.sentinel.input_files

PreprocessorFile.save(product)

assert mock_preprocess.mock_calls == [
mock.call(
mock.sentinel.cubes, 'save', input_files=mock.sentinel.input_files
),
]


@mock.patch('esmvalcore.preprocessor.preprocess', autospec=True)
def test_save_cleanup(mock_preprocess):
"""Test ``save``."""
product = mock.create_autospec(PreprocessorFile, instance=True)
product.settings = {'save': {}, 'cleanup': {}}
product._cubes = mock.sentinel.cubes
product._input_files = mock.sentinel.input_files

PreprocessorFile.save(product)

assert mock_preprocess.mock_calls == [
mock.call(
mock.sentinel.cubes, 'save', input_files=mock.sentinel.input_files
),
mock.call([], 'cleanup', input_files=mock.sentinel.input_files),
]

0 comments on commit f87e25e

Please sign in to comment.