Fix tests

This commit is contained in:
Joachim 2021-06-18 18:28:24 +02:00
parent 973b23856c
commit e07672fff1
4 changed files with 38 additions and 32 deletions

View file

@ -49,7 +49,7 @@ EMAIL_USE_SSL=false
# or use_dominant_color_light / use_dominant_color_dark # or use_dominant_color_light / use_dominant_color_dark
PREVIEW_BG_COLOR=use_dominant_color_light PREVIEW_BG_COLOR=use_dominant_color_light
# Change to #FFF if you use use_dominant_color_dark # Change to #FFF if you use use_dominant_color_dark
PREVIEW_TEXT_COLOR=#363636 PREVIEW_TEXT_COLOR="#363636"
PREVIEW_IMG_WIDTH=1200 PREVIEW_IMG_WIDTH=1200
PREVIEW_IMG_HEIGHT=630 PREVIEW_IMG_HEIGHT=630
PREVIEW_DEFAULT_COVER_COLOR=#002549 PREVIEW_DEFAULT_COVER_COLOR="#002549"

View file

@ -49,7 +49,7 @@ EMAIL_USE_SSL=false
# or use_dominant_color_light / use_dominant_color_dark # or use_dominant_color_light / use_dominant_color_dark
PREVIEW_BG_COLOR=use_dominant_color_light PREVIEW_BG_COLOR=use_dominant_color_light
# Change to #FFF if you use use_dominant_color_dark # Change to #FFF if you use use_dominant_color_dark
PREVIEW_TEXT_COLOR=#363636 PREVIEW_TEXT_COLOR="#363636"
PREVIEW_IMG_WIDTH=1200 PREVIEW_IMG_WIDTH=1200
PREVIEW_IMG_HEIGHT=630 PREVIEW_IMG_HEIGHT=630
PREVIEW_DEFAULT_COVER_COLOR=#002549 PREVIEW_DEFAULT_COVER_COLOR="#002549"

View file

@ -21,6 +21,7 @@ class EditUserViews(TestCase):
def setUp(self): def setUp(self):
"""we need basic test data and mocks""" """we need basic test data and mocks"""
self.factory = RequestFactory() self.factory = RequestFactory()
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
self.local_user = models.User.objects.create_user( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.mouse", "mouse@mouse.mouse",
@ -31,6 +32,8 @@ class EditUserViews(TestCase):
self.rat = models.User.objects.create_user( self.rat = models.User.objects.create_user(
"rat@local.com", "rat@rat.rat", "password", local=True, localname="rat" "rat@local.com", "rat@rat.rat", "password", local=True, localname="rat"
) )
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
self.book = models.Edition.objects.create(title="test") self.book = models.Edition.objects.create(title="test")
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"): with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
models.ShelfBook.objects.create( models.ShelfBook.objects.create(
@ -39,6 +42,7 @@ class EditUserViews(TestCase):
shelf=self.local_user.shelf_set.first(), shelf=self.local_user.shelf_set.first(),
) )
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
models.SiteSettings.objects.create() models.SiteSettings.objects.create()
self.anonymous_user = AnonymousUser self.anonymous_user = AnonymousUser
self.anonymous_user.is_authenticated = False self.anonymous_user.is_authenticated = False
@ -64,6 +68,7 @@ class EditUserViews(TestCase):
request.user = self.local_user request.user = self.local_user
self.assertIsNone(self.local_user.name) self.assertIsNone(self.local_user.name)
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
with patch( with patch(
"bookwyrm.models.activitypub_mixin.broadcast_task.delay" "bookwyrm.models.activitypub_mixin.broadcast_task.delay"
) as delay_mock: ) as delay_mock:
@ -88,6 +93,7 @@ class EditUserViews(TestCase):
request = self.factory.post("", form.data) request = self.factory.post("", form.data)
request.user = self.local_user request.user = self.local_user
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
with patch( with patch(
"bookwyrm.models.activitypub_mixin.broadcast_task.delay" "bookwyrm.models.activitypub_mixin.broadcast_task.delay"
) as delay_mock: ) as delay_mock: