mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 16:42:42 +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,7 +576,6 @@ class ImportTask(BaseImportTask):
|
||||||
"""Sets the fields given at CLI or configuration to the specified
|
"""Sets the fields given at CLI or configuration to the specified
|
||||||
values, for both the album and all its items.
|
values, for both the album and all its items.
|
||||||
"""
|
"""
|
||||||
with lib.transaction():
|
|
||||||
items = self.imported_items()
|
items = self.imported_items()
|
||||||
for field, view in config['import']['set_fields'].items():
|
for field, view in config['import']['set_fields'].items():
|
||||||
value = view.get()
|
value = view.get()
|
||||||
|
|
@ -587,6 +586,7 @@ class ImportTask(BaseImportTask):
|
||||||
self.album[field] = value
|
self.album[field] = value
|
||||||
for item in items:
|
for item in items:
|
||||||
item[field] = value
|
item[field] = value
|
||||||
|
with lib.transaction():
|
||||||
for item in items:
|
for item in items:
|
||||||
item.store()
|
item.store()
|
||||||
self.album.store()
|
self.album.store()
|
||||||
|
|
@ -956,7 +956,6 @@ class SingletonImportTask(ImportTask):
|
||||||
"""Sets the fields given at CLI or configuration to the specified
|
"""Sets the fields given at CLI or configuration to the specified
|
||||||
values, for the singleton item.
|
values, for the singleton item.
|
||||||
"""
|
"""
|
||||||
with lib.transaction():
|
|
||||||
for field, view in config['import']['set_fields'].items():
|
for field, view in config['import']['set_fields'].items():
|
||||||
value = view.get()
|
value = view.get()
|
||||||
log.debug(u'Set field {1}={2} for {0}',
|
log.debug(u'Set field {1}={2} for {0}',
|
||||||
|
|
|
||||||
|
|
@ -743,7 +743,6 @@ class ImportTest(_common.TestCase, ImportHelper):
|
||||||
comments = u"managed by beets"
|
comments = u"managed by beets"
|
||||||
|
|
||||||
config['import']['set_fields'] = {
|
config['import']['set_fields'] = {
|
||||||
u'collection': collection,
|
|
||||||
u'genre': genre,
|
u'genre': genre,
|
||||||
u'comments': comments
|
u'comments': comments
|
||||||
}
|
}
|
||||||
|
|
@ -756,11 +755,10 @@ class ImportTest(_common.TestCase, ImportHelper):
|
||||||
for album in self.lib.albums():
|
for album in self.lib.albums():
|
||||||
album.load() # TODO: Not sure this is necessary.
|
album.load() # TODO: Not sure this is necessary.
|
||||||
self.assertEqual(album.genre, genre)
|
self.assertEqual(album.genre, genre)
|
||||||
self.assertEqual(album.collection, collection)
|
self.assertEqual(album.comments, comments)
|
||||||
for item in album.items():
|
for item in album.items():
|
||||||
self.assertEqual(item.genre, genre)
|
self.assertEqual(item.get("genre", with_album=False), genre)
|
||||||
self.assertEqual(item.collection, collection)
|
self.assertEqual(item.get("comments", with_album=False), comments)
|
||||||
self.assertEqual(item.comments, comments)
|
|
||||||
# Remove album from library to test again with APPLY choice.
|
# Remove album from library to test again with APPLY choice.
|
||||||
album.remove()
|
album.remove()
|
||||||
|
|
||||||
|
|
@ -773,11 +771,10 @@ class ImportTest(_common.TestCase, ImportHelper):
|
||||||
for album in self.lib.albums():
|
for album in self.lib.albums():
|
||||||
album.load()
|
album.load()
|
||||||
self.assertEqual(album.genre, genre)
|
self.assertEqual(album.genre, genre)
|
||||||
self.assertEqual(album.collection, collection)
|
self.assertEqual(album.comments, comments)
|
||||||
for item in album.items():
|
for item in album.items():
|
||||||
self.assertEqual(item.genre, genre)
|
self.assertEqual(item.get("genre", with_album=False), genre)
|
||||||
self.assertEqual(item.collection, collection)
|
self.assertEqual(item.get("comments", with_album=False), comments)
|
||||||
self.assertEqual(item.comments, comments)
|
|
||||||
|
|
||||||
|
|
||||||
class ImportTracksTest(_common.TestCase, ImportHelper):
|
class ImportTracksTest(_common.TestCase, ImportHelper):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue