adding mocks for views tests

This commit is contained in:
Mouse Reeve 2021-02-06 22:37:19 -08:00
parent 272685f27d
commit 6b10e487b6
16 changed files with 132 additions and 120 deletions

View file

@ -84,7 +84,7 @@ class AuthorViews(TestCase):
request = self.factory.post('', form.data)
request.user = self.local_user
with patch('bookwyrm.broadcast.broadcast_task.delay'):
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
view(request, author.id)
author.refresh_from_db()
self.assertEqual(author.name, 'New Name')

View file

@ -40,15 +40,16 @@ class BlockViews(TestCase):
''' create a "block" database entry from an activity '''
view = views.Block.as_view()
self.local_user.followers.add(self.remote_user)
models.UserFollowRequest.objects.create(
user_subject=self.local_user,
user_object=self.remote_user)
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
models.UserFollowRequest.objects.create(
user_subject=self.local_user,
user_object=self.remote_user)
self.assertTrue(models.UserFollows.objects.exists())
self.assertTrue(models.UserFollowRequest.objects.exists())
request = self.factory.post('')
request.user = self.local_user
with patch('bookwyrm.broadcast.broadcast_task.delay'):
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
view(request, self.remote_user.id)
block = models.UserBlocks.objects.get()
self.assertEqual(block.user_subject, self.local_user)
@ -63,7 +64,7 @@ class BlockViews(TestCase):
request = self.factory.post('')
request.user = self.local_user
with patch('bookwyrm.broadcast.broadcast_task.delay'):
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
views.block.unblock(request, self.remote_user.id)
self.assertFalse(models.UserBlocks.objects.exists())

View file

@ -77,7 +77,7 @@ class BookViews(TestCase):
form.data['last_edited_by'] = self.local_user.id
request = self.factory.post('', form.data)
request.user = self.local_user
with patch('bookwyrm.broadcast.broadcast_task.delay'):
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
view(request, self.book.id)
self.book.refresh_from_db()
self.assertEqual(self.book.title, 'New Title')
@ -90,8 +90,9 @@ class BookViews(TestCase):
title='first ed', parent_work=work)
edition2 = models.Edition.objects.create(
title='second ed', parent_work=work)
shelf = models.Shelf.objects.create(
name='Test Shelf', user=self.local_user)
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
shelf = models.Shelf.objects.create(
name='Test Shelf', user=self.local_user)
shelf.books.add(edition1)
models.ReadThrough.objects.create(
user=self.local_user, book=edition1)
@ -102,7 +103,7 @@ class BookViews(TestCase):
'edition': edition2.id
})
request.user = self.local_user
with patch('bookwyrm.broadcast.broadcast_task.delay'):
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
views.switch_edition(request)
self.assertEqual(models.ShelfBook.objects.get().book, edition2)

View file

@ -18,6 +18,7 @@ class FeedMessageViews(TestCase):
'mouse@local.com', 'mouse@mouse.mouse', 'password',
local=True, localname='mouse')
self.book = models.Edition.objects.create(
parent_work=models.Work.objects.create(title='hi'),
title='Example Edition',
remote_id='https://example.com/book/1',
)
@ -38,8 +39,9 @@ class FeedMessageViews(TestCase):
def test_status_page(self):
''' there are so many views, this just makes sure it LOADS '''
view = views.Status.as_view()
status = models.Status.objects.create(
content='hi', user=self.local_user)
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
status = models.Status.objects.create(
content='hi', user=self.local_user)
request = self.factory.get('')
request.user = self.local_user
with patch('bookwyrm.views.feed.is_api_request') as is_api:
@ -59,8 +61,9 @@ class FeedMessageViews(TestCase):
def test_replies_page(self):
''' there are so many views, this just makes sure it LOADS '''
view = views.Replies.as_view()
status = models.Status.objects.create(
content='hi', user=self.local_user)
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
status = models.Status.objects.create(
content='hi', user=self.local_user)
request = self.factory.get('')
request.user = self.local_user
with patch('bookwyrm.views.feed.is_api_request') as is_api:
@ -90,11 +93,12 @@ class FeedMessageViews(TestCase):
def test_get_suggested_book(self):
''' gets books the ~*~ algorithm ~*~ thinks you want to post about '''
models.ShelfBook.objects.create(
book=self.book,
user=self.local_user,
shelf=self.local_user.shelf_set.get(identifier='reading')
)
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
models.ShelfBook.objects.create(
book=self.book,
user=self.local_user,
shelf=self.local_user.shelf_set.get(identifier='reading')
)
suggestions = views.feed.get_suggested_books(self.local_user)
self.assertEqual(suggestions[0]['name'], 'Currently Reading')
self.assertEqual(suggestions[0]['books'][0], self.book)

