mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-29 13:01:08 +00:00
Updates mocks across tests
This commit is contained in:
parent
f71ef286b6
commit
e6a251fdad
57 changed files with 253 additions and 212 deletions
|
@ -66,9 +66,10 @@ class BookDataModel(ObjectMixin, BookWyrmModel):
|
|||
self.remote_id = None
|
||||
return super().save(*args, **kwargs)
|
||||
|
||||
def broadcast(self, activity, sender, software="bookwyrm"):
|
||||
# pylint: disable=arguments-differ
|
||||
def broadcast(self, activity, sender, software="bookwyrm", **kwargs):
|
||||
"""only send book data updates to other bookwyrm instances"""
|
||||
super().broadcast(activity, sender, software=software)
|
||||
super().broadcast(activity, sender, software=software, **kwargs)
|
||||
|
||||
|
||||
class Book(BookDataModel):
|
||||
|
|
|
@ -146,7 +146,7 @@ class BaseActivity(TestCase):
|
|||
self.user.avatar.file # pylint: disable=pointless-statement
|
||||
|
||||
# this would trigger a broadcast because it's a local user
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
activity.to_model(model=models.User, instance=self.user)
|
||||
self.assertIsNotNone(self.user.avatar.file)
|
||||
self.assertEqual(self.user.name, "New Name")
|
||||
|
@ -154,7 +154,7 @@ class BaseActivity(TestCase):
|
|||
|
||||
def test_to_model_many_to_many(self, *_):
|
||||
"""annoying that these all need special handling"""
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
status = models.Status.objects.create(
|
||||
content="test status",
|
||||
user=self.user,
|
||||
|
@ -186,7 +186,7 @@ class BaseActivity(TestCase):
|
|||
def test_to_model_one_to_many(self, *_):
|
||||
"""these are reversed relationships, where the secondary object
|
||||
keys the primary object but not vice versa"""
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
status = models.Status.objects.create(
|
||||
content="test status",
|
||||
user=self.user,
|
||||
|
@ -224,7 +224,7 @@ class BaseActivity(TestCase):
|
|||
@responses.activate
|
||||
def test_set_related_field(self, *_):
|
||||
"""celery task to add back-references to created objects"""
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
status = models.Status.objects.create(
|
||||
content="test status",
|
||||
user=self.user,
|
||||
|
|
|
@ -4,7 +4,7 @@ from django.test import TestCase
|
|||
from bookwyrm import activitystreams, models
|
||||
|
||||
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
|
||||
@patch("bookwyrm.activitystreams.add_status_task.delay")
|
||||
@patch("bookwyrm.activitystreams.add_book_statuses_task.delay")
|
||||
@patch("bookwyrm.suggested_users.rerank_suggestions_task.delay")
|
||||
|
|
|
@ -4,7 +4,7 @@ from django.test import TestCase
|
|||
from bookwyrm import activitystreams, models
|
||||
|
||||
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
|
||||
@patch("bookwyrm.activitystreams.add_status_task.delay")
|
||||
@patch("bookwyrm.activitystreams.add_book_statuses_task.delay")
|
||||
@patch("bookwyrm.suggested_users.rerank_suggestions_task.delay")
|
||||
|
|
|
@ -4,7 +4,7 @@ from django.test import TestCase
|
|||
from bookwyrm import activitystreams, models
|
||||
|
||||
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
|
||||
@patch("bookwyrm.activitystreams.add_status_task.delay")
|
||||
@patch("bookwyrm.activitystreams.add_book_statuses_task.delay")
|
||||
@patch("bookwyrm.suggested_users.rerank_suggestions_task.delay")
|
||||
|
|
|
@ -4,7 +4,7 @@ from django.test import TestCase
|
|||
from bookwyrm import activitystreams, models
|
||||
|
||||
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
|
||||
@patch("bookwyrm.activitystreams.add_status_task.delay")
|
||||
@patch("bookwyrm.activitystreams.add_book_statuses_task.delay")
|
||||
@patch("bookwyrm.suggested_users.rerank_suggestions_task.delay")
|
||||
|
|
|
@ -4,7 +4,7 @@ from django.test import TestCase
|
|||
from bookwyrm import activitystreams, models
|
||||
|
||||
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
|
||||
class ActivitystreamsSignals(TestCase):
|
||||
"""using redis to build activity streams"""
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ class Activitystreams(TestCase):
|
|||
)
|
||||
work = models.Work.objects.create(title="test work")
|
||||
self.book = models.Edition.objects.create(title="test book", parent_work=work)
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
self.status = models.Status.objects.create(
|
||||
content="hi", user=self.local_user
|
||||
)
|
||||
|
@ -133,7 +133,7 @@ class Activitystreams(TestCase):
|
|||
|
||||
@patch("bookwyrm.activitystreams.LocalStream.remove_object_from_related_stores")
|
||||
@patch("bookwyrm.activitystreams.BooksStream.remove_object_from_related_stores")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
|
||||
def test_boost_to_another_timeline(self, *_):
|
||||
"""boost from a non-follower doesn't remove original status from feed"""
|
||||
status = models.Status.objects.create(user=self.local_user, content="hi")
|
||||
|
@ -155,7 +155,7 @@ class Activitystreams(TestCase):
|
|||
|
||||
@patch("bookwyrm.activitystreams.LocalStream.remove_object_from_related_stores")
|
||||
@patch("bookwyrm.activitystreams.BooksStream.remove_object_from_related_stores")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
|
||||
def test_boost_to_another_timeline_remote(self, *_):
|
||||
"""boost from a remote non-follower doesn't remove original status from feed"""
|
||||
status = models.Status.objects.create(user=self.local_user, content="hi")
|
||||
|
@ -177,7 +177,7 @@ class Activitystreams(TestCase):
|
|||
|
||||
@patch("bookwyrm.activitystreams.LocalStream.remove_object_from_related_stores")
|
||||
@patch("bookwyrm.activitystreams.BooksStream.remove_object_from_related_stores")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
|
||||
def test_boost_to_following_timeline(self, *_):
|
||||
"""add a boost and deduplicate the boosted status on the timeline"""
|
||||
self.local_user.following.add(self.another_user)
|
||||
|
@ -199,7 +199,7 @@ class Activitystreams(TestCase):
|
|||
|
||||
@patch("bookwyrm.activitystreams.LocalStream.remove_object_from_related_stores")
|
||||
@patch("bookwyrm.activitystreams.BooksStream.remove_object_from_related_stores")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
|
||||
def test_boost_to_same_timeline(self, *_):
|
||||
"""add a boost and deduplicate the boosted status on the timeline"""
|
||||
status = models.Status.objects.create(user=self.local_user, content="hi")
|
||||
|
|
|
@ -91,7 +91,7 @@ class GoodreadsImport(TestCase):
|
|||
import_item.book = self.book
|
||||
import_item.save()
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
handle_imported_book(
|
||||
self.importer.service, self.local_user, import_item, False, "public"
|
||||
)
|
||||
|
@ -115,7 +115,7 @@ class GoodreadsImport(TestCase):
|
|||
import_item.book = self.book
|
||||
import_item.save()
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
handle_imported_book(
|
||||
self.importer.service, self.local_user, import_item, True, "unlisted"
|
||||
)
|
||||
|
@ -135,7 +135,7 @@ class GoodreadsImport(TestCase):
|
|||
import_item.book = self.book
|
||||
import_item.save()
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
handle_imported_book(
|
||||
self.importer.service, self.local_user, import_item, True, "unlisted"
|
||||
)
|
||||
|
|
|
@ -114,7 +114,7 @@ class LibrarythingImport(TestCase):
|
|||
import_item.book = self.book
|
||||
import_item.save()
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
handle_imported_book(
|
||||
self.importer.service, self.local_user, import_item, False, "public"
|
||||
)
|
||||
|
@ -129,7 +129,7 @@ class LibrarythingImport(TestCase):
|
|||
|
||||
def test_handle_imported_book_already_shelved(self, *_):
|
||||
"""librarything import added a book, this adds related connections"""
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
shelf = self.local_user.shelf_set.filter(identifier="to-read").first()
|
||||
models.ShelfBook.objects.create(
|
||||
shelf=shelf, user=self.local_user, book=self.book
|
||||
|
@ -142,7 +142,7 @@ class LibrarythingImport(TestCase):
|
|||
import_item.book = self.book
|
||||
import_item.save()
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
handle_imported_book(
|
||||
self.importer.service, self.local_user, import_item, False, "public"
|
||||
)
|
||||
|
@ -166,7 +166,7 @@ class LibrarythingImport(TestCase):
|
|||
import_item.book = self.book
|
||||
import_item.save()
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
handle_imported_book(
|
||||
self.importer.service, self.local_user, import_item, True, "unlisted"
|
||||
)
|
||||
|
|
|
@ -95,7 +95,7 @@ class StorygraphImport(TestCase):
|
|||
import_item.book = self.book
|
||||
import_item.save()
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
handle_imported_book(
|
||||
self.importer.service, self.local_user, import_item, False, "public"
|
||||
)
|
||||
|
@ -116,7 +116,7 @@ class StorygraphImport(TestCase):
|
|||
import_item.book = self.book
|
||||
import_item.save()
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
handle_imported_book(
|
||||
self.importer.service, self.local_user, import_item, True, "unlisted"
|
||||
)
|
||||
|
|
|
@ -6,7 +6,7 @@ from bookwyrm import models
|
|||
from bookwyrm.management.commands.populate_streams import populate_streams
|
||||
|
||||
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
|
||||
class Activitystreams(TestCase):
|
||||
"""using redis to build activity streams"""
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ from bookwyrm.settings import PAGE_LENGTH
|
|||
|
||||
# pylint: disable=invalid-name
|
||||
@patch("bookwyrm.activitystreams.add_status_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
|
||||
class ActivitypubMixins(TestCase):
|
||||
"""functionality shared across models"""
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ from django.test import TestCase
|
|||
from bookwyrm import models, settings
|
||||
|
||||
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
|
||||
class Group(TestCase):
|
||||
"""some activitypub oddness ahead"""
|
||||
|
||||
|
@ -87,7 +87,7 @@ class Group(TestCase):
|
|||
def test_group_members_can_see_followers_only_lists(self, _):
|
||||
"""follower-only group booklists should not be excluded from group booklist listing for group members who do not follower list owner"""
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
followers_list = models.List.objects.create(
|
||||
name="Followers List",
|
||||
curation="group",
|
||||
|
@ -107,7 +107,7 @@ class Group(TestCase):
|
|||
def test_group_members_can_see_private_lists(self, _):
|
||||
"""private group booklists should not be excluded from group booklist listing for group members"""
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
|
||||
private_list = models.List.objects.create(
|
||||
name="Private List",
|
||||
|
|
|
@ -5,7 +5,7 @@ from django.test import TestCase
|
|||
from bookwyrm import models, settings
|
||||
|
||||
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
|
||||
class List(TestCase):
|
||||
"""some activitypub oddness ahead"""
|
||||
|
||||
|
@ -22,7 +22,7 @@ class List(TestCase):
|
|||
|
||||
def test_remote_id(self, _):
|
||||
"""shelves use custom remote ids"""
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
book_list = models.List.objects.create(
|
||||
name="Test List", user=self.local_user
|
||||
)
|
||||
|
@ -31,7 +31,7 @@ class List(TestCase):
|
|||
|
||||
def test_to_activity(self, _):
|
||||
"""jsonify it"""
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
book_list = models.List.objects.create(
|
||||
name="Test List", user=self.local_user
|
||||
)
|
||||
|
@ -45,7 +45,7 @@ class List(TestCase):
|
|||
|
||||
def test_list_item(self, _):
|
||||
"""a list entry"""
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
book_list = models.List.objects.create(
|
||||
name="Test List", user=self.local_user, privacy="unlisted"
|
||||
)
|
||||
|
@ -63,7 +63,7 @@ class List(TestCase):
|
|||
|
||||
def test_list_item_pending(self, _):
|
||||
"""a list entry"""
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
book_list = models.List.objects.create(
|
||||
name="Test List", user=self.local_user
|
||||
)
|
||||
|
|
|
@ -33,11 +33,13 @@ class Relationship(TestCase):
|
|||
|
||||
def test_user_follows_from_request(self, _):
|
||||
"""convert a follow request into a follow"""
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay") as mock:
|
||||
with patch(
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||
) as mock:
|
||||
request = models.UserFollowRequest.objects.create(
|
||||
user_subject=self.local_user, user_object=self.remote_user
|
||||
)
|
||||
activity = json.loads(mock.call_args[0][1])
|
||||
activity = json.loads(mock.call_args[1]["args"][1])
|
||||
self.assertEqual(activity["type"], "Follow")
|
||||
self.assertEqual(
|
||||
request.remote_id, "http://local.com/user/mouse#follows/%d" % request.id
|
||||
|
@ -54,7 +56,7 @@ class Relationship(TestCase):
|
|||
|
||||
def test_user_follows_from_request_custom_remote_id(self, _):
|
||||
"""store a specific remote id for a relationship provided by remote"""
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
request = models.UserFollowRequest.objects.create(
|
||||
user_subject=self.local_user,
|
||||
user_object=self.remote_user,
|
||||
|
@ -69,19 +71,19 @@ class Relationship(TestCase):
|
|||
self.assertEqual(rel.user_subject, self.local_user)
|
||||
self.assertEqual(rel.user_object, self.remote_user)
|
||||
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
|
||||
def test_follow_request_activity(self, broadcast_mock, _):
|
||||
"""accept a request and make it a relationship"""
|
||||
models.UserFollowRequest.objects.create(
|
||||
user_subject=self.local_user,
|
||||
user_object=self.remote_user,
|
||||
)
|
||||
activity = json.loads(broadcast_mock.call_args[0][1])
|
||||
activity = json.loads(broadcast_mock.call_args[1]["args"][1])
|
||||
self.assertEqual(activity["actor"], self.local_user.remote_id)
|
||||
self.assertEqual(activity["object"], self.remote_user.remote_id)
|
||||
self.assertEqual(activity["type"], "Follow")
|
||||
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
|
||||
def test_follow_request_accept(self, broadcast_mock, _):
|
||||
"""accept a request and make it a relationship"""
|
||||
self.local_user.manually_approves_followers = True
|
||||
|
@ -96,7 +98,7 @@ class Relationship(TestCase):
|
|||
)
|
||||
request.accept()
|
||||
|
||||
activity = json.loads(broadcast_mock.call_args[0][1])
|
||||
activity = json.loads(broadcast_mock.call_args[1]["args"][1])
|
||||
self.assertEqual(activity["type"], "Accept")
|
||||
self.assertEqual(activity["actor"], self.local_user.remote_id)
|
||||
self.assertEqual(activity["object"]["id"], "https://www.hi.com/")
|
||||
|
@ -107,7 +109,7 @@ class Relationship(TestCase):
|
|||
self.assertEqual(rel.user_subject, self.remote_user)
|
||||
self.assertEqual(rel.user_object, self.local_user)
|
||||
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
|
||||
def test_follow_request_reject(self, broadcast_mock, _):
|
||||
"""accept a request and make it a relationship"""
|
||||
self.local_user.manually_approves_followers = True
|
||||
|
@ -120,7 +122,7 @@ class Relationship(TestCase):
|
|||
)
|
||||
request.reject()
|
||||
|
||||
activity = json.loads(broadcast_mock.call_args[0][1])
|
||||
activity = json.loads(broadcast_mock.call_args[1]["args"][1])
|
||||
self.assertEqual(activity["type"], "Reject")
|
||||
self.assertEqual(activity["actor"], self.local_user.remote_id)
|
||||
self.assertEqual(activity["object"]["id"], request.remote_id)
|
||||
|
|
|
@ -27,7 +27,7 @@ class Shelf(TestCase):
|
|||
|
||||
def test_remote_id(self, *_):
|
||||
"""shelves use custom remote ids"""
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
shelf = models.Shelf.objects.create(
|
||||
name="Test Shelf", identifier="test-shelf", user=self.local_user
|
||||
)
|
||||
|
@ -36,7 +36,7 @@ class Shelf(TestCase):
|
|||
|
||||
def test_to_activity(self, *_):
|
||||
"""jsonify it"""
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
shelf = models.Shelf.objects.create(
|
||||
name="Test Shelf", identifier="test-shelf", user=self.local_user
|
||||
)
|
||||
|
@ -51,19 +51,23 @@ class Shelf(TestCase):
|
|||
def test_create_update_shelf(self, *_):
|
||||
"""create and broadcast shelf creation"""
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay") as mock:
|
||||
with patch(
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||
) as mock:
|
||||
shelf = models.Shelf.objects.create(
|
||||
name="Test Shelf", identifier="test-shelf", user=self.local_user
|
||||
)
|
||||
activity = json.loads(mock.call_args[0][1])
|
||||
activity = json.loads(mock.call_args[1]["args"][1])
|
||||
self.assertEqual(activity["type"], "Create")
|
||||
self.assertEqual(activity["actor"], self.local_user.remote_id)
|
||||
self.assertEqual(activity["object"]["name"], "Test Shelf")
|
||||
|
||||
shelf.name = "arthur russel"
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay") as mock:
|
||||
with patch(
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||
) as mock:
|
||||
shelf.save()
|
||||
activity = json.loads(mock.call_args[0][1])
|
||||
activity = json.loads(mock.call_args[1]["args"][1])
|
||||
self.assertEqual(activity["type"], "Update")
|
||||
self.assertEqual(activity["actor"], self.local_user.remote_id)
|
||||
self.assertEqual(activity["object"]["name"], "arthur russel")
|
||||
|
@ -71,27 +75,31 @@ class Shelf(TestCase):
|
|||
|
||||
def test_shelve(self, *_):
|
||||
"""create and broadcast shelf creation"""
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
shelf = models.Shelf.objects.create(
|
||||
name="Test Shelf", identifier="test-shelf", user=self.local_user
|
||||
)
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay") as mock:
|
||||
with patch(
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||
) as mock:
|
||||
shelf_book = models.ShelfBook.objects.create(
|
||||
shelf=shelf, user=self.local_user, book=self.book
|
||||
)
|
||||
self.assertEqual(mock.call_count, 1)
|
||||
activity = json.loads(mock.call_args[0][1])
|
||||
activity = json.loads(mock.call_args[1]["args"][1])
|
||||
self.assertEqual(activity["type"], "Add")
|
||||
self.assertEqual(activity["actor"], self.local_user.remote_id)
|
||||
self.assertEqual(activity["object"]["id"], shelf_book.remote_id)
|
||||
self.assertEqual(activity["target"], shelf.remote_id)
|
||||
self.assertEqual(shelf.books.first(), self.book)
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay") as mock:
|
||||
with patch(
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||
) as mock:
|
||||
shelf_book.delete()
|
||||
self.assertEqual(mock.call_count, 1)
|
||||
activity = json.loads(mock.call_args[0][1])
|
||||
activity = json.loads(mock.call_args[1]["args"][1])
|
||||
self.assertEqual(activity["type"], "Remove")
|
||||
self.assertEqual(activity["actor"], self.local_user.remote_id)
|
||||
self.assertEqual(activity["object"]["id"], shelf_book.remote_id)
|
||||
|
|
|
@ -165,12 +165,12 @@ class User(TestCase):
|
|||
"""deactivate a user"""
|
||||
self.assertTrue(self.user.is_active)
|
||||
with patch(
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.delay"
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||
) as broadcast_mock:
|
||||
self.user.delete()
|
||||
|
||||
self.assertEqual(broadcast_mock.call_count, 1)
|
||||
activity = json.loads(broadcast_mock.call_args[0][1])
|
||||
activity = json.loads(broadcast_mock.call_args[1]["args"][1])
|
||||
self.assertEqual(activity["type"], "Delete")
|
||||
self.assertEqual(activity["object"], self.user.remote_id)
|
||||
self.assertFalse(self.user.is_active)
|
||||
|
|
|
@ -5,7 +5,7 @@ from django.test import TestCase
|
|||
from bookwyrm import models
|
||||
|
||||
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
|
||||
class PostgresTriggers(TestCase):
|
||||
"""special migrations, fancy stuff ya know"""
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ from bookwyrm import models
|
|||
from bookwyrm.suggested_users import suggested_users, get_annotated_users
|
||||
|
||||
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
|
||||
@patch("bookwyrm.activitystreams.add_status_task.delay")
|
||||
@patch("bookwyrm.suggested_users.rerank_suggestions_task.delay")
|
||||
@patch("bookwyrm.activitystreams.populate_stream_task.delay")
|
||||
|
@ -168,7 +168,7 @@ class SuggestedUsers(TestCase):
|
|||
remote_id="https://example.com/book/1",
|
||||
parent_work=work,
|
||||
)
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
# 1 shared follow
|
||||
self.local_user.following.add(user_2)
|
||||
user_1.followers.add(user_2)
|
||||
|
@ -213,7 +213,7 @@ class SuggestedUsers(TestCase):
|
|||
user.following.add(user_1)
|
||||
user.followers.add(self.local_user)
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
for i in range(3):
|
||||
book = models.Edition.objects.create(
|
||||
title=i,
|
||||
|
|
|
@ -44,7 +44,7 @@ class TemplateTags(TestCase):
|
|||
|
||||
def test_get_user_rating(self, *_):
|
||||
"""get a user's most recent rating of a book"""
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
models.Review.objects.create(user=self.user, book=self.book, rating=3)
|
||||
self.assertEqual(bookwyrm_tags.get_user_rating(self.book, self.user), 3)
|
||||
|
||||
|
@ -63,7 +63,7 @@ class TemplateTags(TestCase):
|
|||
utilities.get_user_identifier(self.remote_user), "rat@example.com"
|
||||
)
|
||||
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
|
||||
def test_get_replies(self, *_):
|
||||
"""direct replies to a status"""
|
||||
parent = models.Review.objects.create(
|
||||
|
@ -90,7 +90,7 @@ class TemplateTags(TestCase):
|
|||
|
||||
def test_get_parent(self, *_):
|
||||
"""get the reply parent of a status"""
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
parent = models.Review.objects.create(
|
||||
user=self.user, book=self.book, content="hi"
|
||||
)
|
||||
|
@ -107,7 +107,7 @@ class TemplateTags(TestCase):
|
|||
status = models.Review.objects.create(user=self.remote_user, book=self.book)
|
||||
|
||||
self.assertFalse(interaction.get_user_liked(self.user, status))
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
models.Favorite.objects.create(user=self.user, status=status)
|
||||
self.assertTrue(interaction.get_user_liked(self.user, status))
|
||||
|
||||
|
@ -116,13 +116,13 @@ class TemplateTags(TestCase):
|
|||
status = models.Review.objects.create(user=self.remote_user, book=self.book)
|
||||
|
||||
self.assertFalse(interaction.get_user_boosted(self.user, status))
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
models.Boost.objects.create(user=self.user, boosted_status=status)
|
||||
self.assertTrue(interaction.get_user_boosted(self.user, status))
|
||||
|
||||
def test_get_boosted(self, *_):
|
||||
"""load a boosted status"""
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
status = models.Review.objects.create(user=self.remote_user, book=self.book)
|
||||
boost = models.Boost.objects.create(user=self.user, boosted_status=status)
|
||||
boosted = status_display.get_boosted(boost)
|
||||
|
@ -166,7 +166,7 @@ class TemplateTags(TestCase):
|
|||
|
||||
def test_related_status(self, *_):
|
||||
"""gets the subclass model for a notification status"""
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
status = models.Status.objects.create(content="hi", user=self.user)
|
||||
notification = models.Notification.objects.create(
|
||||
user=self.user, notification_type="MENTION", related_status=status
|
||||
|
|
|
@ -151,10 +151,12 @@ class ReportViews(TestCase):
|
|||
request.user.is_superuser = True
|
||||
|
||||
# de-activate
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay") as mock:
|
||||
with patch(
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||
) as mock:
|
||||
views.moderator_delete_user(request, self.rat.id)
|
||||
self.assertEqual(mock.call_count, 1)
|
||||
activity = json.loads(mock.call_args[0][1])
|
||||
activity = json.loads(mock.call_args[1]["args"][1])
|
||||
self.assertEqual(activity["type"], "Delete")
|
||||
|
||||
self.rat.refresh_from_db()
|
||||
|
|
|
@ -67,7 +67,7 @@ class UserAdminViews(TestCase):
|
|||
request.user = self.local_user
|
||||
request.user.is_superuser = True
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
result = view(request, self.local_user.id)
|
||||
|
||||
self.assertIsInstance(result, TemplateResponse)
|
||||
|
|
|
@ -78,7 +78,7 @@ class BookViews(TestCase):
|
|||
self.assertIsInstance(result, ActivitypubResponse)
|
||||
self.assertEqual(result.status_code, 200)
|
||||
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
|
||||
@patch("bookwyrm.activitystreams.add_status_task.delay")
|
||||
def test_book_page_statuses(self, *_):
|
||||
"""there are so many views, this just makes sure it LOADS"""
|
||||
|
@ -169,7 +169,7 @@ class BookViews(TestCase):
|
|||
request.user = self.local_user
|
||||
|
||||
with patch(
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.delay"
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||
) as delay_mock:
|
||||
views.upload_cover(request, self.book.id)
|
||||
self.assertEqual(delay_mock.call_count, 1)
|
||||
|
@ -188,7 +188,7 @@ class BookViews(TestCase):
|
|||
request.user = self.local_user
|
||||
|
||||
with patch(
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.delay"
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||
) as delay_mock:
|
||||
views.upload_cover(request, self.book.id)
|
||||
self.assertEqual(delay_mock.call_count, 1)
|
||||
|
@ -202,7 +202,7 @@ class BookViews(TestCase):
|
|||
request = self.factory.post("", {"description": "new description hi"})
|
||||
request.user = self.local_user
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
views.add_description(request, self.book.id)
|
||||
|
||||
self.book.refresh_from_db()
|
||||
|
|
|
@ -79,7 +79,7 @@ class EditBookViews(TestCase):
|
|||
request = self.factory.post("", form.data)
|
||||
request.user = self.local_user
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
view(request, self.book.id)
|
||||
|
||||
self.book.refresh_from_db()
|
||||
|
@ -115,7 +115,7 @@ class EditBookViews(TestCase):
|
|||
request = self.factory.post("", form.data)
|
||||
request.user = self.local_user
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
view(request, self.book.id)
|
||||
|
||||
self.book.refresh_from_db()
|
||||
|
@ -136,7 +136,7 @@ class EditBookViews(TestCase):
|
|||
request = self.factory.post("", form.data)
|
||||
request.user = self.local_user
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
view(request, self.book.id)
|
||||
self.book.refresh_from_db()
|
||||
self.assertEqual(self.book.title, "New Title")
|
||||
|
@ -207,7 +207,7 @@ class EditBookViews(TestCase):
|
|||
request.user = self.local_user
|
||||
|
||||
with patch(
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.delay"
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||
) as delay_mock:
|
||||
views.upload_cover(request, self.book.id)
|
||||
self.assertEqual(delay_mock.call_count, 1)
|
||||
|
|
|
@ -111,7 +111,7 @@ class BookViews(TestCase):
|
|||
work = models.Work.objects.create(title="test work")
|
||||
edition1 = models.Edition.objects.create(title="first ed", parent_work=work)
|
||||
edition2 = models.Edition.objects.create(title="second ed", parent_work=work)
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
shelf = models.Shelf.objects.create(name="Test Shelf", user=self.local_user)
|
||||
models.ShelfBook.objects.create(
|
||||
book=edition1,
|
||||
|
@ -124,7 +124,7 @@ class BookViews(TestCase):
|
|||
self.assertEqual(models.ReadThrough.objects.get().book, edition1)
|
||||
request = self.factory.post("", {"edition": edition2.id})
|
||||
request.user = self.local_user
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
views.switch_edition(request)
|
||||
|
||||
self.assertEqual(models.ShelfBook.objects.get().book, edition2)
|
||||
|
|
|
@ -36,7 +36,7 @@ class InboxActivities(TestCase):
|
|||
outbox="https://example.com/users/rat/outbox",
|
||||
)
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
with patch("bookwyrm.activitystreams.add_status_task.delay"):
|
||||
self.status = models.Status.objects.create(
|
||||
user=self.local_user,
|
||||
|
|
|
@ -40,7 +40,7 @@ class InboxBlock(TestCase):
|
|||
def test_handle_blocks(self):
|
||||
"""create a "block" database entry from an activity"""
|
||||
self.local_user.followers.add(self.remote_user)
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
models.UserFollowRequest.objects.create(
|
||||
user_subject=self.local_user, user_object=self.remote_user
|
||||
)
|
||||
|
|
|
@ -10,7 +10,7 @@ from bookwyrm.activitypub import ActivitySerializerError
|
|||
|
||||
|
||||
# pylint: disable=too-many-public-methods
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
|
||||
@patch("bookwyrm.activitystreams.add_book_statuses_task.delay")
|
||||
class InboxCreate(TestCase):
|
||||
"""readthrough tests"""
|
||||
|
|
|
@ -49,10 +49,12 @@ class InboxRelationships(TestCase):
|
|||
}
|
||||
|
||||
self.assertFalse(models.UserFollowRequest.objects.exists())
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay") as mock:
|
||||
with patch(
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||
) as mock:
|
||||
views.inbox.activity_task(activity)
|
||||
self.assertEqual(mock.call_count, 1)
|
||||
response_activity = json.loads(mock.call_args[0][1])
|
||||
response_activity = json.loads(mock.call_args[1]["args"][1])
|
||||
self.assertEqual(response_activity["type"], "Accept")
|
||||
|
||||
# notification created
|
||||
|
@ -77,17 +79,19 @@ class InboxRelationships(TestCase):
|
|||
"object": "https://example.com/user/mouse",
|
||||
}
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
views.inbox.activity_task(activity)
|
||||
|
||||
# the follow relationship should exist
|
||||
follow = models.UserFollows.objects.get(user_object=self.local_user)
|
||||
self.assertEqual(follow.user_subject, self.remote_user)
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay") as mock:
|
||||
with patch(
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||
) as mock:
|
||||
views.inbox.activity_task(activity)
|
||||
self.assertEqual(mock.call_count, 1)
|
||||
response_activity = json.loads(mock.call_args[0][1])
|
||||
response_activity = json.loads(mock.call_args[1]["args"][1])
|
||||
self.assertEqual(response_activity["type"], "Accept")
|
||||
|
||||
# the follow relationship should STILL exist
|
||||
|
@ -109,7 +113,7 @@ class InboxRelationships(TestCase):
|
|||
broadcast=False, update_fields=["manually_approves_followers"]
|
||||
)
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
views.inbox.activity_task(activity)
|
||||
|
||||
# notification created
|
||||
|
@ -132,7 +136,7 @@ class InboxRelationships(TestCase):
|
|||
self.local_user.save(
|
||||
broadcast=False, update_fields=["manually_approves_followers"]
|
||||
)
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
request = models.UserFollowRequest.objects.create(
|
||||
user_subject=self.remote_user, user_object=self.local_user
|
||||
)
|
||||
|
@ -160,7 +164,7 @@ class InboxRelationships(TestCase):
|
|||
|
||||
def test_unfollow(self):
|
||||
"""remove a relationship"""
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
rel = models.UserFollows.objects.create(
|
||||
user_subject=self.remote_user, user_object=self.local_user
|
||||
)
|
||||
|
@ -186,7 +190,7 @@ class InboxRelationships(TestCase):
|
|||
@patch("bookwyrm.activitystreams.add_user_statuses_task.delay")
|
||||
def test_follow_accept(self, _):
|
||||
"""a remote user approved a follow request from local"""
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
rel = models.UserFollowRequest.objects.create(
|
||||
user_subject=self.local_user, user_object=self.remote_user
|
||||
)
|
||||
|
@ -217,7 +221,7 @@ class InboxRelationships(TestCase):
|
|||
|
||||
def test_follow_reject(self):
|
||||
"""turn down a follow request"""
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
rel = models.UserFollowRequest.objects.create(
|
||||
user_subject=self.local_user, user_object=self.remote_user
|
||||
)
|
||||
|
|
|
@ -35,7 +35,7 @@ class InboxActivities(TestCase):
|
|||
outbox="https://example.com/users/rat/outbox",
|
||||
)
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
with patch("bookwyrm.activitystreams.add_status_task.delay"):
|
||||
self.status = models.Status.objects.create(
|
||||
user=self.local_user,
|
||||
|
|
|
@ -75,7 +75,7 @@ class InboxRemove(TestCase):
|
|||
|
||||
def test_handle_remove_book_from_list(self):
|
||||
"""listing a book"""
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
booklist = models.List.objects.create(
|
||||
name="test list",
|
||||
user=self.local_user,
|
||||
|
|
|
@ -50,7 +50,7 @@ class InboxUpdate(TestCase):
|
|||
|
||||
def test_update_list(self):
|
||||
"""a new list"""
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
book_list = models.List.objects.create(
|
||||
name="hi", remote_id="https://example.com/list/22", user=self.local_user
|
||||
)
|
||||
|
@ -171,7 +171,7 @@ class InboxUpdate(TestCase):
|
|||
book = models.Work.objects.get(id=book.id)
|
||||
self.assertEqual(book.title, "Piranesi")
|
||||
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
|
||||
@patch("bookwyrm.activitystreams.add_status_task.delay")
|
||||
def test_update_status(self, *_):
|
||||
"""edit a status"""
|
||||
|
|
|
@ -9,7 +9,7 @@ from bookwyrm import models, views
|
|||
from bookwyrm.tests.validate_html import validate_html
|
||||
|
||||
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
|
||||
class BlockViews(TestCase):
|
||||
"""view user and edit profile"""
|
||||
|
||||
|
|
|
@ -35,9 +35,9 @@ class DeleteUserViews(TestCase):
|
|||
self.book = models.Edition.objects.create(
|
||||
title="test", parent_work=models.Work.objects.create(title="test work")
|
||||
)
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.add_book_statuses_task.delay"
|
||||
):
|
||||
with patch(
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||
), patch("bookwyrm.activitystreams.add_book_statuses_task.delay"):
|
||||
models.ShelfBook.objects.create(
|
||||
book=self.book,
|
||||
user=self.local_user,
|
||||
|
@ -70,11 +70,11 @@ class DeleteUserViews(TestCase):
|
|||
|
||||
self.assertIsNone(self.local_user.name)
|
||||
with patch(
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.delay"
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||
) as delay_mock:
|
||||
view(request)
|
||||
self.assertEqual(delay_mock.call_count, 1)
|
||||
activity = json.loads(delay_mock.call_args[0][1])
|
||||
activity = json.loads(delay_mock.call_args[1]["args"][1])
|
||||
self.assertEqual(activity["type"], "Delete")
|
||||
self.assertEqual(activity["actor"], self.local_user.remote_id)
|
||||
self.assertEqual(
|
||||
|
|
|
@ -38,9 +38,9 @@ class EditUserViews(TestCase):
|
|||
self.book = models.Edition.objects.create(
|
||||
title="test", parent_work=models.Work.objects.create(title="test work")
|
||||
)
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.add_book_statuses_task.delay"
|
||||
):
|
||||
with patch(
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||
), patch("bookwyrm.activitystreams.add_book_statuses_task.delay"):
|
||||
models.ShelfBook.objects.create(
|
||||
book=self.book,
|
||||
user=self.local_user,
|
||||
|
@ -74,7 +74,7 @@ class EditUserViews(TestCase):
|
|||
|
||||
self.assertIsNone(self.local_user.name)
|
||||
with patch(
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.delay"
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||
) as delay_mock:
|
||||
view(request)
|
||||
self.assertEqual(delay_mock.call_count, 1)
|
||||
|
@ -100,7 +100,7 @@ class EditUserViews(TestCase):
|
|||
request.user = self.local_user
|
||||
|
||||
with patch(
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.delay"
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||
) as delay_mock:
|
||||
view(request)
|
||||
self.assertEqual(delay_mock.call_count, 1)
|
||||
|
|
|
@ -11,7 +11,7 @@ from bookwyrm.activitypub import ActivitypubResponse
|
|||
from bookwyrm.tests.validate_html import validate_html
|
||||
|
||||
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
|
||||
@patch("bookwyrm.suggested_users.rerank_suggestions_task.delay")
|
||||
@patch("bookwyrm.activitystreams.populate_stream_task.delay")
|
||||
@patch("bookwyrm.activitystreams.add_book_statuses_task.delay")
|
||||
|
@ -39,7 +39,7 @@ class ShelfViews(TestCase):
|
|||
remote_id="https://example.com/book/1",
|
||||
parent_work=self.work,
|
||||
)
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
self.shelf = models.Shelf.objects.create(
|
||||
name="Test Shelf", identifier="test-shelf", user=self.local_user
|
||||
)
|
||||
|
@ -142,7 +142,7 @@ class ShelfViews(TestCase):
|
|||
"", {"privacy": "public", "user": self.local_user.id, "name": "cool name"}
|
||||
)
|
||||
request.user = self.local_user
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
view(request, request.user.username, shelf.identifier)
|
||||
shelf.refresh_from_db()
|
||||
|
||||
|
@ -159,7 +159,7 @@ class ShelfViews(TestCase):
|
|||
"", {"privacy": "public", "user": self.local_user.id, "name": "cool name"}
|
||||
)
|
||||
request.user = self.local_user
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
view(request, request.user.username, shelf.identifier)
|
||||
|
||||
self.assertEqual(shelf.name, "To Read")
|
||||
|
|
|
@ -9,7 +9,7 @@ from django.test.client import RequestFactory
|
|||
from bookwyrm import forms, models, views
|
||||
|
||||
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
|
||||
@patch("bookwyrm.suggested_users.rerank_suggestions_task.delay")
|
||||
@patch("bookwyrm.activitystreams.populate_stream_task.delay")
|
||||
@patch("bookwyrm.activitystreams.add_book_statuses_task.delay")
|
||||
|
@ -37,7 +37,7 @@ class ShelfActionViews(TestCase):
|
|||
remote_id="https://example.com/book/1",
|
||||
parent_work=self.work,
|
||||
)
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
self.shelf = models.Shelf.objects.create(
|
||||
name="Test Shelf", identifier="test-shelf", user=self.local_user
|
||||
)
|
||||
|
@ -49,11 +49,13 @@ class ShelfActionViews(TestCase):
|
|||
"", {"book": self.book.id, "shelf": self.shelf.identifier}
|
||||
)
|
||||
request.user = self.local_user
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay") as mock:
|
||||
with patch(
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||
) as mock:
|
||||
views.shelve(request)
|
||||
|
||||
self.assertEqual(mock.call_count, 1)
|
||||
activity = json.loads(mock.call_args[0][1])
|
||||
activity = json.loads(mock.call_args[1]["args"][1])
|
||||
self.assertEqual(activity["type"], "Add")
|
||||
|
||||
item = models.ShelfBook.objects.get()
|
||||
|
@ -69,7 +71,7 @@ class ShelfActionViews(TestCase):
|
|||
)
|
||||
request.user = self.local_user
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
views.shelve(request)
|
||||
# make sure the book is on the shelf
|
||||
self.assertEqual(shelf.books.get(), self.book)
|
||||
|
@ -82,7 +84,7 @@ class ShelfActionViews(TestCase):
|
|||
)
|
||||
request.user = self.local_user
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
views.shelve(request)
|
||||
# make sure the book is on the shelf
|
||||
self.assertEqual(shelf.books.get(), self.book)
|
||||
|
@ -95,7 +97,7 @@ class ShelfActionViews(TestCase):
|
|||
)
|
||||
request.user = self.local_user
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
views.shelve(request)
|
||||
# make sure the book is on the shelf
|
||||
self.assertEqual(shelf.books.get(), self.book)
|
||||
|
@ -118,7 +120,7 @@ class ShelfActionViews(TestCase):
|
|||
)
|
||||
request.user = self.local_user
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
views.shelve(request)
|
||||
# make sure the book is on the shelf
|
||||
self.assertEqual(shelf.books.get(), self.book)
|
||||
|
@ -126,7 +128,7 @@ class ShelfActionViews(TestCase):
|
|||
|
||||
def test_unshelve(self, *_):
|
||||
"""remove a book from a shelf"""
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
models.ShelfBook.objects.create(
|
||||
book=self.book, user=self.local_user, shelf=self.shelf
|
||||
)
|
||||
|
@ -136,9 +138,11 @@ class ShelfActionViews(TestCase):
|
|||
self.assertEqual(self.shelf.books.count(), 1)
|
||||
request = self.factory.post("", {"book": self.book.id, "shelf": self.shelf.id})
|
||||
request.user = self.local_user
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay") as mock:
|
||||
with patch(
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||
) as mock:
|
||||
views.unshelve(request)
|
||||
activity = json.loads(mock.call_args[0][1])
|
||||
activity = json.loads(mock.call_args[1]["args"][1])
|
||||
self.assertEqual(activity["type"], "Remove")
|
||||
self.assertEqual(activity["object"]["id"], item.remote_id)
|
||||
self.assertEqual(self.shelf.books.count(), 0)
|
||||
|
@ -192,7 +196,7 @@ class ShelfActionViews(TestCase):
|
|||
|
||||
def test_delete_shelf_has_book(self, *_):
|
||||
"""delete a brand new custom shelf"""
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
models.ShelfBook.objects.create(
|
||||
book=self.book, user=self.local_user, shelf=self.shelf
|
||||
)
|
||||
|
|
|
@ -111,7 +111,7 @@ class AuthorViews(TestCase):
|
|||
request = self.factory.post("", form.data)
|
||||
request.user = self.local_user
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
view(request, author.id)
|
||||
author.refresh_from_db()
|
||||
self.assertEqual(author.name, "New Name")
|
||||
|
|
|
@ -41,7 +41,7 @@ class DiscoverViews(TestCase):
|
|||
self.assertEqual(result.status_code, 200)
|
||||
result.render()
|
||||
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
|
||||
@patch("bookwyrm.activitystreams.add_status_task.delay")
|
||||
def test_discover_page(self, *_):
|
||||
"""there are so many views, this just makes sure it LOADS"""
|
||||
|
|
|
@ -57,7 +57,7 @@ class FeedViews(TestCase):
|
|||
def test_status_page(self, *_):
|
||||
"""there are so many views, this just makes sure it LOADS"""
|
||||
view = views.Status.as_view()
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
status = models.Status.objects.create(content="hi", user=self.local_user)
|
||||
request = self.factory.get("")
|
||||
request.user = self.local_user
|
||||
|
@ -95,7 +95,7 @@ class FeedViews(TestCase):
|
|||
local=True,
|
||||
localname="rat",
|
||||
)
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
status = models.Status.objects.create(content="hi", user=another_user)
|
||||
|
||||
request = self.factory.get("")
|
||||
|
@ -115,7 +115,7 @@ class FeedViews(TestCase):
|
|||
image = Image.open(image_file)
|
||||
output = BytesIO()
|
||||
image.save(output, format=image.format)
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
status = models.Review.objects.create(
|
||||
content="hi",
|
||||
user=self.local_user,
|
||||
|
@ -144,7 +144,7 @@ class FeedViews(TestCase):
|
|||
def test_replies_page(self, *_):
|
||||
"""there are so many views, this just makes sure it LOADS"""
|
||||
view = views.Replies.as_view()
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
status = models.Status.objects.create(content="hi", user=self.local_user)
|
||||
request = self.factory.get("")
|
||||
request.user = self.local_user
|
||||
|
@ -171,7 +171,7 @@ class FeedViews(TestCase):
|
|||
result.render()
|
||||
self.assertEqual(result.status_code, 200)
|
||||
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
|
||||
@patch("bookwyrm.activitystreams.add_book_statuses_task.delay")
|
||||
def test_get_suggested_book(self, *_):
|
||||
"""gets books the ~*~ algorithm ~*~ thinks you want to post about"""
|
||||
|
|
|
@ -59,7 +59,7 @@ class FollowViews(TestCase):
|
|||
request.user = self.local_user
|
||||
self.assertEqual(models.UserFollowRequest.objects.count(), 0)
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
views.follow(request)
|
||||
|
||||
rel = models.UserFollowRequest.objects.get()
|
||||
|
@ -86,7 +86,7 @@ class FollowViews(TestCase):
|
|||
request.user = self.local_user
|
||||
self.assertEqual(models.UserFollowRequest.objects.count(), 0)
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
views.follow(request)
|
||||
rel = models.UserFollowRequest.objects.get()
|
||||
|
||||
|
@ -111,7 +111,7 @@ class FollowViews(TestCase):
|
|||
request.user = self.local_user
|
||||
self.assertEqual(models.UserFollowRequest.objects.count(), 0)
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
views.follow(request)
|
||||
|
||||
rel = models.UserFollows.objects.get()
|
||||
|
@ -127,10 +127,12 @@ class FollowViews(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.models.activitypub_mixin.broadcast_task.delay") as mock:
|
||||
with patch(
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||
) as mock:
|
||||
views.unfollow(request)
|
||||
self.assertEqual(mock.call_count, 1)
|
||||
activity = json.loads(mock.call_args_list[0][0][1])
|
||||
activity = json.loads(mock.call_args_list[0][1]["args"][1])
|
||||
self.assertEqual(activity["type"], "Undo")
|
||||
|
||||
self.assertEqual(self.remote_user.followers.count(), 0)
|
||||
|
@ -147,7 +149,7 @@ class FollowViews(TestCase):
|
|||
user_subject=self.remote_user, user_object=self.local_user
|
||||
)
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
views.accept_follow_request(request)
|
||||
# request should be deleted
|
||||
self.assertEqual(models.UserFollowRequest.objects.filter(id=rel.id).count(), 0)
|
||||
|
@ -166,7 +168,7 @@ class FollowViews(TestCase):
|
|||
user_subject=self.remote_user, user_object=self.local_user
|
||||
)
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
views.delete_follow_request(request)
|
||||
# request should be deleted
|
||||
self.assertEqual(models.UserFollowRequest.objects.filter(id=rel.id).count(), 0)
|
||||
|
|
|
@ -56,7 +56,7 @@ class GetStartedViews(TestCase):
|
|||
|
||||
self.assertIsNone(self.local_user.name)
|
||||
with patch(
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.delay"
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||
) as delay_mock:
|
||||
view(request)
|
||||
self.assertEqual(delay_mock.call_count, 1)
|
||||
|
@ -98,7 +98,7 @@ class GetStartedViews(TestCase):
|
|||
|
||||
self.assertFalse(self.local_user.shelfbook_set.exists())
|
||||
with patch(
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.delay"
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||
) as delay_mock:
|
||||
view(request)
|
||||
self.assertEqual(delay_mock.call_count, 1)
|
||||
|
|
|
@ -123,7 +123,7 @@ class GoalViews(TestCase):
|
|||
},
|
||||
)
|
||||
request.user = self.local_user
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
view(request, self.local_user.localname, self.year)
|
||||
|
||||
goal = models.AnnualGoal.objects.get()
|
||||
|
|
|
@ -10,7 +10,7 @@ from bookwyrm import models, views, forms
|
|||
from bookwyrm.tests.validate_html import validate_html
|
||||
|
||||
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
|
||||
class GroupViews(TestCase):
|
||||
"""view group and edit details"""
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ class ViewsHelpers(TestCase):
|
|||
datafile = pathlib.Path(__file__).parent.joinpath("../data/ap_user.json")
|
||||
self.userdata = json.loads(datafile.read_bytes())
|
||||
del self.userdata["icon"]
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
self.shelf = models.Shelf.objects.create(
|
||||
name="Test Shelf", identifier="test-shelf", user=self.local_user
|
||||
)
|
||||
|
@ -166,7 +166,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.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
views.helpers.handle_reading_status(
|
||||
self.local_user, shelf, self.book, "public"
|
||||
)
|
||||
|
@ -178,7 +178,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.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
views.helpers.handle_reading_status(
|
||||
self.local_user, shelf, self.book, "public"
|
||||
)
|
||||
|
@ -190,7 +190,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.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
views.helpers.handle_reading_status(
|
||||
self.local_user, shelf, self.book, "public"
|
||||
)
|
||||
|
@ -201,7 +201,7 @@ class ViewsHelpers(TestCase):
|
|||
|
||||
def test_handle_reading_status_other(self, *_):
|
||||
"""posts shelve activities"""
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
views.helpers.handle_reading_status(
|
||||
self.local_user, self.shelf, self.book, "public"
|
||||
)
|
||||
|
|
|
@ -7,7 +7,7 @@ from django.test.client import RequestFactory
|
|||
from bookwyrm import models, views
|
||||
|
||||
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
|
||||
@patch("bookwyrm.activitystreams.remove_status_task.delay")
|
||||
class InteractionViews(TestCase):
|
||||
"""viewing and creating statuses"""
|
||||
|
@ -74,7 +74,7 @@ class InteractionViews(TestCase):
|
|||
self.assertEqual(models.Favorite.objects.count(), 1)
|
||||
self.assertEqual(models.Notification.objects.count(), 1)
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
view(request, status.id)
|
||||
self.assertEqual(models.Favorite.objects.count(), 0)
|
||||
self.assertEqual(models.Notification.objects.count(), 0)
|
||||
|
@ -110,12 +110,12 @@ class InteractionViews(TestCase):
|
|||
status = models.Status.objects.create(user=self.local_user, content="hi")
|
||||
|
||||
with patch(
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.delay"
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||
) as broadcast_mock:
|
||||
view(request, status.id)
|
||||
|
||||
self.assertEqual(broadcast_mock.call_count, 1)
|
||||
activity = json.loads(broadcast_mock.call_args[0][1])
|
||||
activity = json.loads(broadcast_mock.call_args[1]["args"][1])
|
||||
self.assertEqual(activity["type"], "Announce")
|
||||
|
||||
boost = models.Boost.objects.get()
|
||||
|
|
|
@ -61,7 +61,7 @@ class ListViews(TestCase):
|
|||
parent_work=work_four,
|
||||
)
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
self.list = models.List.objects.create(
|
||||
name="Test List", user=self.local_user
|
||||
)
|
||||
|
@ -73,7 +73,7 @@ class ListViews(TestCase):
|
|||
def test_lists_page(self):
|
||||
"""there are so many views, this just makes sure it LOADS"""
|
||||
view = views.Lists.as_view()
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
models.List.objects.create(name="Public list", user=self.local_user)
|
||||
models.List.objects.create(
|
||||
name="Private list", privacy="direct", user=self.local_user
|
||||
|
@ -96,7 +96,7 @@ class ListViews(TestCase):
|
|||
def test_saved_lists_page(self):
|
||||
"""there are so many views, this just makes sure it LOADS"""
|
||||
view = views.SavedLists.as_view()
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
booklist = models.List.objects.create(
|
||||
name="Public list", user=self.local_user
|
||||
)
|
||||
|
@ -116,7 +116,7 @@ class ListViews(TestCase):
|
|||
def test_saved_lists_page_empty(self):
|
||||
"""there are so many views, this just makes sure it LOADS"""
|
||||
view = views.SavedLists.as_view()
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
models.List.objects.create(name="Public list", user=self.local_user)
|
||||
models.List.objects.create(
|
||||
name="Private list", privacy="direct", user=self.local_user
|
||||
|
@ -153,11 +153,13 @@ class ListViews(TestCase):
|
|||
},
|
||||
)
|
||||
request.user = self.local_user
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay") as mock:
|
||||
with patch(
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||
) as mock:
|
||||
result = view(request)
|
||||
|
||||
self.assertEqual(mock.call_count, 1)
|
||||
activity = json.loads(mock.call_args[0][1])
|
||||
activity = json.loads(mock.call_args[1]["args"][1])
|
||||
self.assertEqual(activity["type"], "Create")
|
||||
self.assertEqual(activity["actor"], self.local_user.remote_id)
|
||||
|
||||
|
@ -172,7 +174,7 @@ class ListViews(TestCase):
|
|||
view = views.List.as_view()
|
||||
request = self.factory.get("")
|
||||
request.user = self.local_user
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
models.ListItem.objects.create(
|
||||
book_list=self.list,
|
||||
user=self.local_user,
|
||||
|
@ -191,7 +193,7 @@ class ListViews(TestCase):
|
|||
def test_list_page_sorted(self):
|
||||
"""there are so many views, this just makes sure it LOADS"""
|
||||
view = views.List.as_view()
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
for (i, book) in enumerate([self.book, self.book_two, self.book_three]):
|
||||
models.ListItem.objects.create(
|
||||
book_list=self.list,
|
||||
|
@ -253,7 +255,7 @@ class ListViews(TestCase):
|
|||
def test_list_page_logged_out(self):
|
||||
"""there are so many views, this just makes sure it LOADS"""
|
||||
view = views.List.as_view()
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
models.ListItem.objects.create(
|
||||
book_list=self.list,
|
||||
user=self.local_user,
|
||||
|
@ -276,7 +278,7 @@ class ListViews(TestCase):
|
|||
view = views.List.as_view()
|
||||
request = self.factory.get("")
|
||||
request.user = self.local_user
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
models.ListItem.objects.create(
|
||||
book_list=self.list,
|
||||
user=self.local_user,
|
||||
|
@ -320,11 +322,13 @@ class ListViews(TestCase):
|
|||
)
|
||||
request.user = self.local_user
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay") as mock:
|
||||
with patch(
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||
) as mock:
|
||||
result = view(request, self.list.id)
|
||||
|
||||
self.assertEqual(mock.call_count, 1)
|
||||
activity = json.loads(mock.call_args[0][1])
|
||||
activity = json.loads(mock.call_args[1]["args"][1])
|
||||
self.assertEqual(activity["type"], "Update")
|
||||
self.assertEqual(activity["actor"], self.local_user.remote_id)
|
||||
self.assertEqual(activity["object"]["id"], self.list.remote_id)
|
||||
|
@ -340,7 +344,7 @@ class ListViews(TestCase):
|
|||
def test_curate_page(self):
|
||||
"""there are so many views, this just makes sure it LOADS"""
|
||||
view = views.Curate.as_view()
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
models.List.objects.create(name="Public list", user=self.local_user)
|
||||
models.List.objects.create(
|
||||
name="Private list", privacy="direct", user=self.local_user
|
||||
|
@ -360,7 +364,7 @@ class ListViews(TestCase):
|
|||
def test_user_lists_page(self):
|
||||
"""there are so many views, this just makes sure it LOADS"""
|
||||
view = views.UserLists.as_view()
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
models.List.objects.create(name="Public list", user=self.local_user)
|
||||
models.List.objects.create(
|
||||
name="Private list", privacy="direct", user=self.local_user
|
||||
|
|
|
@ -61,7 +61,7 @@ class ListActionViews(TestCase):
|
|||
parent_work=work_four,
|
||||
)
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
self.list = models.List.objects.create(
|
||||
name="Test List", user=self.local_user
|
||||
)
|
||||
|
@ -71,7 +71,7 @@ class ListActionViews(TestCase):
|
|||
|
||||
def test_delete_list(self):
|
||||
"""delete an entire list"""
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
models.ListItem.objects.create(
|
||||
book_list=self.list,
|
||||
user=self.local_user,
|
||||
|
@ -88,9 +88,11 @@ class ListActionViews(TestCase):
|
|||
)
|
||||
request = self.factory.post("")
|
||||
request.user = self.local_user
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay") as mock:
|
||||
with patch(
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||
) as mock:
|
||||
views.delete_list(request, self.list.id)
|
||||
activity = json.loads(mock.call_args[0][1])
|
||||
activity = json.loads(mock.call_args[1]["args"][1])
|
||||
self.assertEqual(activity["type"], "Delete")
|
||||
self.assertEqual(activity["actor"], self.local_user.remote_id)
|
||||
self.assertEqual(activity["object"]["id"], self.list.remote_id)
|
||||
|
@ -110,7 +112,7 @@ class ListActionViews(TestCase):
|
|||
def test_curate_approve(self):
|
||||
"""approve a pending item"""
|
||||
view = views.Curate.as_view()
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
pending = models.ListItem.objects.create(
|
||||
book_list=self.list,
|
||||
user=self.local_user,
|
||||
|
@ -128,11 +130,13 @@ class ListActionViews(TestCase):
|
|||
)
|
||||
request.user = self.local_user
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay") as mock:
|
||||
with patch(
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||
) as mock:
|
||||
view(request, self.list.id)
|
||||
|
||||
self.assertEqual(mock.call_count, 2)
|
||||
activity = json.loads(mock.call_args[0][1])
|
||||
activity = json.loads(mock.call_args[1]["args"][1])
|
||||
self.assertEqual(activity["type"], "Add")
|
||||
self.assertEqual(activity["actor"], self.local_user.remote_id)
|
||||
self.assertEqual(activity["target"], self.list.remote_id)
|
||||
|
@ -145,7 +149,7 @@ class ListActionViews(TestCase):
|
|||
def test_curate_reject(self):
|
||||
"""approve a pending item"""
|
||||
view = views.Curate.as_view()
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
pending = models.ListItem.objects.create(
|
||||
book_list=self.list,
|
||||
user=self.local_user,
|
||||
|
@ -179,10 +183,12 @@ class ListActionViews(TestCase):
|
|||
)
|
||||
request.user = self.local_user
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay") as mock:
|
||||
with patch(
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||
) as mock:
|
||||
views.list.add_book(request)
|
||||
self.assertEqual(mock.call_count, 1)
|
||||
activity = json.loads(mock.call_args[0][1])
|
||||
activity = json.loads(mock.call_args[1]["args"][1])
|
||||
self.assertEqual(activity["type"], "Add")
|
||||
self.assertEqual(activity["actor"], self.local_user.remote_id)
|
||||
self.assertEqual(activity["target"], self.list.remote_id)
|
||||
|
@ -214,7 +220,7 @@ class ListActionViews(TestCase):
|
|||
},
|
||||
)
|
||||
request_two.user = self.local_user
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
views.list.add_book(request_one)
|
||||
views.list.add_book(request_two)
|
||||
|
||||
|
@ -256,7 +262,7 @@ class ListActionViews(TestCase):
|
|||
)
|
||||
request_three.user = self.local_user
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
views.list.add_book(request_one)
|
||||
views.list.add_book(request_two)
|
||||
views.list.add_book(request_three)
|
||||
|
@ -271,7 +277,7 @@ class ListActionViews(TestCase):
|
|||
|
||||
remove_request = self.factory.post("", {"item": items[1].id})
|
||||
remove_request.user = self.local_user
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
views.list.remove_book(remove_request, self.list.id)
|
||||
items = self.list.listitem_set.order_by("order").all()
|
||||
self.assertEqual(items[0].book, self.book)
|
||||
|
@ -293,7 +299,7 @@ class ListActionViews(TestCase):
|
|||
},
|
||||
)
|
||||
request.user = self.local_user
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
models.ListItem.objects.create(
|
||||
book_list=self.list,
|
||||
user=self.local_user,
|
||||
|
@ -330,7 +336,7 @@ class ListActionViews(TestCase):
|
|||
its order should be at the end of the approved books and before the
|
||||
remaining pending books.
|
||||
"""
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
models.ListItem.objects.create(
|
||||
book_list=self.list,
|
||||
user=self.local_user,
|
||||
|
@ -370,7 +376,7 @@ class ListActionViews(TestCase):
|
|||
)
|
||||
request.user = self.local_user
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
view(request, self.list.id)
|
||||
|
||||
items = self.list.listitem_set.order_by("order").all()
|
||||
|
@ -422,7 +428,7 @@ class ListActionViews(TestCase):
|
|||
)
|
||||
request_three.user = self.local_user
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
views.list.add_book(request_one)
|
||||
views.list.add_book(request_two)
|
||||
views.list.add_book(request_three)
|
||||
|
@ -437,7 +443,7 @@ class ListActionViews(TestCase):
|
|||
|
||||
set_position_request = self.factory.post("", {"position": 1})
|
||||
set_position_request.user = self.local_user
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
views.list.set_book_position(set_position_request, items[2].id)
|
||||
items = self.list.listitem_set.order_by("order").all()
|
||||
self.assertEqual(items[0].book, self.book_three)
|
||||
|
@ -460,10 +466,12 @@ class ListActionViews(TestCase):
|
|||
)
|
||||
request.user = self.rat
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay") as mock:
|
||||
with patch(
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||
) as mock:
|
||||
views.list.add_book(request)
|
||||
self.assertEqual(mock.call_count, 1)
|
||||
activity = json.loads(mock.call_args[0][1])
|
||||
activity = json.loads(mock.call_args[1]["args"][1])
|
||||
self.assertEqual(activity["type"], "Add")
|
||||
self.assertEqual(activity["actor"], self.rat.remote_id)
|
||||
self.assertEqual(activity["target"], self.list.remote_id)
|
||||
|
@ -486,11 +494,13 @@ class ListActionViews(TestCase):
|
|||
)
|
||||
request.user = self.rat
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay") as mock:
|
||||
with patch(
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||
) as mock:
|
||||
views.list.add_book(request)
|
||||
|
||||
self.assertEqual(mock.call_count, 1)
|
||||
activity = json.loads(mock.call_args[0][1])
|
||||
activity = json.loads(mock.call_args[1]["args"][1])
|
||||
|
||||
self.assertEqual(activity["type"], "Add")
|
||||
self.assertEqual(activity["actor"], self.rat.remote_id)
|
||||
|
@ -516,10 +526,12 @@ class ListActionViews(TestCase):
|
|||
)
|
||||
request.user = self.local_user
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay") as mock:
|
||||
with patch(
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||
) as mock:
|
||||
views.list.add_book(request)
|
||||
self.assertEqual(mock.call_count, 1)
|
||||
activity = json.loads(mock.call_args[0][1])
|
||||
activity = json.loads(mock.call_args[1]["args"][1])
|
||||
self.assertEqual(activity["type"], "Add")
|
||||
self.assertEqual(activity["actor"], self.local_user.remote_id)
|
||||
self.assertEqual(activity["target"], self.list.remote_id)
|
||||
|
@ -532,7 +544,7 @@ class ListActionViews(TestCase):
|
|||
def test_remove_book(self):
|
||||
"""take an item off a list"""
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
item = models.ListItem.objects.create(
|
||||
book_list=self.list,
|
||||
user=self.local_user,
|
||||
|
@ -549,13 +561,13 @@ class ListActionViews(TestCase):
|
|||
)
|
||||
request.user = self.local_user
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
views.list.remove_book(request, self.list.id)
|
||||
self.assertFalse(self.list.listitem_set.exists())
|
||||
|
||||
def test_remove_book_unauthorized(self):
|
||||
"""take an item off a list"""
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
item = models.ListItem.objects.create(
|
||||
book_list=self.list, user=self.local_user, book=self.book, order=1
|
||||
)
|
||||
|
|
|
@ -25,7 +25,7 @@ class NotificationViews(TestCase):
|
|||
local=True,
|
||||
localname="mouse",
|
||||
)
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
self.status = models.Status.objects.create(
|
||||
content="hi",
|
||||
user=self.local_user,
|
||||
|
|
|
@ -11,7 +11,7 @@ from bookwyrm.settings import USER_AGENT
|
|||
|
||||
|
||||
# pylint: disable=too-many-public-methods
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
|
||||
class OutboxView(TestCase):
|
||||
"""sends out activities"""
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ class ReadingViews(TestCase):
|
|||
},
|
||||
)
|
||||
request.user = self.local_user
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
views.ReadingStatus.as_view()(request, "start", self.book.id)
|
||||
|
||||
self.assertEqual(shelf.books.get(), self.book)
|
||||
|
@ -100,7 +100,7 @@ class ReadingViews(TestCase):
|
|||
},
|
||||
)
|
||||
request.user = self.local_user
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
views.ReadingStatus.as_view()(request, "start", self.book.id)
|
||||
|
||||
self.assertEqual(shelf.books.get(), self.book)
|
||||
|
@ -124,7 +124,7 @@ class ReadingViews(TestCase):
|
|||
def test_start_reading_reshelve(self, *_):
|
||||
"""begin a book"""
|
||||
to_read_shelf = self.local_user.shelf_set.get(identifier=models.Shelf.TO_READ)
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
models.ShelfBook.objects.create(
|
||||
shelf=to_read_shelf, book=self.book, user=self.local_user
|
||||
)
|
||||
|
@ -135,7 +135,7 @@ class ReadingViews(TestCase):
|
|||
|
||||
request = self.factory.post("")
|
||||
request.user = self.local_user
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
views.ReadingStatus.as_view()(request, "start", self.book.id)
|
||||
|
||||
self.assertFalse(to_read_shelf.books.exists())
|
||||
|
@ -162,7 +162,7 @@ class ReadingViews(TestCase):
|
|||
)
|
||||
request.user = self.local_user
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
views.ReadingStatus.as_view()(request, "finish", self.book.id)
|
||||
|
||||
self.assertEqual(shelf.books.get(), self.book)
|
||||
|
@ -267,7 +267,7 @@ class ReadingViews(TestCase):
|
|||
},
|
||||
)
|
||||
request.user = self.local_user
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
views.update_progress(request, self.book.id)
|
||||
|
||||
status = models.Comment.objects.get()
|
||||
|
|
|
@ -9,7 +9,7 @@ from bookwyrm import models
|
|||
|
||||
@patch("bookwyrm.suggested_users.rerank_suggestions_task.delay")
|
||||
@patch("bookwyrm.activitystreams.populate_stream_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
|
||||
@patch("bookwyrm.activitystreams.add_book_statuses_task.delay")
|
||||
@patch("bookwyrm.activitystreams.remove_book_statuses_task.delay")
|
||||
class ReadThrough(TestCase):
|
||||
|
@ -32,7 +32,7 @@ class ReadThrough(TestCase):
|
|||
"cinco", "cinco@example.com", "seissiete", local=True, localname="cinco"
|
||||
)
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
self.client.force_login(self.user)
|
||||
|
||||
@patch("bookwyrm.activitystreams.remove_user_statuses_task.delay")
|
||||
|
|
|
@ -6,7 +6,7 @@ from bookwyrm import models
|
|||
from bookwyrm.views import rss_feed
|
||||
|
||||
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
|
||||
@patch("bookwyrm.activitystreams.ActivityStream.get_activity_stream")
|
||||
@patch("bookwyrm.activitystreams.add_status_task.delay")
|
||||
class RssFeedView(TestCase):
|
||||
|
|
|
@ -139,7 +139,7 @@ class Views(TestCase):
|
|||
|
||||
def test_search_lists(self):
|
||||
"""searches remote connectors"""
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
booklist = models.List.objects.create(
|
||||
user=self.local_user, name="test list"
|
||||
)
|
||||
|
|
|
@ -14,7 +14,7 @@ from bookwyrm.tests.validate_html import validate_html
|
|||
@patch("bookwyrm.suggested_users.rerank_suggestions_task.delay")
|
||||
@patch("bookwyrm.activitystreams.populate_stream_task.delay")
|
||||
@patch("bookwyrm.activitystreams.remove_status_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
|
||||
class StatusViews(TestCase):
|
||||
"""viewing and creating statuses"""
|
||||
|
||||
|
@ -310,7 +310,7 @@ http://www.fish.com/"""
|
|||
with patch("bookwyrm.activitystreams.remove_status_task.delay") as redis_mock:
|
||||
view(request, status.id)
|
||||
self.assertTrue(redis_mock.called)
|
||||
activity = json.loads(mock.call_args_list[1][0][1])
|
||||
activity = json.loads(mock.call_args_list[1][1]["args"][1])
|
||||
self.assertEqual(activity["type"], "Delete")
|
||||
self.assertEqual(activity["object"]["type"], "Tombstone")
|
||||
status.refresh_from_db()
|
||||
|
@ -344,7 +344,7 @@ http://www.fish.com/"""
|
|||
with patch("bookwyrm.activitystreams.remove_status_task.delay") as redis_mock:
|
||||
view(request, status.id)
|
||||
self.assertTrue(redis_mock.called)
|
||||
activity = json.loads(mock.call_args_list[1][0][1])
|
||||
activity = json.loads(mock.call_args_list[1][1]["args"][1])
|
||||
self.assertEqual(activity["type"], "Delete")
|
||||
self.assertEqual(activity["object"]["type"], "Tombstone")
|
||||
status.refresh_from_db()
|
||||
|
@ -396,7 +396,7 @@ http://www.fish.com/"""
|
|||
request.user = self.local_user
|
||||
|
||||
view(request, "comment", existing_status_id=status.id)
|
||||
activity = json.loads(mock.call_args_list[1][0][1])
|
||||
activity = json.loads(mock.call_args_list[1][1]["args"][1])
|
||||
self.assertEqual(activity["type"], "Update")
|
||||
self.assertEqual(activity["object"]["id"], status.remote_id)
|
||||
|
||||
|
|
|
@ -34,9 +34,11 @@ class UserViews(TestCase):
|
|||
self.book = models.Edition.objects.create(
|
||||
title="test", parent_work=models.Work.objects.create(title="test work")
|
||||
)
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"), patch(
|
||||
"bookwyrm.suggested_users.rerank_suggestions_task.delay"
|
||||
), patch("bookwyrm.activitystreams.add_book_statuses_task.delay"):
|
||||
with patch(
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||
), patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.add_book_statuses_task.delay"
|
||||
):
|
||||
models.ShelfBook.objects.create(
|
||||
book=self.book,
|
||||
user=self.local_user,
|
||||
|
|
Loading…
Reference in a new issue