diff --git a/test/helper.py b/test/helper.py index 16cfd11d3..aa9c92add 100644 --- a/test/helper.py +++ b/test/helper.py @@ -232,11 +232,11 @@ class TestHelper(object): items.append(item) return items - def add_album_fixture(self, track_count=1): + def add_album_fixture(self, track_count=1, ext='mp3'): """Add an album with files to the database. """ items = [] - path = os.path.join(_common.RSRC, 'full.mp3') + path = os.path.join(_common.RSRC, 'full.' + ext) for i in range(track_count): item = Item.from_path(str(path)) item.album = u'\u00e4lbum' # Check unicode paths diff --git a/test/test_convert.py b/test/test_convert.py index 4af539923..21de94696 100644 --- a/test/test_convert.py +++ b/test/test_convert.py @@ -13,9 +13,13 @@ # included in all copies or substantial portions of the Software. import os.path +import _common from _common import unittest from helper import TestHelper, control_stdin +from beets.mediafile import MediaFile + + class ImportConvertTest(unittest.TestCase, TestHelper): def setUp(self): @@ -63,7 +67,8 @@ class ConvertCliTest(unittest.TestCase, TestHelper): def setUp(self): self.setup_beets(disk=True) # Converter is threaded - self.item, = self.add_item_fixtures(ext='ogg') + self.album = self.add_album_fixture(ext='ogg') + self.item = self.album.items()[0] self.load_plugins('convert') self.convert_dest = os.path.join(self.temp_dir, 'convert_dest') @@ -90,6 +95,20 @@ class ConvertCliTest(unittest.TestCase, TestHelper): self.item.load() self.assertEqual(os.path.splitext(self.item.path)[1], '.mp3') + def test_embed_album_art(self): + self.config['convert']['embed'] = True + image_path = os.path.join(_common.RSRC, 'image-2x3.jpg') + self.album.artpath = image_path + self.album.store() + with open(os.path.join(image_path)) as f: + image_data = f.read() + + with control_stdin('y'): + self.run_command('convert', self.item.path) + converted = os.path.join(self.convert_dest, 'converted.mp3') + mediafile = MediaFile(converted) + self.assertEqual(mediafile.images[0].data, image_data) + def suite(): return unittest.TestLoader().loadTestsFromName(__name__)