test helper: add support for multi-disc album fixtures

This commit is contained in:
wisp3rwind 2021-03-20 11:21:59 +01:00
parent c0af86c04a
commit ad4c68112f

View file

@ -373,21 +373,23 @@ class TestHelper:
items.append(item)
return items
def add_album_fixture(self, track_count=1, ext='mp3'):
def add_album_fixture(self, track_count=1, ext='mp3', disc_count=1):
"""Add an album with files to the database.
"""
items = []
path = os.path.join(_common.RSRC, util.bytestring_path('full.' + ext))
for i in range(track_count):
item = Item.from_path(path)
item.album = '\u00e4lbum' # Check unicode paths
item.title = f't\u00eftle {i}'
# mtime needs to be set last since other assignments reset it.
item.mtime = 12345
item.add(self.lib)
item.move(operation=MoveOperation.COPY)
item.store()
items.append(item)
for discnumber in range(1, disc_count + 1):
for i in range(track_count):
item = Item.from_path(path)
item.album = '\u00e4lbum' # Check unicode paths
item.title = f't\u00eftle {i}'
item.disc = discnumber
# mtime needs to be set last since other assignments reset it.
item.mtime = 12345
item.add(self.lib)
item.move(operation=MoveOperation.COPY)
item.store()
items.append(item)
return self.lib.add_album(items)
def create_mediafile_fixture(self, ext='mp3', images=[]):