From ac14b7f2fbde27c90536d6d351810ad31661a30c Mon Sep 17 00:00:00 2001 From: Fabrice Laporte Date: Sat, 27 Apr 2013 12:27:04 +0200 Subject: [PATCH] Fix unit tests by constructing a FetchArtPlugin in the fixture and using 'art.jpg' as default image filename so that 'cautious' option does not interfere with the tests. --- test/test_art.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/test/test_art.py b/test/test_art.py index 8ab01d2cd..a20385655 100644 --- a/test/test_art.py +++ b/test/test_art.py @@ -54,12 +54,13 @@ class FSArtTest(_common.TestCase): def setUp(self): super(FSArtTest, self).setUp() self.dpath = os.path.join(self.temp_dir, 'arttest') + fetchart.FetchArtPlugin() os.mkdir(self.dpath) def test_finds_jpg_in_directory(self): - _common.touch(os.path.join(self.dpath, 'a.jpg')) + _common.touch(os.path.join(self.dpath, 'art.jpg')) fn = fetchart.art_in_path(self.dpath) - self.assertEqual(fn, os.path.join(self.dpath, 'a.jpg')) + self.assertEqual(fn, os.path.join(self.dpath, 'art.jpg')) def test_appropriately_named_file_takes_precedence(self): _common.touch(os.path.join(self.dpath, 'a.jpg')) @@ -107,11 +108,11 @@ class CombinedTest(_common.TestCase): self.assertEqual(artpath, None) def test_main_interface_gives_precedence_to_fs_art(self): - _common.touch(os.path.join(self.dpath, 'a.jpg')) + _common.touch(os.path.join(self.dpath, 'art.jpg')) fetchart.urllib.urlretrieve = MockUrlRetrieve('image/jpeg') album = _common.Bag(asin='xxxx') artpath = fetchart.art_for_album(album, [self.dpath]) - self.assertEqual(artpath, os.path.join(self.dpath, 'a.jpg')) + self.assertEqual(artpath, os.path.join(self.dpath, 'art.jpg')) def test_main_interface_falls_back_to_amazon(self): fetchart.urllib.urlretrieve = MockUrlRetrieve('image/jpeg') @@ -150,12 +151,12 @@ class CombinedTest(_common.TestCase): self.assertFalse(mock_retrieve.fetched) def test_local_only_gets_fs_image(self): - _common.touch(os.path.join(self.dpath, 'a.jpg')) + _common.touch(os.path.join(self.dpath, 'art.jpg')) mock_retrieve = MockUrlRetrieve('image/jpeg') fetchart.urllib.urlretrieve = mock_retrieve album = _common.Bag(mb_albumid='releaseid', asin='xxxx') - artpath = fetchart.art_for_album(album, [self.dpath], local_only=True) - self.assertEqual(artpath, os.path.join(self.dpath, 'a.jpg')) + artpath = fetchart.art_for_album(album, [self.dpath], None, local_only=True) + self.assertEqual(artpath, os.path.join(self.dpath, 'art.jpg')) self.assertFalse(self.urlopen_called) self.assertFalse(mock_retrieve.fetched)