Fix tests?

This commit is contained in:
Joachim 2021-12-21 17:24:15 +01:00
parent 8f0df388e6
commit 66ee5ccacf

View file

@ -12,6 +12,11 @@ from bookwyrm import models, views
from bookwyrm.tests.validate_html import validate_html from bookwyrm.tests.validate_html import validate_html
def make_date(*args):
"""helper function to easily generate a date obj"""
return datetime(*args, tzinfo=pytz.UTC)
class AnnualSummary(TestCase): class AnnualSummary(TestCase):
"""views""" """views"""
@ -91,18 +96,18 @@ class AnnualSummary(TestCase):
validate_html(result.render()) validate_html(result.render())
self.assertEqual(result.status_code, 200) self.assertEqual(result.status_code, 200)
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
@patch("bookwyrm.activitystreams.add_book_statuses_task.delay")
def test_annual_summary_page(self, *_): def test_annual_summary_page(self, *_):
"""there are so many views, this just makes sure it LOADS""" """there are so many views, this just makes sure it LOADS"""
shelf = self.local_user.shelf_set.get(identifier="read") shelf = self.local_user.shelf_set.filter(identifier="read").first()
models.ShelfBook.objects.create(
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"): book=self.book,
models.ShelfBook.objects.create( user=self.local_user,
book=self.book, shelf=shelf,
user=self.local_user, shelved_date=make_date(2020, 1, 1),
shelf=shelf, )
shelved_date=datetime(2020, 1, 1),
)
view = views.AnnualSummary.as_view() view = views.AnnualSummary.as_view()
request = self.factory.get("") request = self.factory.get("")