From f4b43af600380b45e003a562efab13c088ace40e Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 7 Sep 2021 10:24:09 -0700 Subject: [PATCH] Creates test files for activitystreams --- bookwyrm/tests/activitystreams/__init__.py | 1 + .../test_activitystreams.py | 0 .../test_activitystreams_tasks.py | 32 +++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 bookwyrm/tests/activitystreams/__init__.py rename bookwyrm/tests/{ => activitystreams}/test_activitystreams.py (100%) create mode 100644 bookwyrm/tests/activitystreams/test_activitystreams_tasks.py diff --git a/bookwyrm/tests/activitystreams/__init__.py b/bookwyrm/tests/activitystreams/__init__.py new file mode 100644 index 00000000..b6e690fd --- /dev/null +++ b/bookwyrm/tests/activitystreams/__init__.py @@ -0,0 +1 @@ +from . import * diff --git a/bookwyrm/tests/test_activitystreams.py b/bookwyrm/tests/activitystreams/test_activitystreams.py similarity index 100% rename from bookwyrm/tests/test_activitystreams.py rename to bookwyrm/tests/activitystreams/test_activitystreams.py diff --git a/bookwyrm/tests/activitystreams/test_activitystreams_tasks.py b/bookwyrm/tests/activitystreams/test_activitystreams_tasks.py new file mode 100644 index 00000000..31317700 --- /dev/null +++ b/bookwyrm/tests/activitystreams/test_activitystreams_tasks.py @@ -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)