Пример #1
0
def test_sync__download_grids(parse_args_mock, tmp_path, capsys):
    parse_args_mock.return_value = argparse.Namespace(
        bbox=None,
        list_files=False,
        file="us_noaa_alaska",
        all=False,
        source_id=None,
        area_of_use=None,
        verbose=True,
        target_directory=str(tmp_path),
        system_directory=False,
        spatial_test="intersects",
        exclude_world_coverage=False,
        include_already_downloaded=False,
    )
    main()
    captured = capsys.readouterr()
    paths = sorted(Path(path).name for path in glob(str(tmp_path.joinpath("*"))))
    if grids_available("us_noaa_alaska.tif", check_network=False):
        assert paths == ["files.geojson"]
        assert captured.out == ""
    else:
        assert paths == ["files.geojson", "us_noaa_alaska.tif"]
        assert captured.out == "Downloading: https://cdn.proj.org/us_noaa_alaska.tif\n"
    # make sure not downloaded again
    with proj_env():
        append_data_dir(str(tmp_path))
        main()
        captured = capsys.readouterr()
        assert captured.out == ""
Пример #2
0
def test_sync_download(download_mock, parse_args_mock):
    main()
    download_mock.assert_called_with(
        directory=get_user_data_dir(),
        file_url="https://cdn.proj.org/fr_ign_ntf_r93.tif",
        sha256="0aa738b3e00fd2d64f8e3cd0e76034d4792374624fa0e133922433c9491bbf2a",
        short_name="fr_ign_ntf_r93.tif",
        verbose=False,
    )
Пример #3
0
def test_sync_download__directory(
    load_grid_geojson_mock, download_mock, parse_args_mock
):
    load_grid_geojson_mock.return_value = _load_grid_geojson()
    main()
    download_mock.assert_called_with(
        directory="test_directory",
        file_url="https://cdn.proj.org/fr_ign_ntf_r93.tif",
        sha256="0aa738b3e00fd2d64f8e3cd0e76034d4792374624fa0e133922433c9491bbf2a",
        short_name="fr_ign_ntf_r93.tif",
        verbose=True,
    )
    load_grid_geojson_mock.assert_called_with(target_directory="test_directory")