fix #4840 and add to test case

This commit is contained in:
Adam Harder 2024-11-06 23:14:47 -05:00
parent fa10dcf11a
commit d6ac687de1
2 changed files with 11 additions and 2 deletions

View file

@ -605,7 +605,8 @@ class ImportTask(BaseImportTask):
"""
items = self.imported_items()
for field, view in config["import"]["set_fields"].items():
value = view.get()
value = str(view.get())
print("EEE ", value)
log.debug(
"Set field {1}={2} for {0}",
displayable_path(self.paths),
@ -1062,7 +1063,7 @@ class SingletonImportTask(ImportTask):
values, for the singleton item.
"""
for field, view in config["import"]["set_fields"].items():
value = view.get()
value = str(view.get())
log.debug(
"Set field {1}={2} for {0}",
displayable_path(self.paths),

View file

@ -395,11 +395,13 @@ class ImportSingletonTest(ImportTestCase):
def test_set_fields(self):
genre = "\U0001f3b7 Jazz"
collection = "To Listen"
disc = 0
config["import"]["set_fields"] = {
"collection": collection,
"genre": genre,
"title": "$title - formatted",
"disc": disc,
}
# As-is item import.
@ -412,6 +414,7 @@ class ImportSingletonTest(ImportTestCase):
assert item.genre == genre
assert item.collection == collection
assert item.title == "Tag Track 1 - formatted"
assert item.disc == disc
# Remove item from library to test again with APPLY choice.
item.remove()
@ -426,6 +429,7 @@ class ImportSingletonTest(ImportTestCase):
assert item.genre == genre
assert item.collection == collection
assert item.title == "Applied Track 1 - formatted"
assert item.disc == disc
class ImportTest(ImportTestCase):
@ -583,12 +587,14 @@ class ImportTest(ImportTestCase):
genre = "\U0001f3b7 Jazz"
collection = "To Listen"
comments = "managed by beets"
disc = 0
config["import"]["set_fields"] = {
"genre": genre,
"collection": collection,
"comments": comments,
"album": "$album - formatted",
"disc": disc,
}
# As-is album import.
@ -608,6 +614,7 @@ class ImportTest(ImportTestCase):
item.get("album", with_album=False)
== "Tag Album - formatted"
)
assert item.disc == disc
# Remove album from library to test again with APPLY choice.
album.remove()
@ -629,6 +636,7 @@ class ImportTest(ImportTestCase):
item.get("album", with_album=False)
== "Applied Album - formatted"
)
assert item.disc == disc
class ImportTracksTest(ImportTestCase):