Esempio n. 1
0
 def test_main_interface_gives_precedence_to_fs_art(self):
     _common.touch(os.path.join(self.dpath, 'art.jpg'))
     self.mock_response(self.AMAZON_URL)
     album = _common.Bag(asin=self.ASIN)
     artpath = self.plugin.art_for_album(album, [self.dpath])
     self.assertEqual(artpath, os.path.join(self.dpath, 'art.jpg'))
Esempio n. 2
0
 def test_main_interface_falls_back_to_amazon(self):
     self.mock_response(self.AMAZON_URL)
     album = _common.Bag(asin=self.ASIN)
     artpath = self.plugin.art_for_album(album, [self.dpath])
     self.assertNotEqual(artpath, None)
     self.assertFalse(artpath.startswith(self.dpath))
Esempio n. 3
0
 def test_google_art_returns_no_result_when_error_received(self):
     album = _common.Bag(albumartist="some artist", album="some album")
     json = b'{"error": {"errors": [{"reason": "some reason"}]}}'
     self.mock_response(fetchart.GoogleImages.URL, json)
     result_url = self.source.get(album)
     self.assertEqual(list(result_url), [])
Esempio n. 4
0
 def test_main_interface_returns_none_for_missing_asin_and_path(self):
     album = _common.Bag()
     artpath = self.plugin.art_for_album(album, None)
     self.assertEqual(artpath, None)
Esempio n. 5
0
 def test_google_art_dont_finds_image(self):
     album = _common.Bag(albumartist="some artist", album="some album")
     json = """bla blup"""
     self.mock_response(self._google_url, json)
     result_url = self.source.get(album)
     self.assertEqual(list(result_url), [])
Esempio n. 6
0
 def test_main_interface_returns_none_for_missing_asin_and_path(self):
     album = _common.Bag()
     candidate = self.plugin.art_for_album(album, None)
     self.assertIsNone(candidate)
Esempio n. 7
0
 def test_google_art_returns_no_result_with_malformed_response(self):
     album = _common.Bag(albumartist="some artist", album="some album")
     json = """bla blup"""
     self.mock_response(fetchart.GoogleImages.URL, json)
     with self.assertRaises(StopIteration):
         next(self.source.get(album, self.extra))
Esempio n. 8
0
 def test_local_only_does_not_access_network(self):
     album = _common.Bag(mb_albumid=self.MBID, asin=self.ASIN)
     artpath = self.plugin.art_for_album(album, [self.dpath],
                                         local_only=True)
     self.assertEqual(artpath, None)
     self.assertEqual(len(responses.calls), 0)
Esempio n. 9
0
 def test_google_art_finds_image(self):
     album = _common.Bag(albumartist="some artist", album="some album")
     json = '{"items": [{"link": "url_to_the_image"}]}'
     self.mock_response(fetchart.GoogleImages.URL, json)
     candidate = next(self.source.get(album, self.extra))
     self.assertEqual(candidate.url, 'url_to_the_image')
Esempio n. 10
0
 def test_google_art_returns_no_result_when_error_received(self):
     album = _common.Bag(albumartist="some artist", album="some album")
     json = '{"error": {"errors": [{"reason": "some reason"}]}}'
     self.mock_response(fetchart.GoogleImages.URL, json)
     with self.assertRaises(StopIteration):
         next(self.source.get(album, self.extra))
Esempio n. 11
0
 def test_aao_scraper_returns_no_result_when_no_image_present(self):
     self.mock_response(self.AAO_URL, 'blah blah')
     album = _common.Bag(asin=self.ASIN)
     with self.assertRaises(StopIteration):
         next(self.source.get(album, self.extra))
Esempio n. 12
0
 def setUp(self):
     super(ITunesStoreTest, self).setUp()
     self.source = fetchart.ITunesStore(logger, self.plugin.config)
     self.settings = Settings()
     self.album = _common.Bag(albumartist="some artist", album="some album")
