From a9a6fd12429d41ec1b2f0ebeaa57ab080ab61793 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 4 Feb 2022 19:34:37 -0800 Subject: [PATCH] Adds test for author page bug --- bookwyrm/tests/views/test_author.py | 37 +++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/bookwyrm/tests/views/test_author.py b/bookwyrm/tests/views/test_author.py index ad5c069d3..71daef2a4 100644 --- a/bookwyrm/tests/views/test_author.py +++ b/bookwyrm/tests/views/test_author.py @@ -50,6 +50,43 @@ class AuthorViews(TestCase): models.SiteSettings.objects.create() def test_author_page(self): + """there are so many views, this just makes sure it LOADS""" + view = views.Author.as_view() + author = models.Author.objects.create(name="Jessica") + self.book.authors.add(author) + request = self.factory.get("") + request.user = self.local_user + with patch("bookwyrm.views.author.is_api_request") as is_api: + is_api.return_value = False + result = view(request, author.id) + self.assertIsInstance(result, TemplateResponse) + validate_html(result.render()) + self.assertEqual(result.status_code, 200) + + def test_author_page_edition_author(self): + """there are so many views, this just makes sure it LOADS""" + view = views.Author.as_view() + another_book = models.Edition.objects.create( + title="Example Edition", + remote_id="https://example.com/book/1", + parent_work=self.work, + isbn_13="9780300112511", + ) + author = models.Author.objects.create(name="Jessica") + self.book.authors.add(author) + request = self.factory.get("") + request.user = self.local_user + with patch("bookwyrm.views.author.is_api_request") as is_api: + is_api.return_value = False + result = view(request, author.id) + books = result.context_data["books"] + self.assertEqual(books.object_list.count(), 1) + + self.assertIsInstance(result, TemplateResponse) + validate_html(result.render()) + self.assertEqual(result.status_code, 200) + + def test_author_page_empty(self): """there are so many views, this just makes sure it LOADS""" view = views.Author.as_view() author = models.Author.objects.create(name="Jessica")