View file

@ -46,7 +46,7 @@ class BookViews(TestCase):
request.user = self.local_user
self.assertEqual(models.UserFollowRequest.objects.count(), 0)
with patch('bookwyrm.broadcast.broadcast_task.delay'):
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
views.follow(request)
rel = models.UserFollowRequest.objects.get()
@ -62,7 +62,7 @@ class BookViews(TestCase):
request.user = self.local_user
self.remote_user.followers.add(self.local_user)
self.assertEqual(self.remote_user.followers.count(), 1)
with patch('bookwyrm.broadcast.broadcast_task.delay'):
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
views.unfollow(request)
self.assertEqual(self.remote_user.followers.count(), 0)
@ -77,7 +77,7 @@ class BookViews(TestCase):
user_object=self.local_user
)
with patch('bookwyrm.broadcast.broadcast_task.delay'):
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
views.accept_follow_request(request)
# request should be deleted
self.assertEqual(
@ -96,7 +96,7 @@ class BookViews(TestCase):
user_object=self.local_user
)
with patch('bookwyrm.broadcast.broadcast_task.delay'):
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
views.delete_follow_request(request)
# request should be deleted
self.assertEqual(

View file

@ -100,7 +100,7 @@ class GoalViews(TestCase):
'post-status': True
})
request.user = self.local_user
with patch('bookwyrm.broadcast.broadcast_task.delay'):
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
view(request, self.local_user.localname, 2020)
goal = models.AnnualGoal.objects.get()

View file

