dbekaert / RAiDER

Raytracing Atmospheric Delay Estimation for RADAR
Apache License 2.0
70 stars 39 forks source link

[BUG] `test_get_orbits_from_slc_ids` fails: "call not found" #667

Open garlic-os opened 2 months ago

garlic-os commented 2 months ago

Describe the bug test_s1_orbits.py::test_get_orbits_from_slc_ids, a test that uses Mocker, fails for me with an AssertionError that says "call not found". I am not sure if this is a problem with the code or a problem with the test.

To Reproduce

  1. Checkout the dev branch
  2. Run the test RAiDER > test > test_s1_orbits.py > test_get_orbits_from_slc_ids
  3. Raises AssertionError: download_eofs(['20150621T120220'], ['S1A'], save_dir='/tmp/pytest-of-garlic/pytest-5/test_aoi_without_xpts0', force_asf=True) call not found

Expected behavior Test should pass if RAiDER is behaving correctly. If RAiDER is doing something wrong, then I am not able to tell what from this error.

Desktop

Additional context Full error:

/mnt/g/Garlic/Documents/Code/GitHub/RAiDER/test/test_s1_orbits.py::test_get_orbits_from_slc_ids failed: self = <MagicMock name='download_eofs' id='140665354331408'>
args = (['20150621T120220'], ['S1A'])
kwargs = {'force_asf': True, 'save_dir': '/tmp/pytest-of-garlic/pytest-5/test_aoi_without_xpts0'}
expected = call(['20150621T120220'], ['S1A'], save_dir='/tmp/pytest-of-garlic/pytest-5/test_aoi_without_xpts0', force_asf=True)
cause = None
actual = [call(['20150621T120220'], ['S1A'], save_dir='/mnt/g/Garlic/Documents/Code/GitHub/RAiDER', force_asf=True), call(['20150621T120232'], ['S1A'], save_dir='/mnt/g/Garlic/Documents/Code/GitHub/RAiDER', force_asf=True)]
expected_string = "download_eofs(['20150621T120220'], ['S1A'], save_dir='/tmp/pytest-of-garlic/pytest-5/test_aoi_without_xpts0', force_asf=True)"

    def assert_any_call(self, /, *args, **kwargs):
        """assert the mock has been called with the specified arguments.

        The assert passes if the mock has *ever* been called, unlike
        `assert_called_with` and `assert_called_once_with` that only pass if
        the call is the most recent one."""
        expected = self._call_matcher(_Call((args, kwargs), two=True))
        cause = expected if isinstance(expected, Exception) else None
        actual = [self._call_matcher(c) for c in self.call_args_list]
        if cause or expected not in _AnyComparer(actual):
            expected_string = self._format_mock_call_signature(args, kwargs)
>           raise AssertionError(
                '%s call not found' % expected_string
            ) from cause
E           AssertionError: download_eofs(['20150621T120220'], ['S1A'], save_dir='/tmp/pytest-of-garlic/pytest-5/test_aoi_without_xpts0', force_asf=True) call not found

/home/garlic/miniforge3/envs/RAiDER/lib/python3.12/unittest/mock.py:1015: AssertionError

During handling of the above exception, another exception occurred:

mocker = <pytest_mock.plugin.MockerFixture object at 0x7fef337242c0>

    def test_get_orbits_from_slc_ids(mocker):
        side_effect = [
            [Path('foo_start.txt'), Path('foo_stop.txt')],
            [Path('bar_start.txt'), Path('bar_end.txt'),
             Path('fiz_start.txt'), Path('fiz_end')],
        ]
        mocker.patch('eof.download.download_eofs',
                     side_effect=side_effect[0])

        orbit_files = s1_orbits.get_orbits_from_slc_ids(
            ['S1A_IW_SLC__1SSV_20150621T120220_20150621T120232_006471_008934_72D8']
        )
        assert orbit_files == side_effect[0]
        assert eof.download.download_eofs.call_count == 2
        for dt in '20150621T120220 20150621T120232'.split():
>           eof.download.download_eofs.assert_any_call(
                [dt],
                ['S1A'],
                save_dir=str(Path.cwd()),
                force_asf=True
            )
E           AssertionError: download_eofs(['20150621T120220'], ['S1A'], save_dir='/tmp/pytest-of-garlic/pytest-5/test_aoi_without_xpts0', force_asf=True) call not found
E           
E           pytest introspection follows:
E           
E           Args:
E           assert (['20150621T120232'], ['S1A']) == (['20150621T120220'], ['S1A'])
E             
E             At index 0 diff: ['20150621T120232'] != ['20150621T120220']
E             Use -v to get more diff
E           Kwargs:
E           assert {'force_asf':...itHub/RAiDER'} == {'force_asf':...ithout_xpts0'}
E             
E             Omitting 1 identical items, use -vv to show
E             Differing items:
E             {'save_dir': '/mnt/g/Garlic/Documents/Code/GitHub/RAiDER'} != {'save_dir': '/tmp/pytest-of-garlic/pytest-5/test_aoi_without_xpts0'}
E             Use -v to get more diff

/mnt/g/Garlic/Documents/Code/GitHub/RAiDER/test/test_s1_orbits.py:173: AssertionError
garlic-os commented 2 months ago

Oops, I didn't mean to do that.