mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-01-25 16:38:09 +00:00
More mocks
This commit is contained in:
parent
46421f9672
commit
6e70ceb094
4 changed files with 18 additions and 10 deletions
|
@ -32,9 +32,10 @@ class ListsStreamSignals(TestCase):
|
||||||
|
|
||||||
def test_add_list_on_create_command(self, _):
|
def test_add_list_on_create_command(self, _):
|
||||||
"""a new lists has entered"""
|
"""a new lists has entered"""
|
||||||
book_list = models.List.objects.create(
|
with patch("bookwyrm.lists_stream.remove_list_task.delay"):
|
||||||
user=self.remote_user, name="hi", privacy="public"
|
book_list = models.List.objects.create(
|
||||||
)
|
user=self.remote_user, name="hi", privacy="public"
|
||||||
|
)
|
||||||
with patch("bookwyrm.lists_stream.add_list_task.delay") as mock:
|
with patch("bookwyrm.lists_stream.add_list_task.delay") as mock:
|
||||||
lists_stream.add_list_on_create_command(book_list.id)
|
lists_stream.add_list_on_create_command(book_list.id)
|
||||||
self.assertEqual(mock.call_count, 1)
|
self.assertEqual(mock.call_count, 1)
|
||||||
|
@ -43,9 +44,10 @@ class ListsStreamSignals(TestCase):
|
||||||
|
|
||||||
def test_remove_list_on_delete(self, _):
|
def test_remove_list_on_delete(self, _):
|
||||||
"""delete a list"""
|
"""delete a list"""
|
||||||
book_list = models.List.objects.create(
|
with patch("bookwyrm.lists_stream.remove_list_task.delay"):
|
||||||
user=self.remote_user, name="hi", privacy="public"
|
book_list = models.List.objects.create(
|
||||||
)
|
user=self.remote_user, name="hi", privacy="public"
|
||||||
|
)
|
||||||
with patch("bookwyrm.lists_stream.remove_list_task.delay") as mock:
|
with patch("bookwyrm.lists_stream.remove_list_task.delay") as mock:
|
||||||
lists_stream.remove_list_on_delete(models.List, book_list)
|
lists_stream.remove_list_on_delete(models.List, book_list)
|
||||||
args = mock.call_args[0]
|
args = mock.call_args[0]
|
||||||
|
|
|
@ -11,6 +11,7 @@ from bookwyrm import lists_stream, models
|
||||||
@patch("bookwyrm.activitystreams.add_book_statuses_task.delay")
|
@patch("bookwyrm.activitystreams.add_book_statuses_task.delay")
|
||||||
@patch("bookwyrm.suggested_users.rerank_suggestions_task.delay")
|
@patch("bookwyrm.suggested_users.rerank_suggestions_task.delay")
|
||||||
@patch("bookwyrm.activitystreams.populate_stream_task.delay")
|
@patch("bookwyrm.activitystreams.populate_stream_task.delay")
|
||||||
|
@patch("bookwyrm.lists_stream.remove_list_task.delay")
|
||||||
class ListsStream(TestCase):
|
class ListsStream(TestCase):
|
||||||
"""using redis to build activity streams"""
|
"""using redis to build activity streams"""
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,9 @@ class Activitystreams(TestCase):
|
||||||
inbox="https://example.com/users/rat/inbox",
|
inbox="https://example.com/users/rat/inbox",
|
||||||
outbox="https://example.com/users/rat/outbox",
|
outbox="https://example.com/users/rat/outbox",
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
with patch(
|
||||||
|
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||||
|
), patch("bookwyrm.lists_stream.remove_list_task.delay"):
|
||||||
self.list = models.List.objects.create(
|
self.list = models.List.objects.create(
|
||||||
user=self.local_user, name="hi", privacy="public"
|
user=self.local_user, name="hi", privacy="public"
|
||||||
)
|
)
|
||||||
|
|
|
@ -80,7 +80,9 @@ class Group(TestCase):
|
||||||
"""follower-only group booklists should not be excluded from group booklist
|
"""follower-only group booklists should not be excluded from group booklist
|
||||||
listing for group members who do not follower list owner"""
|
listing for group members who do not follower list owner"""
|
||||||
|
|
||||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
with patch(
|
||||||
|
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||||
|
), patch("bookwyrm.lists_stream.remove_list_task.delay"):
|
||||||
followers_list = models.List.objects.create(
|
followers_list = models.List.objects.create(
|
||||||
name="Followers List",
|
name="Followers List",
|
||||||
curation="group",
|
curation="group",
|
||||||
|
@ -101,8 +103,9 @@ class Group(TestCase):
|
||||||
"""private group booklists should not be excluded from group booklist listing
|
"""private group booklists should not be excluded from group booklist listing
|
||||||
for group members"""
|
for group members"""
|
||||||
|
|
||||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
with patch(
|
||||||
|
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||||
|
), patch("bookwyrm.lists_stream.remove_list_task.delay"):
|
||||||
private_list = models.List.objects.create(
|
private_list = models.List.objects.create(
|
||||||
name="Private List",
|
name="Private List",
|
||||||
privacy="direct",
|
privacy="direct",
|
||||||
|
|
Loading…
Reference in a new issue