mirror of
https://github.com/beetbox/beets.git
synced 2026-01-29 19:43:20 +01:00
Test converter embeds album art
This commit is contained in:
parent
9c6491a65d
commit
f19fa1567e
2 changed files with 22 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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__)
|
||||
|
|
|
|||
Loading…
Reference in a new issue