@ -38,11 +38,12 @@ class ViewsHelpers(TestCase):
)
self.userdata = json.loads(datafile.read_bytes())
del self.userdata['icon']
self.shelf = models.Shelf.objects.create(
name='Test Shelf',
identifier='test-shelf',
user=self.local_user
)
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
self.shelf = models.Shelf.objects.create(
name='Test Shelf',
identifier='test-shelf',
user=self.local_user
)
def test_get_edition(self):
@ -83,22 +84,23 @@ class ViewsHelpers(TestCase):
rat = models.User.objects.create_user(
'rat', 'rat@rat.rat', 'password', local=True)
public_status = models.Comment.objects.create(
content='public status', book=self.book, user=self.local_user)
direct_status = models.Status.objects.create(
content='direct', user=self.local_user, privacy='direct')
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
public_status = models.Comment.objects.create(
content='public status', book=self.book, user=self.local_user)
direct_status = models.Status.objects.create(
content='direct', user=self.local_user, privacy='direct')
rat_public = models.Status.objects.create(
content='blah blah', user=rat)
rat_unlisted = models.Status.objects.create(
content='blah blah', user=rat, privacy='unlisted')
remote_status = models.Status.objects.create(
content='blah blah', user=self.remote_user)
followers_status = models.Status.objects.create(
content='blah', user=rat, privacy='followers')
rat_mention = models.Status.objects.create(
content='blah blah blah', user=rat, privacy='followers')
rat_mention.mention_users.set([self.local_user])
rat_public = models.Status.objects.create(
content='blah blah', user=rat)
rat_unlisted = models.Status.objects.create(
content='blah blah', user=rat, privacy='unlisted')
remote_status = models.Status.objects.create(
content='blah blah', user=self.remote_user)
followers_status = models.Status.objects.create(
content='blah', user=rat, privacy='followers')
rat_mention = models.Status.objects.create(
content='blah blah blah', user=rat, privacy='followers')
rat_mention.mention_users.set([self.local_user])
statuses = views.helpers.get_activity_feed(
self.local_user,
@ -159,14 +161,15 @@ class ViewsHelpers(TestCase):
rat = models.User.objects.create_user(
'rat', 'rat@rat.rat', 'password', local=True)
public_status = models.Comment.objects.create(
content='public status', book=self.book, user=self.local_user)
rat_public = models.Status.objects.create(
content='blah blah', user=rat)
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
public_status = models.Comment.objects.create(
content='public status', book=self.book, user=self.local_user)
rat_public = models.Status.objects.create(
content='blah blah', user=rat)
statuses = views.helpers.get_activity_feed(
self.local_user, ['public'])
self.assertEqual(len(statuses), 2)
statuses = views.helpers.get_activity_feed(
self.local_user, ['public'])
self.assertEqual(len(statuses), 2)
# block relationship
rat.blocks.add(self.local_user)
@ -240,7 +243,7 @@ class ViewsHelpers(TestCase):
def test_handle_reading_status_to_read(self):
''' posts shelve activities '''
shelf = self.local_user.shelf_set.get(identifier='to-read')
with patch('bookwyrm.broadcast.broadcast_task.delay'):
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
views.helpers.handle_reading_status(
self.local_user, shelf, self.book, 'public')
status = models.GeneratedNote.objects.get()
@ -251,7 +254,7 @@ class ViewsHelpers(TestCase):
def test_handle_reading_status_reading(self):
''' posts shelve activities '''
shelf = self.local_user.shelf_set.get(identifier='reading')
with patch('bookwyrm.broadcast.broadcast_task.delay'):
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
views.helpers.handle_reading_status(
self.local_user, shelf, self.book, 'public')
status = models.GeneratedNote.objects.get()
@ -262,7 +265,7 @@ class ViewsHelpers(TestCase):
def test_handle_reading_status_read(self):
''' posts shelve activities '''
shelf = self.local_user.shelf_set.get(identifier='read')
with patch('bookwyrm.broadcast.broadcast_task.delay'):
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
views.helpers.handle_reading_status(
self.local_user, shelf, self.book, 'public')
status = models.GeneratedNote.objects.get()
@ -272,7 +275,7 @@ class ViewsHelpers(TestCase):
def test_handle_reading_status_other(self):
''' posts shelve activities '''
with patch('bookwyrm.broadcast.broadcast_task.delay'):
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
views.helpers.handle_reading_status(
self.local_user, self.shelf, self.book, 'public')
self.assertFalse(models.GeneratedNote.objects.exists())

View file

@ -38,10 +38,10 @@ class InteractionViews(TestCase):
view = views.Favorite.as_view()
request = self.factory.post('')
request.user = self.remote_user
status = models.Status.objects.create(
user=self.local_user, content='hi')
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
status = models.Status.objects.create(
user=self.local_user, content='hi')
with patch('bookwyrm.broadcast.broadcast_task.delay'):
view(request, status.id)
fav = models.Favorite.objects.get()
self.assertEqual(fav.status, status)
@ -58,15 +58,15 @@ class InteractionViews(TestCase):
view = views.Unfavorite.as_view()
request = self.factory.post('')
request.user = self.remote_user
status = models.Status.objects.create(
user=self.local_user, content='hi')
with patch('bookwyrm.broadcast.broadcast_task.delay'):
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
status = models.Status.objects.create(
user=self.local_user, content='hi')
views.Favorite.as_view()(request, status.id)
self.assertEqual(models.Favorite.objects.count(), 1)
self.assertEqual(models.Notification.objects.count(), 1)
with patch('bookwyrm.broadcast.broadcast_task.delay'):
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
view(request, status.id)
self.assertEqual(models.Favorite.objects.count(), 0)
self.assertEqual(models.Notification.objects.count(), 0)
@ -77,10 +77,10 @@ class InteractionViews(TestCase):
view = views.Boost.as_view()
request = self.factory.post('')
request.user = self.remote_user
status = models.Status.objects.create(
user=self.local_user, content='hi')
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
status = models.Status.objects.create(
user=self.local_user, content='hi')
with patch('bookwyrm.broadcast.broadcast_task.delay'):
view(request, status.id)
boost = models.Boost.objects.get()
@ -99,10 +99,10 @@ class InteractionViews(TestCase):
view = views.Boost.as_view()
request = self.factory.post('')
request.user = self.local_user
status = models.Status.objects.create(
user=self.local_user, content='hi', privacy='unlisted')
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
status = models.Status.objects.create(
user=self.local_user, content='hi', privacy='unlisted')
with patch('bookwyrm.broadcast.broadcast_task.delay'):
view(request, status.id)
boost = models.Boost.objects.get()
@ -113,10 +113,10 @@ class InteractionViews(TestCase):
view = views.Boost.as_view()
request = self.factory.post('')
request.user = self.local_user
status = models.Status.objects.create(
user=self.local_user, content='hi', privacy='followers')
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
status = models.Status.objects.create(
user=self.local_user, content='hi', privacy='followers')
with patch('bookwyrm.broadcast.broadcast_task.delay'):
view(request, status.id)
self.assertFalse(models.Boost.objects.exists())
@ -125,10 +125,10 @@ class InteractionViews(TestCase):
view = views.Boost.as_view()
request = self.factory.post('')
request.user = self.local_user
status = models.Status.objects.create(
user=self.local_user, content='hi')
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
status = models.Status.objects.create(
user=self.local_user, content='hi')
with patch('bookwyrm.broadcast.broadcast_task.delay'):
view(request, status.id)
view(request, status.id)
self.assertEqual(models.Boost.objects.count(), 1)
@ -139,14 +139,14 @@ class InteractionViews(TestCase):
view = views.Unboost.as_view()
request = self.factory.post('')
request.user = self.remote_user
status = models.Status.objects.create(
user=self.local_user, content='hi')
with patch('bookwyrm.broadcast.broadcast_task.delay'):
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
status = models.Status.objects.create(
user=self.local_user, content='hi')
views.Boost.as_view()(request, status.id)
self.assertEqual(models.Boost.objects.count(), 1)
self.assertEqual(models.Notification.objects.count(), 1)
with patch('bookwyrm.broadcast.broadcast_task.delay'):
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
view(request, status.id)
self.assertEqual(models.Boost.objects.count(), 0)
self.assertEqual(models.Notification.objects.count(), 0)

View file

@ -10,7 +10,7 @@ from bookwyrm import models, views
from bookwyrm.activitypub import ActivitypubResponse
@patch('bookwyrm.broadcast.broadcast_task.delay')
@patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay')
class ListViews(TestCase):
''' tag views'''
def setUp(self):
@ -32,8 +32,9 @@ class ListViews(TestCase):
remote_id='https://example.com/book/1',
parent_work=work,
)
self.list = models.List.objects.create(
name='Test List', user=self.local_user)
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
self.list = models.List.objects.create(
name='Test List', user=self.local_user)
self.anonymous_user = AnonymousUser
self.anonymous_user.is_authenticated = False
models.SiteSettings.objects.create()
@ -43,8 +44,9 @@ class ListViews(TestCase):
''' there are so many views, this just makes sure it LOADS '''
view = views.Lists.as_view()
models.List.objects.create(name='Public list', user=self.local_user)
models.List.objects.create(
name='Private list', privacy='private', user=self.local_user)
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
models.List.objects.create(
name='Private list', privacy='private', user=self.local_user)
request = self.factory.get('')
request.user = self.local_user
@ -128,6 +130,7 @@ class ListViews(TestCase):
})
request.user = self.local_user
# TODO should broadcast?
result = view(request, self.list.id)
self.assertEqual(result.status_code, 302)

