mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-24 09:00:33 +00:00
Creates test files for activitystreams
This commit is contained in:
parent
5a224b5aa4
commit
f4b43af600
3 changed files with 33 additions and 0 deletions
1
bookwyrm/tests/activitystreams/__init__.py
Normal file
1
bookwyrm/tests/activitystreams/__init__.py
Normal file
|
@ -0,0 +1 @@
|
|||
from . import *
|
32
bookwyrm/tests/activitystreams/test_activitystreams_tasks.py
Normal file
32
bookwyrm/tests/activitystreams/test_activitystreams_tasks.py
Normal file
|
@ -0,0 +1,32 @@
|
|||
""" testing activitystreams """
|
||||
from unittest.mock import patch
|
||||
from django.test import TestCase
|
||||
from bookwyrm import activitystreams, models
|
||||
|
||||
|
||||
class Activitystreams(TestCase):
|
||||
"""using redis to build activity streams"""
|
||||
|
||||
def setUp(self):
|
||||
"""use a test csv"""
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
):
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse"
|
||||
)
|
||||
work = models.Work.objects.create(title="test work")
|
||||
self.book = models.Edition.objects.create(title="test book", parent_work=work)
|
||||
|
||||
class TestStream(activitystreams.ActivityStream):
|
||||
"""test stream, don't have to do anything here"""
|
||||
|
||||
key = "test"
|
||||
|
||||
self.test_stream = TestStream()
|
||||
|
||||
def test_add_book_statuses_task(self):
|
||||
"""statuses related to a book"""
|
||||
with patch("bookwyrm.activitystreams.BooksStream") as mock:
|
||||
activitystreams.add_book_statuses_task(self.local_user.id, self.book.id)
|
||||
self.assertTrue(mock.called)
|
Loading…
Reference in a new issue