示例#1
0
 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')
示例#2
0
 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)
示例#3
0
 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'))
示例#4
0
 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')
示例#5
0
 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')
示例#6
0
 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)
示例#7
0
 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)
示例#8
0
 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)
示例#9
0
 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'))
示例#10
0
 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)
示例#11
0
 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)
示例#12
0
 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)
示例#13
0
 def test_main_interface_returns_none_for_missing_asin(self):
     album = {'asin': None}
     artpath = art.art_for_album(album)
     self.assertEqual(artpath, None)
示例#14
0
 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')