33 lines
1.2 KiB
Python
33 lines
1.2 KiB
Python
""" 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)
|