def test_download_ranged_http(event_loop, httpserver, tmpdir):
    tmpdir = str(tmpdir)
    httpserver.serve_content('SIMPLE  = T',
                             headers={'Content-Disposition': "attachment; filename=testfile.fits"})
    dl = Downloader(loop=event_loop)

    dl.enqueue_file(httpserver.url, path=Path(tmpdir))

    assert dl.queued_downloads == 1

    f = dl.download()

    assert len(f) == 1
    assert Path(f[0]).name == "testfile.fits"
    assert sha256sum(f[0]) == "a1c58cd340e3bd33f94524076f1fa5cf9a7f13c59d5272a9d4bc0b5bc436d9b3"
Beispiel #2
0
def validate_test_file(f):
    assert len(f) == 1
    assert Path(f[0]).name == "testfile.fits"
    assert sha256sum(
        f[0]
    ) == "a1c58cd340e3bd33f94524076f1fa5cf9a7f13c59d5272a9d4bc0b5bc436d9b3"
Beispiel #3
0
def test_sha256sum():
    tempfilename = tempfile.mktemp()
    filehash = "559aead08264d5795d3909718cdd05abd49572e84fe55590eef31a88a08fdffd"
    with open(tempfilename, 'w') as f:
        f.write('A')
    assert sha256sum(tempfilename) == filehash