From dd3850a3ba3bf98009cbcbc614bef58cb3730931 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 27 Sep 2021 12:26:56 -0700 Subject: [PATCH] Updates books test --- bookwyrm/templatetags/bookwyrm_tags.py | 1 + bookwyrm/tests/views/test_book.py | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bookwyrm/templatetags/bookwyrm_tags.py b/bookwyrm/templatetags/bookwyrm_tags.py index 07e518ce..b66f68c7 100644 --- a/bookwyrm/templatetags/bookwyrm_tags.py +++ b/bookwyrm/templatetags/bookwyrm_tags.py @@ -70,6 +70,7 @@ def related_status(notification): @register.simple_tag(takes_context=True) def active_shelf(context, book): """check what shelf a user has a book on, if any""" + print(hasattr(book, "current_shelves")) if hasattr(book, "current_shelves"): return book.current_shelves[0] if len(book.current_shelves) else {"book": book} diff --git a/bookwyrm/tests/views/test_book.py b/bookwyrm/tests/views/test_book.py index 99022ec5..8c423e16 100644 --- a/bookwyrm/tests/views/test_book.py +++ b/bookwyrm/tests/views/test_book.py @@ -9,6 +9,7 @@ import responses from django.contrib.auth.models import Group, Permission from django.contrib.contenttypes.models import ContentType from django.core.files.uploadedfile import SimpleUploadedFile +from django.http import Http404 from django.template.response import TemplateResponse from django.test import TestCase from django.test.client import RequestFactory @@ -133,8 +134,8 @@ class BookViews(TestCase): request.user = self.local_user with patch("bookwyrm.views.books.is_api_request") as is_api: is_api.return_value = False - result = view(request, 0) - self.assertEqual(result.status_code, 404) + with self.assertRaises(Http404): + view(request, 0) def test_book_page_work_id(self): """there are so many views, this just makes sure it LOADS"""