Skip to content

Commit dc2d778

Browse files
committed
Clarify tests
1 parent cc5c589 commit dc2d778

2 files changed

Lines changed: 21 additions & 30 deletions

File tree

test/test_importer.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -304,15 +304,15 @@ def test_import_single_files(self):
304304
assert len(self.lib.albums()) == 2
305305

306306
def test_set_fields(self):
307-
genre = "\U0001f3b7 Jazz"
307+
genres = ["\U0001f3b7 Jazz", "Rock"]
308308
collection = "To Listen"
309309
disc = 0
310310

311311
config["import"]["set_fields"] = {
312+
"genres": "; ".join(genres),
312313
"collection": collection,
313-
"genres": genre,
314-
"title": "$title - formatted",
315314
"disc": disc,
315+
"title": "$title - formatted",
316316
}
317317

318318
# As-is item import.
@@ -322,7 +322,7 @@ def test_set_fields(self):
322322

323323
for item in self.lib.items():
324324
item.load() # TODO: Not sure this is necessary.
325-
assert item.genres == [genre]
325+
assert item.genres == genres
326326
assert item.collection == collection
327327
assert item.title == "Tag Track 1 - formatted"
328328
assert item.disc == disc
@@ -337,7 +337,7 @@ def test_set_fields(self):
337337

338338
for item in self.lib.items():
339339
item.load()
340-
assert item.genres == [genre]
340+
assert item.genres == genres
341341
assert item.collection == collection
342342
assert item.title == "Applied Track 1 - formatted"
343343
assert item.disc == disc
@@ -464,17 +464,17 @@ def test_asis_no_data_source(self):
464464
self.lib.items().get().data_source
465465

466466
def test_set_fields(self):
467-
genre = "\U0001f3b7 Jazz"
467+
genres = ["\U0001f3b7 Jazz", "Rock"]
468468
collection = "To Listen"
469-
comments = "managed by beets"
470469
disc = 0
470+
comments = "managed by beets"
471471

472472
config["import"]["set_fields"] = {
473-
"genres": genre,
473+
"genres": "; ".join(genres),
474474
"collection": collection,
475+
"disc": disc,
475476
"comments": comments,
476477
"album": "$album - formatted",
477-
"disc": disc,
478478
}
479479

480480
# As-is album import.
@@ -483,10 +483,10 @@ def test_set_fields(self):
483483
self.importer.run()
484484

485485
for album in self.lib.albums():
486-
assert album.genres == [genre]
486+
assert album.genres == genres
487487
assert album.comments == comments
488488
for item in album.items():
489-
assert item.get("genres", with_album=False) == [genre]
489+
assert item.get("genres", with_album=False) == genres
490490
assert item.get("collection", with_album=False) == collection
491491
assert item.get("comments", with_album=False) == comments
492492
assert (
@@ -504,10 +504,10 @@ def test_set_fields(self):
504504
self.importer.run()
505505

506506
for album in self.lib.albums():
507-
assert album.genres == [genre]
507+
assert album.genres == genres
508508
assert album.comments == comments
509509
for item in album.items():
510-
assert item.get("genres", with_album=False) == [genre]
510+
assert item.get("genres", with_album=False) == genres
511511
assert item.get("collection", with_album=False) == collection
512512
assert item.get("comments", with_album=False) == comments
513513
assert (

test/test_library.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -56,27 +56,18 @@ def test_load_clears_dirty_flags(self):
5656

5757
class StoreTest(ItemInDBTestCase):
5858
def test_store_changes_database_value(self):
59-
self.i.year = 1987
59+
new_year = 1987
60+
self.i.year = new_year
6061
self.i.store()
61-
new_year = (
62-
self.lib._connection()
63-
.execute("select year from items where title = ?", (self.i.title,))
64-
.fetchone()["year"]
65-
)
66-
assert new_year == 1987
62+
63+
assert self.lib.get_item(self.i.id).year == new_year
6764

6865
def test_store_only_writes_dirty_fields(self):
69-
original_genres = self.i.genres
70-
self.i._values_fixed["genres"] = ["beatboxing"] # change w/o dirtying
66+
new_year = 1987
67+
self.i._values_fixed["year"] = new_year # change w/o dirtying
7168
self.i.store()
72-
new_genre = (
73-
self.lib._connection()
74-
.execute(
75-
"select genres from items where title = ?", (self.i.title,)
76-
)
77-
.fetchone()["genres"]
78-
)
79-
assert [new_genre] == original_genres
69+
70+
assert self.lib.get_item(self.i.id).year != new_year
8071

8172
def test_store_clears_dirty_flags(self):
8273
self.i.composer = "tvp"

0 commit comments

Comments
 (0)