Merge pull request #1613 from bookwyrm-social/list-not-loading
Use a redis cache to store lists for user
This commit is contained in:
commit
e1a617f742
108 changed files with 1044 additions and 204 deletions
|
@ -16,7 +16,7 @@ class AnnouncementViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.mouse",
|
||||
|
|
|
@ -16,7 +16,7 @@ class DashboardViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.mouse",
|
||||
|
|
|
@ -17,7 +17,7 @@ class EmailBlocklistViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.mouse",
|
||||
|
|
|
@ -19,7 +19,7 @@ class FederationViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.mouse",
|
||||
|
|
|
@ -16,7 +16,7 @@ class IPBlocklistViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.mouse",
|
||||
|
|
|
@ -18,7 +18,7 @@ class ReportViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.mouse",
|
||||
|
|
|
@ -18,7 +18,7 @@ class UserAdminViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.mouse",
|
||||
|
|
|
@ -28,7 +28,7 @@ class BookViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.com",
|
||||
|
|
|
@ -21,7 +21,7 @@ class EditBookViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.com",
|
||||
|
|
|
@ -18,7 +18,7 @@ class BookViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.com",
|
||||
|
|
|
@ -19,7 +19,7 @@ class ImportViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.mouse",
|
||||
|
|
|
@ -16,7 +16,7 @@ class ImportManualReviewViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.mouse",
|
||||
|
|
|
@ -16,7 +16,7 @@ class ImportTroubleshootViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.mouse",
|
||||
|
|
|
@ -22,7 +22,7 @@ class Inbox(TestCase):
|
|||
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
local_user = models.User.objects.create_user(
|
||||
"mouse@example.com",
|
||||
"mouse@mouse.com",
|
||||
|
|
|
@ -15,7 +15,7 @@ class InboxAdd(TestCase):
|
|||
"""basic user and book data"""
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
local_user = models.User.objects.create_user(
|
||||
"mouse@example.com",
|
||||
"mouse@mouse.com",
|
||||
|
|
|
@ -15,7 +15,7 @@ class InboxActivities(TestCase):
|
|||
"""basic user and book data"""
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@example.com",
|
||||
"mouse@mouse.com",
|
||||
|
|
|
@ -14,7 +14,7 @@ class InboxBlock(TestCase):
|
|||
"""basic user and book data"""
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@example.com",
|
||||
"mouse@mouse.com",
|
||||
|
@ -57,7 +57,7 @@ class InboxBlock(TestCase):
|
|||
|
||||
with patch(
|
||||
"bookwyrm.activitystreams.remove_user_statuses_task.delay"
|
||||
) as redis_mock:
|
||||
) as redis_mock, patch("bookwyrm.lists_stream.remove_user_lists_task.delay"):
|
||||
views.inbox.activity_task(activity)
|
||||
self.assertTrue(redis_mock.called)
|
||||
views.inbox.activity_task(activity)
|
||||
|
@ -70,7 +70,9 @@ class InboxBlock(TestCase):
|
|||
self.assertFalse(models.UserFollowRequest.objects.exists())
|
||||
|
||||
@patch("bookwyrm.activitystreams.remove_user_statuses_task.delay")
|
||||
def test_handle_unblock(self, _):
|
||||
@patch("bookwyrm.lists_stream.add_user_lists_task.delay")
|
||||
@patch("bookwyrm.lists_stream.remove_user_lists_task.delay")
|
||||
def test_handle_unblock(self, *_):
|
||||
"""unblock a user"""
|
||||
self.remote_user.blocks.add(self.local_user)
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ class InboxCreate(TestCase):
|
|||
"""basic user and book data"""
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@example.com",
|
||||
"mouse@mouse.com",
|
||||
|
|
|
@ -15,7 +15,7 @@ class InboxActivities(TestCase):
|
|||
"""basic user and book data"""
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@example.com",
|
||||
"mouse@mouse.com",
|
||||
|
@ -51,7 +51,7 @@ class InboxActivities(TestCase):
|
|||
"type": "Delete",
|
||||
"to": ["https://www.w3.org/ns/activitystreams#Public"],
|
||||
"cc": ["https://example.com/user/mouse/followers"],
|
||||
"id": "%s/activity" % self.status.remote_id,
|
||||
"id": f"{self.status.remote_id}/activity",
|
||||
"actor": self.remote_user.remote_id,
|
||||
"object": {"id": self.status.remote_id, "type": "Tombstone"},
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ class InboxActivities(TestCase):
|
|||
"type": "Delete",
|
||||
"to": ["https://www.w3.org/ns/activitystreams#Public"],
|
||||
"cc": ["https://example.com/user/mouse/followers"],
|
||||
"id": "%s/activity" % self.status.remote_id,
|
||||
"id": f"{self.status.remote_id}/activity",
|
||||
"actor": self.remote_user.remote_id,
|
||||
"object": {"id": self.status.remote_id, "type": "Tombstone"},
|
||||
}
|
||||
|
@ -152,5 +152,7 @@ class InboxActivities(TestCase):
|
|||
"cc": [],
|
||||
},
|
||||
}
|
||||
views.inbox.activity_task(activity)
|
||||
with patch("bookwyrm.lists_stream.remove_list_task.delay") as mock:
|
||||
views.inbox.activity_task(activity)
|
||||
self.assertTrue(mock.called)
|
||||
self.assertFalse(models.List.objects.exists())
|
||||
|
|
|
@ -15,7 +15,7 @@ class InboxRelationships(TestCase):
|
|||
"""basic user and book data"""
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@example.com",
|
||||
"mouse@mouse.com",
|
||||
|
@ -188,7 +188,8 @@ class InboxRelationships(TestCase):
|
|||
self.assertIsNone(self.local_user.followers.first())
|
||||
|
||||
@patch("bookwyrm.activitystreams.add_user_statuses_task.delay")
|
||||
def test_follow_accept(self, _):
|
||||
@patch("bookwyrm.lists_stream.add_user_lists_task.delay")
|
||||
def test_follow_accept(self, *_):
|
||||
"""a remote user approved a follow request from local"""
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
rel = models.UserFollowRequest.objects.create(
|
||||
|
|
|
@ -14,7 +14,7 @@ class InboxActivities(TestCase):
|
|||
"""basic user and book data"""
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@example.com",
|
||||
"mouse@mouse.com",
|
||||
|
|
|
@ -14,7 +14,7 @@ class InboxRemove(TestCase):
|
|||
"""basic user and book data"""
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@example.com",
|
||||
"mouse@mouse.com",
|
||||
|
|
|
@ -16,7 +16,7 @@ class InboxUpdate(TestCase):
|
|||
"""basic user and book data"""
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@example.com",
|
||||
"mouse@mouse.com",
|
||||
|
@ -78,6 +78,7 @@ class InboxUpdate(TestCase):
|
|||
|
||||
@patch("bookwyrm.suggested_users.rerank_user_task.delay")
|
||||
@patch("bookwyrm.activitystreams.add_user_statuses_task.delay")
|
||||
@patch("bookwyrm.lists_stream.add_user_lists_task.delay")
|
||||
def test_update_user(self, *_):
|
||||
"""update an existing user"""
|
||||
models.UserFollows.objects.create(
|
||||
|
|
|
@ -19,7 +19,7 @@ class InviteViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.mouse",
|
||||
|
|
|
@ -18,7 +18,7 @@ class LandingViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.mouse",
|
||||
|
|
|
@ -21,7 +21,7 @@ class LoginViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@your.domain.here",
|
||||
"mouse@mouse.com",
|
||||
|
|
|
@ -21,7 +21,7 @@ class PasswordViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.com",
|
||||
|
|
|
@ -16,6 +16,7 @@ from bookwyrm.tests.validate_html import validate_html
|
|||
# pylint: disable=too-many-public-methods
|
||||
@patch("bookwyrm.suggested_users.rerank_suggestions_task.delay")
|
||||
@patch("bookwyrm.activitystreams.populate_stream_task.delay")
|
||||
@patch("bookwyrm.lists_stream.populate_lists_task.delay")
|
||||
class RegisterViews(TestCase):
|
||||
"""login and password management"""
|
||||
|
||||
|
@ -24,7 +25,7 @@ class RegisterViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@your.domain.here",
|
||||
"mouse@mouse.com",
|
||||
|
|
|
@ -18,7 +18,7 @@ class BlockViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.mouse",
|
||||
|
@ -61,7 +61,9 @@ class BlockViews(TestCase):
|
|||
|
||||
request = self.factory.post("")
|
||||
request.user = self.local_user
|
||||
with patch("bookwyrm.activitystreams.remove_user_statuses_task.delay"):
|
||||
with patch("bookwyrm.activitystreams.remove_user_statuses_task.delay"), patch(
|
||||
"bookwyrm.lists_stream.remove_user_lists_task.delay"
|
||||
):
|
||||
view(request, self.remote_user.id)
|
||||
block = models.UserBlocks.objects.get()
|
||||
self.assertEqual(block.user_subject, self.local_user)
|
||||
|
@ -76,7 +78,9 @@ class BlockViews(TestCase):
|
|||
request = self.factory.post("")
|
||||
request.user = self.local_user
|
||||
|
||||
with patch("bookwyrm.activitystreams.add_user_statuses_task.delay"):
|
||||
with patch("bookwyrm.activitystreams.add_user_statuses_task.delay"), patch(
|
||||
"bookwyrm.lists_stream.add_user_lists_task.delay"
|
||||
):
|
||||
views.unblock(request, self.remote_user.id)
|
||||
|
||||
self.assertFalse(models.UserBlocks.objects.exists())
|
||||
|
|
|
@ -17,7 +17,7 @@ class ChangePasswordViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.com",
|
||||
|
|
|
@ -20,7 +20,7 @@ class DeleteUserViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.mouse",
|
||||
|
|
|
@ -23,7 +23,7 @@ class EditUserViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.mouse",
|
||||
|
|
|
@ -14,6 +14,7 @@ from bookwyrm.tests.validate_html import validate_html
|
|||
@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.lists_stream.populate_lists_task.delay")
|
||||
@patch("bookwyrm.activitystreams.add_book_statuses_task.delay")
|
||||
@patch("bookwyrm.activitystreams.remove_book_statuses_task.delay")
|
||||
class ShelfViews(TestCase):
|
||||
|
@ -24,7 +25,7 @@ class ShelfViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.com",
|
||||
|
|
|
@ -12,6 +12,7 @@ from bookwyrm import forms, models, views
|
|||
@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.lists_stream.populate_lists_task.delay")
|
||||
@patch("bookwyrm.activitystreams.add_book_statuses_task.delay")
|
||||
@patch("bookwyrm.activitystreams.remove_book_statuses_task.delay")
|
||||
class ShelfActionViews(TestCase):
|
||||
|
@ -22,7 +23,7 @@ class ShelfActionViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.com",
|
||||
|
@ -178,7 +179,7 @@ class ShelfActionViews(TestCase):
|
|||
"""delete a brand new custom shelf"""
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
rat = models.User.objects.create_user(
|
||||
"rat@local.com",
|
||||
"rat@mouse.mouse",
|
||||
|
|
|
@ -26,7 +26,7 @@ class AnnualSummary(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.com",
|
||||
|
|
|
@ -21,7 +21,7 @@ class AuthorViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.com",
|
||||
|
|
|
@ -18,7 +18,7 @@ class DirectoryViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.com",
|
||||
|
@ -34,6 +34,7 @@ class DirectoryViews(TestCase):
|
|||
|
||||
@patch("bookwyrm.suggested_users.rerank_suggestions_task.delay")
|
||||
@patch("bookwyrm.activitystreams.populate_stream_task.delay")
|
||||
@patch("bookwyrm.lists_stream.populate_lists_task.delay")
|
||||
@patch("bookwyrm.suggested_users.rerank_user_task.delay")
|
||||
def test_directory_page(self, *_):
|
||||
"""there are so many views, this just makes sure it LOADS"""
|
||||
|
|
|
@ -16,7 +16,7 @@ class DiscoverViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.mouse",
|
||||
|
|
|
@ -10,8 +10,7 @@ from django.template.response import TemplateResponse
|
|||
from django.test import TestCase
|
||||
from django.test.client import RequestFactory
|
||||
|
||||
from bookwyrm import models
|
||||
from bookwyrm import views
|
||||
from bookwyrm import forms, models, views
|
||||
from bookwyrm.activitypub import ActivitypubResponse
|
||||
from bookwyrm.tests.validate_html import validate_html
|
||||
|
||||
|
@ -20,6 +19,7 @@ from bookwyrm.tests.validate_html import validate_html
|
|||
@patch("bookwyrm.activitystreams.add_status_task.delay")
|
||||
@patch("bookwyrm.suggested_users.rerank_suggestions_task.delay")
|
||||
@patch("bookwyrm.activitystreams.populate_stream_task.delay")
|
||||
@patch("bookwyrm.lists_stream.populate_lists_task.delay")
|
||||
@patch("bookwyrm.suggested_users.remove_user_task.delay")
|
||||
class FeedViews(TestCase):
|
||||
"""activity feed, statuses, dms"""
|
||||
|
@ -29,7 +29,7 @@ class FeedViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.mouse",
|
||||
|
@ -62,6 +62,25 @@ class FeedViews(TestCase):
|
|||
validate_html(result.render())
|
||||
self.assertEqual(result.status_code, 200)
|
||||
|
||||
@patch("bookwyrm.suggested_users.SuggestedUsers.get_suggestions")
|
||||
def test_save_feed_settings(self, *_):
|
||||
"""update display preferences"""
|
||||
self.assertEqual(
|
||||
self.local_user.feed_status_types,
|
||||
["review", "comment", "quotation", "everything"],
|
||||
)
|
||||
view = views.Feed.as_view()
|
||||
form = forms.FeedStatusTypesForm(instance=self.local_user)
|
||||
form.data["feed_status_types"] = "review"
|
||||
request = self.factory.post("", form.data)
|
||||
request.user = self.local_user
|
||||
|
||||
result = view(request, "home")
|
||||
|
||||
self.assertEqual(result.status_code, 200)
|
||||
self.local_user.refresh_from_db()
|
||||
self.assertEqual(self.local_user.feed_status_types, ["review"])
|
||||
|
||||
def test_status_page(self, *_):
|
||||
"""there are so many views, this just makes sure it LOADS"""
|
||||
view = views.Status.as_view()
|
||||
|
|
|
@ -13,6 +13,7 @@ from bookwyrm.tests.validate_html import validate_html
|
|||
|
||||
|
||||
@patch("bookwyrm.activitystreams.add_user_statuses_task.delay")
|
||||
@patch("bookwyrm.lists_stream.add_user_lists_task.delay")
|
||||
class FollowViews(TestCase):
|
||||
"""follows"""
|
||||
|
||||
|
@ -22,7 +23,7 @@ class FollowViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.com",
|
||||
|
@ -56,7 +57,7 @@ class FollowViews(TestCase):
|
|||
parent_work=self.work,
|
||||
)
|
||||
|
||||
def test_handle_follow_remote(self, _):
|
||||
def test_handle_follow_remote(self, *_):
|
||||
"""send a follow request"""
|
||||
request = self.factory.post("", {"user": self.remote_user.username})
|
||||
request.user = self.local_user
|
||||
|
@ -71,11 +72,11 @@ class FollowViews(TestCase):
|
|||
self.assertEqual(rel.user_object, self.remote_user)
|
||||
self.assertEqual(rel.status, "follow_request")
|
||||
|
||||
def test_handle_follow_local_manually_approves(self, _):
|
||||
def test_handle_follow_local_manually_approves(self, *_):
|
||||
"""send a follow request"""
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
rat = models.User.objects.create_user(
|
||||
"rat@local.com",
|
||||
"rat@rat.com",
|
||||
|
@ -97,11 +98,11 @@ class FollowViews(TestCase):
|
|||
self.assertEqual(rel.user_object, rat)
|
||||
self.assertEqual(rel.status, "follow_request")
|
||||
|
||||
def test_handle_follow_local(self, _):
|
||||
def test_handle_follow_local(self, *_):
|
||||
"""send a follow request"""
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
rat = models.User.objects.create_user(
|
||||
"rat@local.com",
|
||||
"rat@rat.com",
|
||||
|
@ -124,6 +125,7 @@ class FollowViews(TestCase):
|
|||
self.assertEqual(rel.status, "follows")
|
||||
|
||||
@patch("bookwyrm.activitystreams.remove_user_statuses_task.delay")
|
||||
@patch("bookwyrm.lists_stream.remove_user_lists_task.delay")
|
||||
def test_handle_unfollow(self, *_):
|
||||
"""send an unfollow"""
|
||||
request = self.factory.post("", {"user": self.remote_user.username})
|
||||
|
@ -140,7 +142,7 @@ class FollowViews(TestCase):
|
|||
|
||||
self.assertEqual(self.remote_user.followers.count(), 0)
|
||||
|
||||
def test_handle_accept(self, _):
|
||||
def test_handle_accept(self, *_):
|
||||
"""accept a follow request"""
|
||||
self.local_user.manually_approves_followers = True
|
||||
self.local_user.save(
|
||||
|
@ -159,7 +161,7 @@ class FollowViews(TestCase):
|
|||
# follow relationship should exist
|
||||
self.assertEqual(self.local_user.followers.first(), self.remote_user)
|
||||
|
||||
def test_handle_reject(self, _):
|
||||
def test_handle_reject(self, *_):
|
||||
"""reject a follow request"""
|
||||
self.local_user.manually_approves_followers = True
|
||||
self.local_user.save(
|
||||
|
@ -178,7 +180,7 @@ class FollowViews(TestCase):
|
|||
# follow relationship should not exist
|
||||
self.assertEqual(models.UserFollows.objects.filter(id=rel.id).count(), 0)
|
||||
|
||||
def test_ostatus_follow_request(self, _):
|
||||
def test_ostatus_follow_request(self, *_):
|
||||
"""check ostatus subscribe template loads"""
|
||||
request = self.factory.get(
|
||||
"", {"acct": "https%3A%2F%2Fexample.com%2Fusers%2Frat"}
|
||||
|
@ -189,7 +191,7 @@ class FollowViews(TestCase):
|
|||
validate_html(result.render())
|
||||
self.assertEqual(result.status_code, 200)
|
||||
|
||||
def test_remote_follow_page(self, _):
|
||||
def test_remote_follow_page(self, *_):
|
||||
"""check remote follow page loads"""
|
||||
request = self.factory.get("", {"acct": "mouse@local.com"})
|
||||
request.user = self.remote_user
|
||||
|
@ -198,7 +200,7 @@ class FollowViews(TestCase):
|
|||
validate_html(result.render())
|
||||
self.assertEqual(result.status_code, 200)
|
||||
|
||||
def test_ostatus_follow_success(self, _):
|
||||
def test_ostatus_follow_success(self, *_):
|
||||
"""check remote follow success page loads"""
|
||||
request = self.factory.get("")
|
||||
request.user = self.remote_user
|
||||
|
@ -208,7 +210,7 @@ class FollowViews(TestCase):
|
|||
validate_html(result.render())
|
||||
self.assertEqual(result.status_code, 200)
|
||||
|
||||
def test_remote_follow(self, _):
|
||||
def test_remote_follow(self, *_):
|
||||
"""check follow from remote page loads"""
|
||||
request = self.factory.post("", {"user": self.remote_user.id})
|
||||
request.user = self.remote_user
|
||||
|
|
|
@ -17,7 +17,7 @@ class GetStartedViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.mouse",
|
||||
|
|
|
@ -20,7 +20,7 @@ class GoalViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.com",
|
||||
|
|
|
@ -20,7 +20,7 @@ class GroupViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.mouse",
|
||||
|
|
|
@ -23,7 +23,7 @@ class ViewsHelpers(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
with patch("bookwyrm.suggested_users.rerank_user_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
|
|
|
@ -17,7 +17,7 @@ class InteractionViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.com",
|
||||
|
|
|
@ -18,7 +18,7 @@ class IsbnViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.com",
|
||||
|
@ -49,3 +49,13 @@ class IsbnViews(TestCase):
|
|||
self.assertEqual(len(data), 1)
|
||||
self.assertEqual(data[0]["title"], "Test Book")
|
||||
self.assertEqual(data[0]["key"], f"https://{DOMAIN}/book/{self.book.id}")
|
||||
|
||||
def test_isbn_html_response(self):
|
||||
"""searches local data only and returns book data in json format"""
|
||||
view = views.Isbn.as_view()
|
||||
request = self.factory.get("")
|
||||
with patch("bookwyrm.views.isbn.is_api_request") as is_api:
|
||||
is_api.return_value = False
|
||||
response = view(request, isbn="1234567890123")
|
||||
self.assertEqual(response.status_code, 200)
|
||||
response.render()
|
||||
|
|
|
@ -21,7 +21,7 @@ class ListViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.com",
|
||||
|
@ -72,10 +72,13 @@ class ListViews(TestCase):
|
|||
|
||||
models.SiteSettings.objects.create()
|
||||
|
||||
def test_lists_page(self):
|
||||
@patch("bookwyrm.lists_stream.ListsStream.get_list_stream")
|
||||
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.apply_async"):
|
||||
with patch(
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||
), patch("bookwyrm.lists_stream.add_list_task.delay"):
|
||||
models.List.objects.create(name="Public list", user=self.local_user)
|
||||
models.List.objects.create(
|
||||
name="Private list", privacy="direct", user=self.local_user
|
||||
|
@ -346,16 +349,16 @@ class ListViews(TestCase):
|
|||
def test_curate_page(self):
|
||||
"""there are so many views, this just makes sure it LOADS"""
|
||||
view = views.Curate.as_view()
|
||||
request = self.factory.get("")
|
||||
request.user = self.local_user
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
models.ListItem.objects.create(
|
||||
user=self.local_user,
|
||||
book_list=self.list,
|
||||
user=self.local_user,
|
||||
book=self.book,
|
||||
approved=False,
|
||||
order=1,
|
||||
)
|
||||
request = self.factory.get("")
|
||||
request.user = self.local_user
|
||||
|
||||
result = view(request, self.list.id)
|
||||
self.assertIsInstance(result, TemplateResponse)
|
||||
|
|
|
@ -18,7 +18,7 @@ class ListActionViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.com",
|
||||
|
@ -90,8 +90,9 @@ class ListActionViews(TestCase):
|
|||
request.user = self.local_user
|
||||
with patch(
|
||||
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
|
||||
) as mock:
|
||||
) as mock, patch("bookwyrm.lists_stream.remove_list_task.delay") as redis_mock:
|
||||
views.delete_list(request, self.list.id)
|
||||
self.assertTrue(redis_mock.called)
|
||||
activity = json.loads(mock.call_args[1]["args"][1])
|
||||
self.assertEqual(activity["type"], "Delete")
|
||||
self.assertEqual(activity["actor"], self.local_user.remote_id)
|
||||
|
@ -123,10 +124,7 @@ class ListActionViews(TestCase):
|
|||
|
||||
request = self.factory.post(
|
||||
"",
|
||||
{
|
||||
"item": pending.id,
|
||||
"approved": "true",
|
||||
},
|
||||
{"item": pending.id, "approved": "true"},
|
||||
)
|
||||
request.user = self.local_user
|
||||
|
||||
|
@ -553,12 +551,7 @@ class ListActionViews(TestCase):
|
|||
)
|
||||
self.assertTrue(self.list.listitem_set.exists())
|
||||
|
||||
request = self.factory.post(
|
||||
"",
|
||||
{
|
||||
"item": item.id,
|
||||
},
|
||||
)
|
||||
request = self.factory.post("", {"item": item.id})
|
||||
request.user = self.local_user
|
||||
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
|
@ -572,14 +565,22 @@ class ListActionViews(TestCase):
|
|||
book_list=self.list, user=self.local_user, book=self.book, order=1
|
||||
)
|
||||
self.assertTrue(self.list.listitem_set.exists())
|
||||
request = self.factory.post(
|
||||
"",
|
||||
{
|
||||
"item": item.id,
|
||||
},
|
||||
)
|
||||
request = self.factory.post("", {"item": item.id})
|
||||
request.user = self.rat
|
||||
|
||||
with self.assertRaises(PermissionDenied):
|
||||
views.list.remove_book(request, self.list.id)
|
||||
self.assertTrue(self.list.listitem_set.exists())
|
||||
|
||||
def test_save_unsave_list(self):
|
||||
"""bookmark a list"""
|
||||
self.assertFalse(self.local_user.saved_lists.exists())
|
||||
request = self.factory.post("")
|
||||
request.user = self.local_user
|
||||
views.save_list(request, self.list.id)
|
||||
self.local_user.refresh_from_db()
|
||||
self.assertEqual(self.local_user.saved_lists.first(), self.list)
|
||||
|
||||
views.unsave_list(request, self.list.id)
|
||||
self.local_user.refresh_from_db()
|
||||
self.assertFalse(self.local_user.saved_lists.exists())
|
||||
|
|
|
@ -17,7 +17,7 @@ class NotificationViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.mouse",
|
||||
|
|
|
@ -20,7 +20,7 @@ class OutboxView(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.com",
|
||||
|
|
|
@ -20,7 +20,7 @@ class ReadingViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.com",
|
||||
|
|
|
@ -27,7 +27,7 @@ class ReadThrough(TestCase):
|
|||
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.user = models.User.objects.create_user(
|
||||
"cinco", "cinco@example.com", "seissiete", local=True, localname="cinco"
|
||||
)
|
||||
|
|
|
@ -15,7 +15,7 @@ class RssFeedView(TestCase):
|
|||
def setUp(self):
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"rss_user", "rss@test.rss", "password", local=True
|
||||
)
|
||||
|
|
|
@ -23,7 +23,7 @@ class Views(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.com",
|
||||
|
|
|
@ -13,6 +13,7 @@ from bookwyrm.tests.validate_html import validate_html
|
|||
# pylint: disable=invalid-name
|
||||
@patch("bookwyrm.suggested_users.rerank_suggestions_task.delay")
|
||||
@patch("bookwyrm.activitystreams.populate_stream_task.delay")
|
||||
@patch("bookwyrm.lists_stream.populate_lists_task.delay")
|
||||
@patch("bookwyrm.activitystreams.remove_status_task.delay")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
|
||||
class StatusViews(TestCase):
|
||||
|
@ -23,7 +24,7 @@ class StatusViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.com",
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import json
|
||||
from unittest.mock import patch
|
||||
|
||||
from django.http import JsonResponse
|
||||
from django.http import Http404, JsonResponse
|
||||
from django.test import TestCase
|
||||
from django.test.client import RequestFactory
|
||||
|
||||
|
@ -17,7 +17,7 @@ class UpdateViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.mouse",
|
||||
|
@ -54,6 +54,7 @@ class UpdateViews(TestCase):
|
|||
"bookwyrm.activitystreams.ActivityStream.get_unread_count"
|
||||
) as mock_count:
|
||||
with patch(
|
||||
# pylint:disable=line-too-long
|
||||
"bookwyrm.activitystreams.ActivityStream.get_unread_count_by_status_type"
|
||||
) as mock_count_by_status:
|
||||
mock_count.return_value = 3
|
||||
|
@ -64,3 +65,11 @@ class UpdateViews(TestCase):
|
|||
data = json.loads(result.getvalue())
|
||||
self.assertEqual(data["count"], 3)
|
||||
self.assertEqual(data["count_by_type"]["review"], 5)
|
||||
|
||||
def test_get_unread_status_count_invalid_stream(self):
|
||||
"""there are so many views, this just makes sure it LOADS"""
|
||||
request = self.factory.get("")
|
||||
request.user = self.local_user
|
||||
|
||||
with self.assertRaises(Http404):
|
||||
views.get_unread_status_count(request, "fish")
|
||||
|
|
|
@ -20,7 +20,7 @@ class UserViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.mouse",
|
||||
|
|
|
@ -18,7 +18,7 @@ class WellknownViews(TestCase):
|
|||
self.factory = RequestFactory()
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse@local.com",
|
||||
"mouse@mouse.mouse",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue