示例#1
0
 def test_fetch(self):
     target_folder = '/tmp/variety/ImageFetcher'
     shutil.rmtree(target_folder, ignore_errors=True)
     os.makedirs(target_folder)
     for url in ["http://wallpapers.wallhaven.cc/wallpapers/full/wallhaven-207261.jpg",
                 "http://unsplash.com/photos/7EqQ1s3wIAI/download",
                 "http://az608707.vo.msecnd.net/files/GreaterFlamingos_EN-US13682107304_1366x768.jpg",
                 "http://a.desktopprassets.com/wallpapers/07865fb0cb575e82fe43d3e1b634f6e2309e2114/foto_alese45.jpg",
                 ]:
         f = ImageFetcher.fetch(url, target_folder, verbose=False)
         self.assertIsNotNone(f)
         self.assertTrue(os.path.isfile(f))
         self.assertTrue(Util.is_image(f, check_contents=False))
         self.assertTrue(Util.is_image(f, check_contents=True))
         self.assertNotEqual('download', f)
示例#2
0
 def test_fetch(self):
     target_folder = '/tmp/variety/ImageFetcher'
     shutil.rmtree(target_folder, ignore_errors=True)
     os.makedirs(target_folder)
     for url in [
             "http://wallpapers.wallhaven.cc/wallpapers/full/wallhaven-207261.jpg",
             "http://unsplash.com/photos/7EqQ1s3wIAI/download",
             "http://az608707.vo.msecnd.net/files/GreaterFlamingos_EN-US13682107304_1366x768.jpg",
             "http://a.desktopprassets.com/wallpapers/07865fb0cb575e82fe43d3e1b634f6e2309e2114/foto_alese45.jpg",
     ]:
         f = ImageFetcher.fetch(url, target_folder, verbose=False)
         self.assertIsNotNone(f)
         self.assertTrue(os.path.isfile(f))
         self.assertTrue(Util.is_image(f, check_contents=False))
         self.assertTrue(Util.is_image(f, check_contents=True))
         self.assertNotEqual('download', f)
示例#3
0
def test_download_one_for(test_case, dl):
    dl.target_folder = '/tmp/variety/%s' % dl.__class__.__name__
    shutil.rmtree(dl.target_folder, ignore_errors=True)
    for _ in xrange(5):
        f = dl.download_one()
        if f and os.path.isfile(f) and Util.is_image(f, check_contents=True):
            return
    test_case.fail("Tried download_one 5 times, all failed")
示例#4
0
def test_download_one_for(test_case, dl):
    dl.target_folder = '/tmp/variety/%s' % dl.__class__.__name__
    shutil.rmtree(dl.target_folder, ignore_errors=True)
    for _ in xrange(5):
        f = dl.download_one()
        if f and os.path.isfile(f) and Util.is_image(f, check_contents=True):
            return
    test_case.fail("Tried download_one 5 times, all failed")