mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 08:39:17 +01:00
fix: transactions and stricter tests
This commit is contained in:
parent
a25a2a6cbb
commit
e98f78e29b
2 changed files with 24 additions and 28 deletions
|
|
@ -576,17 +576,17 @@ class ImportTask(BaseImportTask):
|
|||
"""Sets the fields given at CLI or configuration to the specified
|
||||
values, for both the album and all its items.
|
||||
"""
|
||||
items = self.imported_items()
|
||||
for field, view in config['import']['set_fields'].items():
|
||||
value = view.get()
|
||||
log.debug(u'Set field {1}={2} for {0}',
|
||||
displayable_path(self.paths),
|
||||
field,
|
||||
value)
|
||||
self.album[field] = value
|
||||
for item in items:
|
||||
item[field] = value
|
||||
with lib.transaction():
|
||||
items = self.imported_items()
|
||||
for field, view in config['import']['set_fields'].items():
|
||||
value = view.get()
|
||||
log.debug(u'Set field {1}={2} for {0}',
|
||||
displayable_path(self.paths),
|
||||
field,
|
||||
value)
|
||||
self.album[field] = value
|
||||
for item in items:
|
||||
item[field] = value
|
||||
for item in items:
|
||||
item.store()
|
||||
self.album.store()
|
||||
|
|
@ -956,15 +956,14 @@ class SingletonImportTask(ImportTask):
|
|||
"""Sets the fields given at CLI or configuration to the specified
|
||||
values, for the singleton item.
|
||||
"""
|
||||
with lib.transaction():
|
||||
for field, view in config['import']['set_fields'].items():
|
||||
value = view.get()
|
||||
log.debug(u'Set field {1}={2} for {0}',
|
||||
displayable_path(self.paths),
|
||||
field,
|
||||
value)
|
||||
self.item[field] = value
|
||||
self.item.store()
|
||||
for field, view in config['import']['set_fields'].items():
|
||||
value = view.get()
|
||||
log.debug(u'Set field {1}={2} for {0}',
|
||||
displayable_path(self.paths),
|
||||
field,
|
||||
value)
|
||||
self.item[field] = value
|
||||
self.item.store()
|
||||
|
||||
|
||||
# FIXME The inheritance relationships are inverted. This is why there
|
||||
|
|
|
|||
|
|
@ -743,7 +743,6 @@ class ImportTest(_common.TestCase, ImportHelper):
|
|||
comments = u"managed by beets"
|
||||
|
||||
config['import']['set_fields'] = {
|
||||
u'collection': collection,
|
||||
u'genre': genre,
|
||||
u'comments': comments
|
||||
}
|
||||
|
|
@ -756,11 +755,10 @@ class ImportTest(_common.TestCase, ImportHelper):
|
|||
for album in self.lib.albums():
|
||||
album.load() # TODO: Not sure this is necessary.
|
||||
self.assertEqual(album.genre, genre)
|
||||
self.assertEqual(album.collection, collection)
|
||||
self.assertEqual(album.comments, comments)
|
||||
for item in album.items():
|
||||
self.assertEqual(item.genre, genre)
|
||||
self.assertEqual(item.collection, collection)
|
||||
self.assertEqual(item.comments, comments)
|
||||
self.assertEqual(item.get("genre", with_album=False), genre)
|
||||
self.assertEqual(item.get("comments", with_album=False), comments)
|
||||
# Remove album from library to test again with APPLY choice.
|
||||
album.remove()
|
||||
|
||||
|
|
@ -773,11 +771,10 @@ class ImportTest(_common.TestCase, ImportHelper):
|
|||
for album in self.lib.albums():
|
||||
album.load()
|
||||
self.assertEqual(album.genre, genre)
|
||||
self.assertEqual(album.collection, collection)
|
||||
self.assertEqual(album.comments, comments)
|
||||
for item in album.items():
|
||||
self.assertEqual(item.genre, genre)
|
||||
self.assertEqual(item.collection, collection)
|
||||
self.assertEqual(item.comments, comments)
|
||||
self.assertEqual(item.get("genre", with_album=False), genre)
|
||||
self.assertEqual(item.get("comments", with_album=False), comments)
|
||||
|
||||
|
||||
class ImportTracksTest(_common.TestCase, ImportHelper):
|
||||
|
|
|
|||
Loading…
Reference in a new issue