def test_main_interface_falls_back_to_amazon(self): art.urllib.urlretrieve = MockUrlRetrieve('anotherpath', 'image/jpeg') album = {'asin': 'xxxx'} artpath = art.art_for_album(album, self.dpath) self.assertEqual(artpath, 'anotherpath')
def test_main_interface_returns_none_for_missing_asin_and_path(self): album = {'asin': None} artpath = art.art_for_album(album, None) self.assertEqual(artpath, None)
def test_main_interface_gives_precedence_to_fs_art(self): _common.touch(os.path.join(self.dpath, 'a.jpg')) art.urllib.urlretrieve = MockUrlRetrieve('anotherpath', 'image/jpeg') album = {'asin': 'xxxx'} artpath = art.art_for_album(album, self.dpath) self.assertEqual(artpath, os.path.join(self.dpath, 'a.jpg'))
def test_main_interface_returns_amazon_art(self): art.urllib.urlretrieve = MockUrlRetrieve('anotherpath', 'image/jpeg') album = AlbumInfo(None, None, None, None, None, asin='xxxx') artpath = art.art_for_album(album, None) self.assertEqual(artpath, 'anotherpath')
def test_main_interface_returns_amazon_art(self): art.urllib.urlretrieve = MockUrlRetrieve('anotherpath', 'image/jpeg') album = {'asin': 'xxxx'} artpath = art.art_for_album(album, None) self.assertEqual(artpath, 'anotherpath')
def test_main_interface_tries_amazon_before_aao(self): self.urlopen_called = False art.urllib.urlretrieve = MockUrlRetrieve('anotherpath', 'image/jpeg') album = AlbumInfo(None, None, None, None, None, asin='xxxx') art.art_for_album(album, self.dpath) self.assertFalse(self.urlopen_called)
def test_main_interface_falls_back_to_aao(self): self.urlopen_called = False art.urllib.urlretrieve = MockUrlRetrieve('anotherpath', 'text/html') album = AlbumInfo(None, None, None, None, None, asin='xxxx') art.art_for_album(album, self.dpath) self.assertTrue(self.urlopen_called)
def test_main_interface_returns_none_for_missing_asin_and_path(self): album = AlbumInfo(None, None, None, None, None, asin=None) artpath = art.art_for_album(album, None) self.assertEqual(artpath, None)
def test_main_interface_gives_precedence_to_fs_art(self): _common.touch(os.path.join(self.dpath, 'a.jpg')) art.urllib.urlretrieve = MockUrlRetrieve('anotherpath', 'image/jpeg') album = AlbumInfo(None, None, None, None, None, asin='xxxx') artpath = art.art_for_album(album, self.dpath) self.assertEqual(artpath, os.path.join(self.dpath, 'a.jpg'))
def test_main_interface_returns_none_for_missing_asin(self): album = {'asin': None} artpath = art.art_for_album(album) self.assertEqual(artpath, None)
def test_main_interface_returns_amazon_art(self): art.urllib.urlretrieve = MockUrlRetrieve('anotherpath', 'image/jpeg') album = {'asin': 'xxxx'} artpath = art.art_for_album(album) self.assertEqual(artpath, 'anotherpath')