From 5b5e15d48bc57e5a52f2ffde272e058d1e5ceae9 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 4 Oct 2022 11:40:01 -0700 Subject: [PATCH 1/2] Just adds a couple tests --- bookwyrm/tests/templatetags/test_utilities.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/bookwyrm/tests/templatetags/test_utilities.py b/bookwyrm/tests/templatetags/test_utilities.py index 7738a51d9..ccb3259fc 100644 --- a/bookwyrm/tests/templatetags/test_utilities.py +++ b/bookwyrm/tests/templatetags/test_utilities.py @@ -14,6 +14,7 @@ from bookwyrm.templatetags import utilities class UtilitiesTags(TestCase): """lotta different things here""" + # pylint: disable=invalid-name def setUp(self): """create some filler objects""" with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( @@ -34,6 +35,7 @@ class UtilitiesTags(TestCase): remote_id="http://example.com/rat", local=False, ) + self.author = models.Author.objects.create(name="Jessica", isni="4") self.book = models.Edition.objects.create(title="Test Book") def test_get_uuid(self, *_): @@ -77,3 +79,16 @@ class UtilitiesTags(TestCase): value = ValueMock("home/one/two/three/four") self.assertEqual(utilities.truncatepath(value, 2), "home/…ur") self.assertEqual(utilities.truncatepath(value, "a"), "four") + + def test_get_book_cover_thumbnail(self, *_): + """get book cover thumbnail""" + result = utilities.get_book_cover_thumbnail(self.book) + self.assertEqual(result, "images/no_cover.jpg") + + def test_get_isni_bio(self, *_): + """get ISNI bio""" + DataMock = namedtuple("Data", ("bio", "isni")) + data = [DataMock(r"One\Dtwo", "4"), DataMock("Not used", "4")] + + result = utilities.get_isni_bio(data, self.author) + self.assertEqual(result, "Author of One\\Dtwo") From 74b89b2d4a1905daef0eb4b4804ba9f8a3ee9b3d Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 4 Oct 2022 12:09:05 -0700 Subject: [PATCH 2/2] That test didn't work --- bookwyrm/tests/templatetags/test_utilities.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/bookwyrm/tests/templatetags/test_utilities.py b/bookwyrm/tests/templatetags/test_utilities.py index ccb3259fc..c9e1c744f 100644 --- a/bookwyrm/tests/templatetags/test_utilities.py +++ b/bookwyrm/tests/templatetags/test_utilities.py @@ -80,11 +80,6 @@ class UtilitiesTags(TestCase): self.assertEqual(utilities.truncatepath(value, 2), "home/…ur") self.assertEqual(utilities.truncatepath(value, "a"), "four") - def test_get_book_cover_thumbnail(self, *_): - """get book cover thumbnail""" - result = utilities.get_book_cover_thumbnail(self.book) - self.assertEqual(result, "images/no_cover.jpg") - def test_get_isni_bio(self, *_): """get ISNI bio""" DataMock = namedtuple("Data", ("bio", "isni"))