def test_mirrors(self):
     goodurl = "http://{host}:{port}/{path}".format(path=THIS_FILE, **HTTP)
     badurl = "http://{host}:{deadport}/{path}".format(path=randstr(), **HTTP)
     target = "httpdownloader-test-" + randstr()
     dl = HTTPDownloader([badurl, goodurl], target)
     assert dl.location == goodurl
     assert dl.is_available()
     dl.download_to_cache()
     assert os.path.exists(target)
     os.remove(target)
 def test_download(self):
     target = "httpdownloader-test-" + randstr()
     dl = HTTPDownloader("http://{host}:{port}/{path}".format(path=THIS_FILE, **HTTP), target)
     assert dl.is_available()
     dl.download_to_cache()
     assert os.path.exists(target)
     os.remove(target)
 def test_not_available(self):
     bogus_filename = randstr()
     dl = HTTPDownloader("http://{host}:{port}/%s".format(**HTTP) % bogus_filename, bogus_filename)
     assert not dl.is_available()