View file

@ -1,4 +1,5 @@
''' sending out activities '''
from unittest.mock import patch
import json
from django.http import JsonResponse
@ -49,14 +50,16 @@ class OutboxView(TestCase):
def test_outbox_privacy(self):
''' don't show dms et cetera in outbox '''
models.Status.objects.create(
content='PRIVATE!!', user=self.local_user, privacy='direct')
models.Status.objects.create(
content='bffs ONLY', user=self.local_user, privacy='followers')
models.Status.objects.create(
content='unlisted status', user=self.local_user, privacy='unlisted')
models.Status.objects.create(
content='look at this', user=self.local_user, privacy='public')
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
models.Status.objects.create(
content='PRIVATE!!', user=self.local_user, privacy='direct')
models.Status.objects.create(
content='bffs ONLY', user=self.local_user, privacy='followers')
models.Status.objects.create(
content='unlisted status', user=self.local_user,
privacy='unlisted')
models.Status.objects.create(
content='look at this', user=self.local_user, privacy='public')
request = self.factory.get('')
result = views.Outbox.as_view()(request, 'mouse')
@ -67,11 +70,12 @@ class OutboxView(TestCase):
def test_outbox_filter(self):
''' if we only care about reviews, only get reviews '''
models.Review.objects.create(
content='look at this', name='hi', rating=1,
book=self.book, user=self.local_user)
models.Status.objects.create(
content='look at this', user=self.local_user)
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
models.Review.objects.create(
content='look at this', name='hi', rating=1,
book=self.book, user=self.local_user)
models.Status.objects.create(
content='look at this', user=self.local_user)
request = self.factory.get('', {'type': 'bleh'})
result = views.Outbox.as_view()(request, 'mouse')

