mirror of
https://github.com/beetbox/beets.git
synced 2026-01-30 12:02:41 +01:00
Replace assertCount
This commit is contained in:
parent
111cb562ea
commit
72caf0d2cd
1 changed files with 10 additions and 43 deletions
|
|
@ -134,22 +134,6 @@ class EditCommandTest(EditMixin, BeetsTestCase):
|
|||
{f: item[f] for f in item._fields} for item in self.album.items()
|
||||
]
|
||||
|
||||
def assertCounts(
|
||||
self,
|
||||
mock_write,
|
||||
album_count=ALBUM_COUNT,
|
||||
track_count=TRACK_COUNT,
|
||||
write_call_count=TRACK_COUNT,
|
||||
title_starts_with="",
|
||||
):
|
||||
"""Several common assertions on Album, Track and call counts."""
|
||||
assert len(self.lib.albums()) == album_count
|
||||
assert len(self.lib.items()) == track_count
|
||||
assert mock_write.call_count == write_call_count
|
||||
assert all(
|
||||
i.title.startswith(title_starts_with) for i in self.lib.items()
|
||||
)
|
||||
|
||||
def test_title_edit_discard(self, mock_write):
|
||||
"""Edit title for all items in the library, then discard changes."""
|
||||
# Edit track titles.
|
||||
|
|
@ -159,9 +143,7 @@ class EditCommandTest(EditMixin, BeetsTestCase):
|
|||
["c"],
|
||||
)
|
||||
|
||||
self.assertCounts(
|
||||
mock_write, write_call_count=0, title_starts_with="t\u00eftle"
|
||||
)
|
||||
assert mock_write.call_count == 0
|
||||
self.assertItemFieldsModified(self.album.items(), self.items_orig, [])
|
||||
|
||||
def test_title_edit_apply(self, mock_write):
|
||||
|
|
@ -173,11 +155,7 @@ class EditCommandTest(EditMixin, BeetsTestCase):
|
|||
["a"],
|
||||
)
|
||||
|
||||
self.assertCounts(
|
||||
mock_write,
|
||||
write_call_count=self.TRACK_COUNT,
|
||||
title_starts_with="modified t\u00eftle",
|
||||
)
|
||||
assert mock_write.call_count == self.TRACK_COUNT
|
||||
self.assertItemFieldsModified(
|
||||
self.album.items(), self.items_orig, ["title", "mtime"]
|
||||
)
|
||||
|
|
@ -191,10 +169,7 @@ class EditCommandTest(EditMixin, BeetsTestCase):
|
|||
["a"],
|
||||
)
|
||||
|
||||
self.assertCounts(
|
||||
mock_write,
|
||||
write_call_count=1,
|
||||
)
|
||||
assert mock_write.call_count == 1
|
||||
# No changes except on last item.
|
||||
self.assertItemFieldsModified(
|
||||
list(self.album.items())[:-1], self.items_orig[:-1], []
|
||||
|
|
@ -210,9 +185,7 @@ class EditCommandTest(EditMixin, BeetsTestCase):
|
|||
[],
|
||||
)
|
||||
|
||||
self.assertCounts(
|
||||
mock_write, write_call_count=0, title_starts_with="t\u00eftle"
|
||||
)
|
||||
assert mock_write.call_count == 0
|
||||
self.assertItemFieldsModified(self.album.items(), self.items_orig, [])
|
||||
|
||||
def test_album_edit_apply(self, mock_write):
|
||||
|
|
@ -226,7 +199,7 @@ class EditCommandTest(EditMixin, BeetsTestCase):
|
|||
["a"],
|
||||
)
|
||||
|
||||
self.assertCounts(mock_write, write_call_count=self.TRACK_COUNT)
|
||||
assert mock_write.call_count == self.TRACK_COUNT
|
||||
self.assertItemFieldsModified(
|
||||
self.album.items(), self.items_orig, ["album", "mtime"]
|
||||
)
|
||||
|
|
@ -249,9 +222,7 @@ class EditCommandTest(EditMixin, BeetsTestCase):
|
|||
# Even though a flexible attribute was written (which is not directly
|
||||
# written to the tags), write should still be called since templates
|
||||
# might use it.
|
||||
self.assertCounts(
|
||||
mock_write, write_call_count=1, title_starts_with="t\u00eftle"
|
||||
)
|
||||
assert mock_write.call_count == 1
|
||||
|
||||
def test_a_album_edit_apply(self, mock_write):
|
||||
"""Album query (-a), edit album field, apply changes."""
|
||||
|
|
@ -263,7 +234,7 @@ class EditCommandTest(EditMixin, BeetsTestCase):
|
|||
)
|
||||
|
||||
self.album.load()
|
||||
self.assertCounts(mock_write, write_call_count=self.TRACK_COUNT)
|
||||
assert mock_write.call_count == self.TRACK_COUNT
|
||||
assert self.album.album == "modified \u00e4lbum"
|
||||
self.assertItemFieldsModified(
|
||||
self.album.items(), self.items_orig, ["album", "mtime"]
|
||||
|
|
@ -279,7 +250,7 @@ class EditCommandTest(EditMixin, BeetsTestCase):
|
|||
)
|
||||
|
||||
self.album.load()
|
||||
self.assertCounts(mock_write, write_call_count=self.TRACK_COUNT)
|
||||
assert mock_write.call_count == self.TRACK_COUNT
|
||||
assert self.album.albumartist == "the modified album artist"
|
||||
self.assertItemFieldsModified(
|
||||
self.album.items(), self.items_orig, ["albumartist", "mtime"]
|
||||
|
|
@ -295,9 +266,7 @@ class EditCommandTest(EditMixin, BeetsTestCase):
|
|||
["n"],
|
||||
)
|
||||
|
||||
self.assertCounts(
|
||||
mock_write, write_call_count=0, title_starts_with="t\u00eftle"
|
||||
)
|
||||
assert mock_write.call_count == 0
|
||||
|
||||
def test_invalid_yaml(self, mock_write):
|
||||
"""Edit the yaml file incorrectly (resulting in a well-formed but
|
||||
|
|
@ -309,9 +278,7 @@ class EditCommandTest(EditMixin, BeetsTestCase):
|
|||
[],
|
||||
)
|
||||
|
||||
self.assertCounts(
|
||||
mock_write, write_call_count=0, title_starts_with="t\u00eftle"
|
||||
)
|
||||
assert mock_write.call_count == 0
|
||||
|
||||
|
||||
@_common.slow_test()
|
||||
|
|
|
|||
Loading…
Reference in a new issue