Skip to content

Commit 2e307b5

Browse files
committed
lastgenre: Also mock try_write in test_pretend..
and add and original genre instead empty string (clarify intention of test / readability). Remove not really necessary assert items checks.
1 parent 9b1537f commit 2e307b5

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

test/plugins/test_lastgenre.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def test_pretend_option_skips_library_updates(self):
137137
albumartist="Pretend Artist",
138138
artist="Pretend Artist",
139139
title="Pretend Track",
140-
genre="",
140+
genre="Original Genre",
141141
)
142142
album = self.lib.add_album([item])
143143

@@ -151,20 +151,22 @@ def test_pretend_option_skips_library_updates(self):
151151
return_value=("Mock Genre", "mock stage"),
152152
) as mock_get_genre:
153153
with patch.object(self.plugin._log, "info") as log_info:
154-
command.func(self.lib, opts, args)
154+
# Mock try_write to verify it's never called in pretend mode
155+
with patch.object(item, "try_write") as mock_try_write:
156+
command.func(self.lib, opts, args)
155157

156158
mock_get_genre.assert_called_once()
157159

158160
assert any(
159161
call.args[1] == "Pretend: " for call in log_info.call_args_list
160162
)
161163

162-
stored_album = self.lib.get_album(album.id)
163-
assert stored_album.genre == ""
164+
# Verify that try_write was never called (file operations skipped)
165+
mock_try_write.assert_not_called()
164166

165-
items = list(stored_album.items())
166-
assert items
167-
assert items[0].genre == ""
167+
stored_album = self.lib.get_album(album.id)
168+
assert stored_album.genre == "Original Genre"
169+
assert stored_album.items()[0].genre == "Original Genre"
168170

169171
def test_no_duplicate(self):
170172
"""Remove duplicated genres."""

0 commit comments

Comments
 (0)