mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-28 11:00:36 +00:00
Mocks redis in outbox tests
This commit is contained in:
parent
ea71c2aa88
commit
73661b9472
1 changed files with 12 additions and 11 deletions
|
@ -11,6 +11,7 @@ from bookwyrm.settings import USER_AGENT
|
|||
|
||||
|
||||
# pylint: disable=too-many-public-methods
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||
class OutboxView(TestCase):
|
||||
""" sends out activities """
|
||||
|
||||
|
@ -32,19 +33,19 @@ class OutboxView(TestCase):
|
|||
parent_work=work,
|
||||
)
|
||||
|
||||
def test_outbox(self):
|
||||
def test_outbox(self, _):
|
||||
""" returns user's statuses """
|
||||
request = self.factory.get("")
|
||||
result = views.Outbox.as_view()(request, "mouse")
|
||||
self.assertIsInstance(result, JsonResponse)
|
||||
|
||||
def test_outbox_bad_method(self):
|
||||
def test_outbox_bad_method(self, _):
|
||||
""" can't POST to outbox """
|
||||
request = self.factory.post("")
|
||||
result = views.Outbox.as_view()(request, "mouse")
|
||||
self.assertEqual(result.status_code, 405)
|
||||
|
||||
def test_outbox_unknown_user(self):
|
||||
def test_outbox_unknown_user(self, _):
|
||||
""" should 404 for unknown and remote users """
|
||||
request = self.factory.post("")
|
||||
result = views.Outbox.as_view()(request, "beepboop")
|
||||
|
@ -52,9 +53,9 @@ class OutboxView(TestCase):
|
|||
result = views.Outbox.as_view()(request, "rat")
|
||||
self.assertEqual(result.status_code, 405)
|
||||
|
||||
def test_outbox_privacy(self):
|
||||
def test_outbox_privacy(self, _):
|
||||
""" don't show dms et cetera in outbox """
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.activitystreams.ActivityStream.add_status"):
|
||||
models.Status.objects.create(
|
||||
content="PRIVATE!!", user=self.local_user, privacy="direct"
|
||||
)
|
||||
|
@ -75,9 +76,9 @@ class OutboxView(TestCase):
|
|||
self.assertEqual(data["type"], "OrderedCollection")
|
||||
self.assertEqual(data["totalItems"], 2)
|
||||
|
||||
def test_outbox_filter(self):
|
||||
def test_outbox_filter(self, _):
|
||||
""" if we only care about reviews, only get reviews """
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.activitystreams.ActivityStream.add_status"):
|
||||
models.Review.objects.create(
|
||||
content="look at this",
|
||||
name="hi",
|
||||
|
@ -101,9 +102,9 @@ class OutboxView(TestCase):
|
|||
self.assertEqual(data["type"], "OrderedCollection")
|
||||
self.assertEqual(data["totalItems"], 1)
|
||||
|
||||
def test_outbox_bookwyrm_request_true(self):
|
||||
def test_outbox_bookwyrm_request_true(self, _):
|
||||
""" should differentiate between bookwyrm and outside requests """
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.activitystreams.ActivityStream.add_status"):
|
||||
models.Review.objects.create(
|
||||
name="hi",
|
||||
content="look at this",
|
||||
|
@ -119,9 +120,9 @@ class OutboxView(TestCase):
|
|||
self.assertEqual(len(data["orderedItems"]), 1)
|
||||
self.assertEqual(data["orderedItems"][0]["type"], "Review")
|
||||
|
||||
def test_outbox_bookwyrm_request_false(self):
|
||||
def test_outbox_bookwyrm_request_false(self, _):
|
||||
""" should differentiate between bookwyrm and outside requests """
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
with patch("bookwyrm.activitystreams.ActivityStream.add_status"):
|
||||
models.Review.objects.create(
|
||||
name="hi",
|
||||
content="look at this",
|
||||
|
|
Loading…
Reference in a new issue