Exemple #1
0
def test_datafile_download():
    urls = ["https://google.com", "https://bing.com", "https://amazon.com"]
    attempt = 0
    for url in urls:
        DataFile.download_to_file(url, "datafile_download_temp")
        r = requests.get(urls[attempt])
        if r.status_code == 200:
            break
    assert os.path.exists("datafile_download_temp")
    os.remove("datafile_download_temp")
Exemple #2
0
def test_datafile_download_bad_url(display):
    display.change_status = mock.MagicMock(name="change_status")
    mydownloadqueue = DownloadQueue()
    url = "https://bad"
    DataFile.download_to_file(url,
                              "datafile_download_temp",
                              "datafile download name",
                              mydownloadqueue,
                              display=display)
    while mydownloadqueue.length > 0:
        pass
    assert display.change_status.call_count > 0
    assert not os.path.exists("datafile_download_temp")