Esempio n. 1
0
    def test_wget_file(self, mock_system, tmp_path):
        # tests the write call made to os.system
        exporter = ESACCIExporter(tmp_path)

        url_path = 'ftp://geo10.elie.ucl.ac.be/v207/ESACCI-LC-L4-LCCS-Map-'\
            '300m-P1Y-1992_2015-v2.0.7b.nc.zip'
        folder = (tmp_path / 'raw' / 'esa_cci_landcover').as_posix()

        exporter.wget_file()
        mock_system.assert_called_once_with(f'wget {url_path} -P {folder}')
Esempio n. 2
0
    def test_wget_checkpointing(self, mock_system, tmp_path, capsys):
        # checks we don't redownload files
        exporter = ESACCIExporter(tmp_path)

        # setup the already downloaded file
        test_filename = exporter.target_file
        (tmp_path / f'raw/esa_cci_landcover/{test_filename}').touch()
        (tmp_path / f'raw/esa_cci_landcover/legend.csv').touch()

        exporter.wget_file()
        captured = capsys.readouterr()

        expected_stdout = f'{test_filename} already exists! Skipping\n'
        assert expected_stdout in captured.out, \
            f'Expected stdout to be {expected_stdout}, got {captured.out}'
        mock_system.assert_not_called(
        ), 'os.system was called! Should have been skipped'