Beispiel #1
0
def test_download_resource_file(urlretrieve_mock, verbose, tmp_path, capsys):
    def dummy_urlretrieve(url, local_path):
        with open(local_path, "w") as testf:
            testf.write("TEST")

    urlretrieve_mock.side_effect = dummy_urlretrieve
    _download_resource_file(
        file_url="test_url",
        short_name="test_file.txt",
        directory=tmp_path,
        verbose=verbose,
        sha256=
        "94ee059335e587e501cc4bf90613e0814f00a7b08bc7c648fd865a2af6a22cc2",
    )
    urlretrieve_mock.assert_called_with("test_url",
                                        tmp_path / "test_file.txt.part")
    captured = capsys.readouterr()
    if not verbose:
        assert captured.out == ""
    else:
        assert captured.out == "Downloading: test_url\n"
    expected_file = tmp_path / "test_file.txt"
    assert expected_file.exists()
    assert (_sha256sum(expected_file) ==
            "94ee059335e587e501cc4bf90613e0814f00a7b08bc7c648fd865a2af6a22cc2")
Beispiel #2
0
def test_sha256sum(tmp_path):
    test_file = tmp_path / "test.file"
    test_file.write_text("TEST")
    assert (_sha256sum(test_file) ==
            "94ee059335e587e501cc4bf90613e0814f00a7b08bc7c648fd865a2af6a22cc2")
Beispiel #3
0
def test_sha256sum(tmp_path):
    test_file = tmp_path / "test.file"
    with open(test_file, "w") as testf:
        testf.write("TEST")
    assert (_sha256sum(test_file) ==
            "94ee059335e587e501cc4bf90613e0814f00a7b08bc7c648fd865a2af6a22cc2")