mirror of
https://github.com/beetbox/beets.git
synced 2026-01-17 05:34:23 +01:00
Add tests and make sure they pass
This commit is contained in:
parent
f17601e4cd
commit
406f3ce843
3 changed files with 27 additions and 1 deletions
|
|
@ -1016,7 +1016,8 @@ class Album(LibModel):
|
|||
# Move items.
|
||||
items = list(self.items())
|
||||
for item in items:
|
||||
item.move(copy, link, basedir=basedir, with_album=False)
|
||||
item.move(copy, link, basedir=basedir, with_album=False,
|
||||
fields_to_store=fields_to_store)
|
||||
|
||||
# Move art.
|
||||
self.move_art(copy, link)
|
||||
|
|
|
|||
|
|
@ -1086,6 +1086,11 @@ def update_items(lib, query, album, move, pretend, fields):
|
|||
reflect the item's embedded tags.
|
||||
"""
|
||||
with lib.transaction():
|
||||
if move and fields is not None and 'path' not in fields:
|
||||
# Special case: if an item needs to be moved, the path field has to
|
||||
# updated; otherwise the new path will not be reflected in the
|
||||
# database
|
||||
fields.append('path')
|
||||
items, _ = _do_query(lib, query, album)
|
||||
|
||||
# Walk through the items and pick up their changes.
|
||||
|
|
|
|||
|
|
@ -550,6 +550,26 @@ class UpdateTest(_common.TestCase):
|
|||
item = self.lib.items().get()
|
||||
self.assertTrue(b'differentTitle' not in item.path)
|
||||
|
||||
def test_selective_modified_metadata_moved(self):
|
||||
mf = MediaFile(self.i.path)
|
||||
mf.title = u'differentTitle'
|
||||
mf.genre = u'differentGenre'
|
||||
mf.save()
|
||||
self._update(move=True, fields=['title'])
|
||||
item = self.lib.items().get()
|
||||
self.assertTrue(b'differentTitle' in item.path)
|
||||
self.assertNotEqual(item.genre, u'differentGenre')
|
||||
|
||||
def test_selective_modified_metadata_not_moved(self):
|
||||
mf = MediaFile(self.i.path)
|
||||
mf.title = u'differentTitle'
|
||||
mf.genre = u'differentGenre'
|
||||
mf.save()
|
||||
self._update(move=False, fields=['title'])
|
||||
item = self.lib.items().get()
|
||||
self.assertTrue(b'differentTitle' not in item.path)
|
||||
self.assertNotEqual(item.genre, u'differentGenre')
|
||||
|
||||
def test_modified_album_metadata_moved(self):
|
||||
mf = MediaFile(self.i.path)
|
||||
mf.album = u'differentAlbum'
|
||||
|
|
|
|||
Loading…
Reference in a new issue