Esempio n. 13
0
 def test_google_art_returns_no_result_with_malformed_response(self):
     album = _common.Bag(albumartist="some artist", album="some album")
     json = b"""bla blup"""
     self.mock_response(fetchart.GoogleImages.URL, json)
     result_url = self.source.get(album)
     self.assertEqual(list(result_url), [])
Esempio n. 14
0
 def test_main_interface_tries_amazon_before_aao(self):
     self.mock_response(self.AMAZON_URL)
     album = _common.Bag(asin=self.ASIN)
     self.plugin.art_for_album(album, [self.dpath])
     self.assertEqual(len(responses.calls), 1)
     self.assertEqual(responses.calls[0].request.url, self.AMAZON_URL)
Esempio n. 15
0
 def test_fanarttv_finds_image(self):
     album = _common.Bag(mb_releasegroupid=u'thereleasegroupid')
     self.mock_response(fetchart.FanartTV.API_ALBUMS + u'thereleasegroupid',
                        self.RESPONSE_MULTIPLE)
     candidate = next(self.source.get(album, self.extra))
     self.assertEqual(candidate.url, 'http://example.com/1.jpg')
Esempio n. 16
0
 def test_main_interface_falls_back_to_aao(self):
     self.mock_response(self.AMAZON_URL, content_type='text/html')
     album = _common.Bag(asin=self.ASIN)
     self.plugin.art_for_album(album, [self.dpath])
     self.assertEqual(responses.calls[-1].request.url, self.AAO_URL)
Esempio n. 17
0
 def test_fanarttv_returns_no_result_when_error_received(self):
     album = _common.Bag(mb_releasegroupid=u'thereleasegroupid')
     self.mock_response(fetchart.FanartTV.API_ALBUMS + u'thereleasegroupid',
                        self.RESPONSE_ERROR)
     with self.assertRaises(StopIteration):
         next(self.source.get(album, self.extra))
Esempio n. 18
0
 def test_aao_scraper_returns_no_result_when_no_image_present(self):
     self.mock_response(self.AAO_URL, 'blah blah')
     album = _common.Bag(asin=self.ASIN)
     res = self.source.get(album)
     self.assertEqual(list(res), [])
Esempio n. 19
0
 def test_fanarttv_returns_no_result_with_malformed_response(self):
     album = _common.Bag(mb_releasegroupid=u'thereleasegroupid')
     self.mock_response(fetchart.FanartTV.API_ALBUMS + u'thereleasegroupid',
                        self.RESPONSE_MALFORMED)
     with self.assertRaises(StopIteration):
         next(self.source.get(album, self.extra))
Esempio n. 20
0
 def test_main_interface_returns_amazon_art(self):
     self.mock_response(self.AMAZON_URL)
     album = _common.Bag(asin=self.ASIN)
     candidate = self.plugin.art_for_album(album, None)
     self.assertIsNotNone(candidate)
Esempio n. 21
0
 def test_main_interface_returns_amazon_art(self):
     self.mock_response(self.AMAZON_URL)
     album = _common.Bag(asin=self.ASIN)
     artpath = self.plugin.art_for_album(album, None)
     self.assertNotEqual(artpath, None)
Esempio n. 22
0
 def test_main_interface_falls_back_to_amazon(self):
     self.mock_response(self.AMAZON_URL)
     album = _common.Bag(asin=self.ASIN)
     candidate = self.plugin.art_for_album(album, [self.dpath])
     self.assertIsNotNone(candidate)
     self.assertFalse(candidate.path.startswith(self.dpath))
Esempio n. 23
0
 def test_google_art_finds_image(self):
     album = _common.Bag(albumartist="some artist", album="some album")
     json = b'{"items": [{"link": "url_to_the_image"}]}'
     self.mock_response(fetchart.GoogleImages.URL, json)
     result_url = self.source.get(album)
     self.assertEqual(list(result_url)[0], 'url_to_the_image')