View file

@ -45,7 +45,7 @@ class ReadingViews(TestCase):
'start_date': '2020-01-05',
})
request.user = self.local_user
with patch('bookwyrm.broadcast.broadcast_task.delay'):
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
views.start_reading(request, self.book.id)
self.assertEqual(shelf.books.get(), self.book)
@ -74,7 +74,7 @@ class ReadingViews(TestCase):
request = self.factory.post('')
request.user = self.local_user
with patch('bookwyrm.broadcast.broadcast_task.delay'):
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
views.start_reading(request, self.book.id)
self.assertFalse(to_read_shelf.books.exists())
@ -98,7 +98,7 @@ class ReadingViews(TestCase):
})
request.user = self.local_user
with patch('bookwyrm.broadcast.broadcast_task.delay'):
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
views.finish_reading(request, self.book.id)
self.assertEqual(shelf.books.get(), self.book)

View file

@ -2,16 +2,14 @@
from unittest.mock import patch
from django.test import RequestFactory, TestCase
import responses
from bookwyrm import models
from bookwyrm.views import rss_feed
from bookwyrm.settings import DOMAIN
class RssFeedView(TestCase):
''' rss feed behaves as expected '''
def setUp(self):
''' test data '''
self.site = models.SiteSettings.objects.create()
self.user = models.User.objects.create_user(
@ -39,6 +37,7 @@ class RssFeedView(TestCase):
def test_rss_feed(self):
''' load an rss feed '''
view = rss_feed.RssFeed()
request = self.factory.get('/user/rss_user/rss')
with patch("bookwyrm.models.SiteSettings.objects.get") as site:
@ -47,6 +46,5 @@ class RssFeedView(TestCase):
self.assertEqual(result.status_code, 200)
self.assertIn(b"Status updates from rss_user", result.content)
self.assertIn( b"a sickening sense", result.content)
self.assertIn(b"a sickening sense", result.content)
self.assertIn(b"Example Edition", result.content)

View file

@ -8,7 +8,7 @@ from bookwyrm import models, views
from bookwyrm.activitypub import ActivitypubResponse
@patch('bookwyrm.broadcast.broadcast_task.delay')
@patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay')
class ShelfViews(TestCase):
''' tag views'''
def setUp(self):
@ -170,7 +170,7 @@ class ShelfViews(TestCase):
})
request.user = self.local_user
with patch('bookwyrm.broadcast.broadcast_task.delay'):
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
views.shelve(request)
# make sure the book is on the shelf
self.assertEqual(shelf.books.get(), self.book)
@ -186,6 +186,6 @@ class ShelfViews(TestCase):
'shelf': self.shelf.id
})
request.user = self.local_user
with patch('bookwyrm.broadcast.broadcast_task.delay'):
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
views.unshelve(request)
self.assertEqual(self.shelf.books.count(), 0)

View file

@ -1,11 +1,9 @@
''' test for app action functionality '''
from unittest.mock import patch
from django.template.response import TemplateResponse
from django.test import TestCase
from django.test.client import RequestFactory
from bookwyrm import forms, models, views
from bookwyrm.activitypub import ActivitypubResponse
from bookwyrm.settings import DOMAIN
@ -47,7 +45,7 @@ class StatusViews(TestCase):
})
request = self.factory.post('', form.data)
request.user = self.local_user
with patch('bookwyrm.broadcast.broadcast_task.delay'):
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
view(request, 'comment')
status = models.Comment.objects.get()
self.assertEqual(status.content, '<p>hi</p>')
@ -69,7 +67,7 @@ class StatusViews(TestCase):
})
request = self.factory.post('', form.data)
request.user = user
with patch('bookwyrm.broadcast.broadcast_task.delay'):
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
view(request, 'reply')
status = models.Status.objects.get(user=user)
self.assertEqual(status.content, '<p>hi</p>')
@ -92,7 +90,7 @@ class StatusViews(TestCase):
request = self.factory.post('', form.data)
request.user = self.local_user
with patch('bookwyrm.broadcast.broadcast_task.delay'):
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
view(request, 'comment')
status = models.Status.objects.get()
self.assertEqual(list(status.mention_users.all()), [user])
@ -116,7 +114,7 @@ class StatusViews(TestCase):
request = self.factory.post('', form.data)
request.user = self.local_user
with patch('bookwyrm.broadcast.broadcast_task.delay'):
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
view(request, 'comment')
status = models.Status.objects.get()
@ -128,7 +126,7 @@ class StatusViews(TestCase):
})
request = self.factory.post('', form.data)
request.user = user
with patch('bookwyrm.broadcast.broadcast_task.delay'):
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
view(request, 'reply')
reply = models.Status.replies(status).first()
@ -226,7 +224,7 @@ class StatusViews(TestCase):
self.assertFalse(status.deleted)
request = self.factory.post('')
request.user = self.local_user
with patch('bookwyrm.broadcast.broadcast_task.delay'):
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
view(request, status.id)
status.refresh_from_db()
self.assertTrue(status.deleted)

View file

@ -68,7 +68,7 @@ class TagViews(TestCase):
})
request.user = self.local_user
with patch('bookwyrm.broadcast.broadcast_task.delay'):
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
view(request)
tag = models.Tag.objects.get()
@ -93,7 +93,7 @@ class TagViews(TestCase):
})
request.user = self.local_user
with patch('bookwyrm.broadcast.broadcast_task.delay'):
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
view(request)
self.assertTrue(models.Tag.objects.filter(name='A Tag!?').exists())

View file

@ -138,7 +138,7 @@ class UserViews(TestCase):
request = self.factory.post('', form.data)
request.user = self.local_user
with patch('bookwyrm.broadcast.broadcast_task.delay'):
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
view(request)
self.assertEqual(self.local_user.name, 'New Name')