mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-15 13:24:04 +00:00
Fixes model tests
This commit is contained in:
parent
9e23bfe7c0
commit
7f271dbde7
4 changed files with 54 additions and 50 deletions
|
@ -13,6 +13,7 @@ from bookwyrm.models.activitypub_mixin import ActivitypubMixin
|
||||||
from bookwyrm.models.activitypub_mixin import ActivityMixin, ObjectMixin
|
from bookwyrm.models.activitypub_mixin import ActivityMixin, ObjectMixin
|
||||||
|
|
||||||
|
|
||||||
|
@patch("bookwyrm.activitystreams.ActivityStream.add_status")
|
||||||
class ActivitypubMixins(TestCase):
|
class ActivitypubMixins(TestCase):
|
||||||
""" functionality shared across models """
|
""" functionality shared across models """
|
||||||
|
|
||||||
|
@ -44,7 +45,7 @@ class ActivitypubMixins(TestCase):
|
||||||
}
|
}
|
||||||
|
|
||||||
# ActivitypubMixin
|
# ActivitypubMixin
|
||||||
def test_to_activity(self):
|
def test_to_activity(self, _):
|
||||||
""" model to ActivityPub json """
|
""" model to ActivityPub json """
|
||||||
|
|
||||||
@dataclass(init=False)
|
@dataclass(init=False)
|
||||||
|
@ -65,7 +66,7 @@ class ActivitypubMixins(TestCase):
|
||||||
self.assertEqual(activity["id"], "https://www.example.com/test")
|
self.assertEqual(activity["id"], "https://www.example.com/test")
|
||||||
self.assertEqual(activity["type"], "Test")
|
self.assertEqual(activity["type"], "Test")
|
||||||
|
|
||||||
def test_find_existing_by_remote_id(self):
|
def test_find_existing_by_remote_id(self, _):
|
||||||
""" attempt to match a remote id to an object in the db """
|
""" attempt to match a remote id to an object in the db """
|
||||||
# uses a different remote id scheme
|
# uses a different remote id scheme
|
||||||
# this isn't really part of this test directly but it's helpful to state
|
# this isn't really part of this test directly but it's helpful to state
|
||||||
|
@ -98,7 +99,7 @@ class ActivitypubMixins(TestCase):
|
||||||
# test subclass match
|
# test subclass match
|
||||||
result = models.Status.find_existing_by_remote_id("https://comment.net")
|
result = models.Status.find_existing_by_remote_id("https://comment.net")
|
||||||
|
|
||||||
def test_find_existing(self):
|
def test_find_existing(self, _):
|
||||||
""" match a blob of data to a model """
|
""" match a blob of data to a model """
|
||||||
book = models.Edition.objects.create(
|
book = models.Edition.objects.create(
|
||||||
title="Test edition",
|
title="Test edition",
|
||||||
|
@ -108,7 +109,7 @@ class ActivitypubMixins(TestCase):
|
||||||
result = models.Edition.find_existing({"openlibraryKey": "OL1234"})
|
result = models.Edition.find_existing({"openlibraryKey": "OL1234"})
|
||||||
self.assertEqual(result, book)
|
self.assertEqual(result, book)
|
||||||
|
|
||||||
def test_get_recipients_public_object(self):
|
def test_get_recipients_public_object(self, _):
|
||||||
""" determines the recipients for an object's broadcast """
|
""" determines the recipients for an object's broadcast """
|
||||||
MockSelf = namedtuple("Self", ("privacy"))
|
MockSelf = namedtuple("Self", ("privacy"))
|
||||||
mock_self = MockSelf("public")
|
mock_self = MockSelf("public")
|
||||||
|
@ -116,7 +117,7 @@ class ActivitypubMixins(TestCase):
|
||||||
self.assertEqual(len(recipients), 1)
|
self.assertEqual(len(recipients), 1)
|
||||||
self.assertEqual(recipients[0], self.remote_user.inbox)
|
self.assertEqual(recipients[0], self.remote_user.inbox)
|
||||||
|
|
||||||
def test_get_recipients_public_user_object_no_followers(self):
|
def test_get_recipients_public_user_object_no_followers(self, _):
|
||||||
""" determines the recipients for a user's object broadcast """
|
""" determines the recipients for a user's object broadcast """
|
||||||
MockSelf = namedtuple("Self", ("privacy", "user"))
|
MockSelf = namedtuple("Self", ("privacy", "user"))
|
||||||
mock_self = MockSelf("public", self.local_user)
|
mock_self = MockSelf("public", self.local_user)
|
||||||
|
@ -124,7 +125,7 @@ class ActivitypubMixins(TestCase):
|
||||||
recipients = ActivitypubMixin.get_recipients(mock_self)
|
recipients = ActivitypubMixin.get_recipients(mock_self)
|
||||||
self.assertEqual(len(recipients), 0)
|
self.assertEqual(len(recipients), 0)
|
||||||
|
|
||||||
def test_get_recipients_public_user_object(self):
|
def test_get_recipients_public_user_object(self, _):
|
||||||
""" determines the recipients for a user's object broadcast """
|
""" determines the recipients for a user's object broadcast """
|
||||||
MockSelf = namedtuple("Self", ("privacy", "user"))
|
MockSelf = namedtuple("Self", ("privacy", "user"))
|
||||||
mock_self = MockSelf("public", self.local_user)
|
mock_self = MockSelf("public", self.local_user)
|
||||||
|
@ -134,7 +135,7 @@ class ActivitypubMixins(TestCase):
|
||||||
self.assertEqual(len(recipients), 1)
|
self.assertEqual(len(recipients), 1)
|
||||||
self.assertEqual(recipients[0], self.remote_user.inbox)
|
self.assertEqual(recipients[0], self.remote_user.inbox)
|
||||||
|
|
||||||
def test_get_recipients_public_user_object_with_mention(self):
|
def test_get_recipients_public_user_object_with_mention(self, _):
|
||||||
""" determines the recipients for a user's object broadcast """
|
""" determines the recipients for a user's object broadcast """
|
||||||
MockSelf = namedtuple("Self", ("privacy", "user"))
|
MockSelf = namedtuple("Self", ("privacy", "user"))
|
||||||
mock_self = MockSelf("public", self.local_user)
|
mock_self = MockSelf("public", self.local_user)
|
||||||
|
@ -157,7 +158,7 @@ class ActivitypubMixins(TestCase):
|
||||||
self.assertEqual(recipients[0], another_remote_user.inbox)
|
self.assertEqual(recipients[0], another_remote_user.inbox)
|
||||||
self.assertEqual(recipients[1], self.remote_user.inbox)
|
self.assertEqual(recipients[1], self.remote_user.inbox)
|
||||||
|
|
||||||
def test_get_recipients_direct(self):
|
def test_get_recipients_direct(self, _):
|
||||||
""" determines the recipients for a user's object broadcast """
|
""" determines the recipients for a user's object broadcast """
|
||||||
MockSelf = namedtuple("Self", ("privacy", "user"))
|
MockSelf = namedtuple("Self", ("privacy", "user"))
|
||||||
mock_self = MockSelf("public", self.local_user)
|
mock_self = MockSelf("public", self.local_user)
|
||||||
|
@ -179,7 +180,7 @@ class ActivitypubMixins(TestCase):
|
||||||
self.assertEqual(len(recipients), 1)
|
self.assertEqual(len(recipients), 1)
|
||||||
self.assertEqual(recipients[0], another_remote_user.inbox)
|
self.assertEqual(recipients[0], another_remote_user.inbox)
|
||||||
|
|
||||||
def test_get_recipients_combine_inboxes(self):
|
def test_get_recipients_combine_inboxes(self, _):
|
||||||
""" should combine users with the same shared_inbox """
|
""" should combine users with the same shared_inbox """
|
||||||
self.remote_user.shared_inbox = "http://example.com/inbox"
|
self.remote_user.shared_inbox = "http://example.com/inbox"
|
||||||
self.remote_user.save(broadcast=False)
|
self.remote_user.save(broadcast=False)
|
||||||
|
@ -203,7 +204,7 @@ class ActivitypubMixins(TestCase):
|
||||||
self.assertEqual(len(recipients), 1)
|
self.assertEqual(len(recipients), 1)
|
||||||
self.assertEqual(recipients[0], "http://example.com/inbox")
|
self.assertEqual(recipients[0], "http://example.com/inbox")
|
||||||
|
|
||||||
def test_get_recipients_software(self):
|
def test_get_recipients_software(self, _):
|
||||||
""" should differentiate between bookwyrm and other remote users """
|
""" should differentiate between bookwyrm and other remote users """
|
||||||
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
||||||
another_remote_user = models.User.objects.create_user(
|
another_remote_user = models.User.objects.create_user(
|
||||||
|
@ -233,7 +234,7 @@ class ActivitypubMixins(TestCase):
|
||||||
self.assertEqual(recipients[0], another_remote_user.inbox)
|
self.assertEqual(recipients[0], another_remote_user.inbox)
|
||||||
|
|
||||||
# ObjectMixin
|
# ObjectMixin
|
||||||
def test_object_save_create(self):
|
def test_object_save_create(self, _):
|
||||||
""" should save uneventufully when broadcast is disabled """
|
""" should save uneventufully when broadcast is disabled """
|
||||||
|
|
||||||
class Success(Exception):
|
class Success(Exception):
|
||||||
|
@ -264,7 +265,7 @@ class ActivitypubMixins(TestCase):
|
||||||
ObjectModel(user=self.local_user).save(broadcast=False)
|
ObjectModel(user=self.local_user).save(broadcast=False)
|
||||||
ObjectModel(user=None).save()
|
ObjectModel(user=None).save()
|
||||||
|
|
||||||
def test_object_save_update(self):
|
def test_object_save_update(self, _):
|
||||||
""" should save uneventufully when broadcast is disabled """
|
""" should save uneventufully when broadcast is disabled """
|
||||||
|
|
||||||
class Success(Exception):
|
class Success(Exception):
|
||||||
|
@ -290,7 +291,7 @@ class ActivitypubMixins(TestCase):
|
||||||
with self.assertRaises(Success):
|
with self.assertRaises(Success):
|
||||||
UpdateObjectModel(id=1, last_edited_by=self.local_user).save()
|
UpdateObjectModel(id=1, last_edited_by=self.local_user).save()
|
||||||
|
|
||||||
def test_object_save_delete(self):
|
def test_object_save_delete(self, _):
|
||||||
""" should create delete activities when objects are deleted by flag """
|
""" should create delete activities when objects are deleted by flag """
|
||||||
|
|
||||||
class ActivitySuccess(Exception):
|
class ActivitySuccess(Exception):
|
||||||
|
@ -312,7 +313,7 @@ class ActivitypubMixins(TestCase):
|
||||||
with self.assertRaises(ActivitySuccess):
|
with self.assertRaises(ActivitySuccess):
|
||||||
DeletableObjectModel(id=1, user=self.local_user, deleted=True).save()
|
DeletableObjectModel(id=1, user=self.local_user, deleted=True).save()
|
||||||
|
|
||||||
def test_to_delete_activity(self):
|
def test_to_delete_activity(self, _):
|
||||||
""" wrapper for Delete activity """
|
""" wrapper for Delete activity """
|
||||||
MockSelf = namedtuple("Self", ("remote_id", "to_activity"))
|
MockSelf = namedtuple("Self", ("remote_id", "to_activity"))
|
||||||
mock_self = MockSelf(
|
mock_self = MockSelf(
|
||||||
|
@ -327,7 +328,7 @@ class ActivitypubMixins(TestCase):
|
||||||
activity["cc"], ["https://www.w3.org/ns/activitystreams#Public"]
|
activity["cc"], ["https://www.w3.org/ns/activitystreams#Public"]
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_to_update_activity(self):
|
def test_to_update_activity(self, _):
|
||||||
""" ditto above but for Update """
|
""" ditto above but for Update """
|
||||||
MockSelf = namedtuple("Self", ("remote_id", "to_activity"))
|
MockSelf = namedtuple("Self", ("remote_id", "to_activity"))
|
||||||
mock_self = MockSelf(
|
mock_self = MockSelf(
|
||||||
|
@ -345,7 +346,7 @@ class ActivitypubMixins(TestCase):
|
||||||
self.assertIsInstance(activity["object"], dict)
|
self.assertIsInstance(activity["object"], dict)
|
||||||
|
|
||||||
# Activity mixin
|
# Activity mixin
|
||||||
def test_to_undo_activity(self):
|
def test_to_undo_activity(self, _):
|
||||||
""" and again, for Undo """
|
""" and again, for Undo """
|
||||||
MockSelf = namedtuple("Self", ("remote_id", "to_activity", "user"))
|
MockSelf = namedtuple("Self", ("remote_id", "to_activity", "user"))
|
||||||
mock_self = MockSelf(
|
mock_self = MockSelf(
|
||||||
|
|
|
@ -27,18 +27,18 @@ class BaseModel(TestCase):
|
||||||
expected = instance.get_remote_id()
|
expected = instance.get_remote_id()
|
||||||
self.assertEqual(expected, "https://%s/user/mouse/bookwyrmmodel/1" % DOMAIN)
|
self.assertEqual(expected, "https://%s/user/mouse/bookwyrmmodel/1" % DOMAIN)
|
||||||
|
|
||||||
def test_execute_after_save(self):
|
def test_set_remote_id(self):
|
||||||
""" this function sets remote ids after creation """
|
""" this function sets remote ids after creation """
|
||||||
# using Work because it BookWrymModel is abstract and this requires save
|
# using Work because it BookWrymModel is abstract and this requires save
|
||||||
# Work is a relatively not-fancy model.
|
# Work is a relatively not-fancy model.
|
||||||
instance = models.Work.objects.create(title="work title")
|
instance = models.Work.objects.create(title="work title")
|
||||||
instance.remote_id = None
|
instance.remote_id = None
|
||||||
base_model.execute_after_save(None, instance, True)
|
base_model.set_remote_id(None, instance, True)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
instance.remote_id, "https://%s/book/%d" % (DOMAIN, instance.id)
|
instance.remote_id, "https://%s/book/%d" % (DOMAIN, instance.id)
|
||||||
)
|
)
|
||||||
|
|
||||||
# shouldn't set remote_id if it's not created
|
# shouldn't set remote_id if it's not created
|
||||||
instance.remote_id = None
|
instance.remote_id = None
|
||||||
base_model.execute_after_save(None, instance, False)
|
base_model.set_remote_id(None, instance, False)
|
||||||
self.assertIsNone(instance.remote_id)
|
self.assertIsNone(instance.remote_id)
|
||||||
|
|
|
@ -185,7 +185,8 @@ class ActivitypubFields(TestCase):
|
||||||
self.assertEqual(model_instance.privacy_field, "unlisted")
|
self.assertEqual(model_instance.privacy_field, "unlisted")
|
||||||
|
|
||||||
@patch("bookwyrm.models.activitypub_mixin.ObjectMixin.broadcast")
|
@patch("bookwyrm.models.activitypub_mixin.ObjectMixin.broadcast")
|
||||||
def test_privacy_field_set_activity_from_field(self, _):
|
@patch("bookwyrm.activitystreams.ActivityStream.add_status")
|
||||||
|
def test_privacy_field_set_activity_from_field(self, *_):
|
||||||
""" translate between to/cc fields and privacy """
|
""" translate between to/cc fields and privacy """
|
||||||
user = User.objects.create_user(
|
user = User.objects.create_user(
|
||||||
"rat", "rat@rat.rat", "ratword", local=True, localname="rat"
|
"rat", "rat@rat.rat", "ratword", local=True, localname="rat"
|
||||||
|
|
|
@ -15,6 +15,7 @@ from bookwyrm import activitypub, models, settings
|
||||||
|
|
||||||
# pylint: disable=too-many-public-methods
|
# pylint: disable=too-many-public-methods
|
||||||
@patch("bookwyrm.models.Status.broadcast")
|
@patch("bookwyrm.models.Status.broadcast")
|
||||||
|
@patch("bookwyrm.activitystreams.ActivityStream.add_status")
|
||||||
class Status(TestCase):
|
class Status(TestCase):
|
||||||
""" lotta types of statuses """
|
""" lotta types of statuses """
|
||||||
|
|
||||||
|
@ -44,14 +45,14 @@ class Status(TestCase):
|
||||||
image.save(output, format=image.format)
|
image.save(output, format=image.format)
|
||||||
self.book.cover.save("test.jpg", ContentFile(output.getvalue()))
|
self.book.cover.save("test.jpg", ContentFile(output.getvalue()))
|
||||||
|
|
||||||
def test_status_generated_fields(self, _):
|
def test_status_generated_fields(self, *_):
|
||||||
""" setting remote id """
|
""" setting remote id """
|
||||||
status = models.Status.objects.create(content="bleh", user=self.local_user)
|
status = models.Status.objects.create(content="bleh", user=self.local_user)
|
||||||
expected_id = "https://%s/user/mouse/status/%d" % (settings.DOMAIN, status.id)
|
expected_id = "https://%s/user/mouse/status/%d" % (settings.DOMAIN, status.id)
|
||||||
self.assertEqual(status.remote_id, expected_id)
|
self.assertEqual(status.remote_id, expected_id)
|
||||||
self.assertEqual(status.privacy, "public")
|
self.assertEqual(status.privacy, "public")
|
||||||
|
|
||||||
def test_replies(self, _):
|
def test_replies(self, *_):
|
||||||
""" get a list of replies """
|
""" get a list of replies """
|
||||||
parent = models.Status.objects.create(content="hi", user=self.local_user)
|
parent = models.Status.objects.create(content="hi", user=self.local_user)
|
||||||
child = models.Status.objects.create(
|
child = models.Status.objects.create(
|
||||||
|
@ -70,7 +71,7 @@ class Status(TestCase):
|
||||||
# should select subclasses
|
# should select subclasses
|
||||||
self.assertIsInstance(replies.last(), models.Review)
|
self.assertIsInstance(replies.last(), models.Review)
|
||||||
|
|
||||||
def test_status_type(self, _):
|
def test_status_type(self, *_):
|
||||||
""" class name """
|
""" class name """
|
||||||
self.assertEqual(models.Status().status_type, "Note")
|
self.assertEqual(models.Status().status_type, "Note")
|
||||||
self.assertEqual(models.Review().status_type, "Review")
|
self.assertEqual(models.Review().status_type, "Review")
|
||||||
|
@ -78,14 +79,14 @@ class Status(TestCase):
|
||||||
self.assertEqual(models.Comment().status_type, "Comment")
|
self.assertEqual(models.Comment().status_type, "Comment")
|
||||||
self.assertEqual(models.Boost().status_type, "Announce")
|
self.assertEqual(models.Boost().status_type, "Announce")
|
||||||
|
|
||||||
def test_boostable(self, _):
|
def test_boostable(self, *_):
|
||||||
""" can a status be boosted, based on privacy """
|
""" can a status be boosted, based on privacy """
|
||||||
self.assertTrue(models.Status(privacy="public").boostable)
|
self.assertTrue(models.Status(privacy="public").boostable)
|
||||||
self.assertTrue(models.Status(privacy="unlisted").boostable)
|
self.assertTrue(models.Status(privacy="unlisted").boostable)
|
||||||
self.assertFalse(models.Status(privacy="followers").boostable)
|
self.assertFalse(models.Status(privacy="followers").boostable)
|
||||||
self.assertFalse(models.Status(privacy="direct").boostable)
|
self.assertFalse(models.Status(privacy="direct").boostable)
|
||||||
|
|
||||||
def test_to_replies(self, _):
|
def test_to_replies(self, *_):
|
||||||
""" activitypub replies collection """
|
""" activitypub replies collection """
|
||||||
parent = models.Status.objects.create(content="hi", user=self.local_user)
|
parent = models.Status.objects.create(content="hi", user=self.local_user)
|
||||||
child = models.Status.objects.create(
|
child = models.Status.objects.create(
|
||||||
|
@ -102,7 +103,7 @@ class Status(TestCase):
|
||||||
self.assertEqual(replies["id"], "%s/replies" % parent.remote_id)
|
self.assertEqual(replies["id"], "%s/replies" % parent.remote_id)
|
||||||
self.assertEqual(replies["totalItems"], 2)
|
self.assertEqual(replies["totalItems"], 2)
|
||||||
|
|
||||||
def test_status_to_activity(self, _):
|
def test_status_to_activity(self, *_):
|
||||||
""" subclass of the base model version with a "pure" serializer """
|
""" subclass of the base model version with a "pure" serializer """
|
||||||
status = models.Status.objects.create(
|
status = models.Status.objects.create(
|
||||||
content="test content", user=self.local_user
|
content="test content", user=self.local_user
|
||||||
|
@ -113,20 +114,21 @@ class Status(TestCase):
|
||||||
self.assertEqual(activity["content"], "test content")
|
self.assertEqual(activity["content"], "test content")
|
||||||
self.assertEqual(activity["sensitive"], False)
|
self.assertEqual(activity["sensitive"], False)
|
||||||
|
|
||||||
def test_status_to_activity_tombstone(self, _):
|
def test_status_to_activity_tombstone(self, *_):
|
||||||
""" subclass of the base model version with a "pure" serializer """
|
""" subclass of the base model version with a "pure" serializer """
|
||||||
status = models.Status.objects.create(
|
with patch("bookwyrm.activitystreams.ActivityStream.remove_status"):
|
||||||
content="test content",
|
status = models.Status.objects.create(
|
||||||
user=self.local_user,
|
content="test content",
|
||||||
deleted=True,
|
user=self.local_user,
|
||||||
deleted_date=timezone.now(),
|
deleted=True,
|
||||||
)
|
deleted_date=timezone.now(),
|
||||||
|
)
|
||||||
activity = status.to_activity()
|
activity = status.to_activity()
|
||||||
self.assertEqual(activity["id"], status.remote_id)
|
self.assertEqual(activity["id"], status.remote_id)
|
||||||
self.assertEqual(activity["type"], "Tombstone")
|
self.assertEqual(activity["type"], "Tombstone")
|
||||||
self.assertFalse(hasattr(activity, "content"))
|
self.assertFalse(hasattr(activity, "content"))
|
||||||
|
|
||||||
def test_status_to_pure_activity(self, _):
|
def test_status_to_pure_activity(self, *_):
|
||||||
""" subclass of the base model version with a "pure" serializer """
|
""" subclass of the base model version with a "pure" serializer """
|
||||||
status = models.Status.objects.create(
|
status = models.Status.objects.create(
|
||||||
content="test content", user=self.local_user
|
content="test content", user=self.local_user
|
||||||
|
@ -138,7 +140,7 @@ class Status(TestCase):
|
||||||
self.assertEqual(activity["sensitive"], False)
|
self.assertEqual(activity["sensitive"], False)
|
||||||
self.assertEqual(activity["attachment"], [])
|
self.assertEqual(activity["attachment"], [])
|
||||||
|
|
||||||
def test_generated_note_to_activity(self, _):
|
def test_generated_note_to_activity(self, *_):
|
||||||
""" subclass of the base model version with a "pure" serializer """
|
""" subclass of the base model version with a "pure" serializer """
|
||||||
status = models.GeneratedNote.objects.create(
|
status = models.GeneratedNote.objects.create(
|
||||||
content="test content", user=self.local_user
|
content="test content", user=self.local_user
|
||||||
|
@ -152,7 +154,7 @@ class Status(TestCase):
|
||||||
self.assertEqual(activity["sensitive"], False)
|
self.assertEqual(activity["sensitive"], False)
|
||||||
self.assertEqual(len(activity["tag"]), 2)
|
self.assertEqual(len(activity["tag"]), 2)
|
||||||
|
|
||||||
def test_generated_note_to_pure_activity(self, _):
|
def test_generated_note_to_pure_activity(self, *_):
|
||||||
""" subclass of the base model version with a "pure" serializer """
|
""" subclass of the base model version with a "pure" serializer """
|
||||||
status = models.GeneratedNote.objects.create(
|
status = models.GeneratedNote.objects.create(
|
||||||
content="test content", user=self.local_user
|
content="test content", user=self.local_user
|
||||||
|
@ -176,7 +178,7 @@ class Status(TestCase):
|
||||||
)
|
)
|
||||||
self.assertEqual(activity["attachment"][0].name, "Test Edition")
|
self.assertEqual(activity["attachment"][0].name, "Test Edition")
|
||||||
|
|
||||||
def test_comment_to_activity(self, _):
|
def test_comment_to_activity(self, *_):
|
||||||
""" subclass of the base model version with a "pure" serializer """
|
""" subclass of the base model version with a "pure" serializer """
|
||||||
status = models.Comment.objects.create(
|
status = models.Comment.objects.create(
|
||||||
content="test content", user=self.local_user, book=self.book
|
content="test content", user=self.local_user, book=self.book
|
||||||
|
@ -187,7 +189,7 @@ class Status(TestCase):
|
||||||
self.assertEqual(activity["content"], "test content")
|
self.assertEqual(activity["content"], "test content")
|
||||||
self.assertEqual(activity["inReplyToBook"], self.book.remote_id)
|
self.assertEqual(activity["inReplyToBook"], self.book.remote_id)
|
||||||
|
|
||||||
def test_comment_to_pure_activity(self, _):
|
def test_comment_to_pure_activity(self, *_):
|
||||||
""" subclass of the base model version with a "pure" serializer """
|
""" subclass of the base model version with a "pure" serializer """
|
||||||
status = models.Comment.objects.create(
|
status = models.Comment.objects.create(
|
||||||
content="test content", user=self.local_user, book=self.book
|
content="test content", user=self.local_user, book=self.book
|
||||||
|
@ -207,7 +209,7 @@ class Status(TestCase):
|
||||||
)
|
)
|
||||||
self.assertEqual(activity["attachment"][0].name, "Test Edition")
|
self.assertEqual(activity["attachment"][0].name, "Test Edition")
|
||||||
|
|
||||||
def test_quotation_to_activity(self, _):
|
def test_quotation_to_activity(self, *_):
|
||||||
""" subclass of the base model version with a "pure" serializer """
|
""" subclass of the base model version with a "pure" serializer """
|
||||||
status = models.Quotation.objects.create(
|
status = models.Quotation.objects.create(
|
||||||
quote="a sickening sense",
|
quote="a sickening sense",
|
||||||
|
@ -222,7 +224,7 @@ class Status(TestCase):
|
||||||
self.assertEqual(activity["content"], "test content")
|
self.assertEqual(activity["content"], "test content")
|
||||||
self.assertEqual(activity["inReplyToBook"], self.book.remote_id)
|
self.assertEqual(activity["inReplyToBook"], self.book.remote_id)
|
||||||
|
|
||||||
def test_quotation_to_pure_activity(self, _):
|
def test_quotation_to_pure_activity(self, *_):
|
||||||
""" subclass of the base model version with a "pure" serializer """
|
""" subclass of the base model version with a "pure" serializer """
|
||||||
status = models.Quotation.objects.create(
|
status = models.Quotation.objects.create(
|
||||||
quote="a sickening sense",
|
quote="a sickening sense",
|
||||||
|
@ -245,7 +247,7 @@ class Status(TestCase):
|
||||||
)
|
)
|
||||||
self.assertEqual(activity["attachment"][0].name, "Test Edition")
|
self.assertEqual(activity["attachment"][0].name, "Test Edition")
|
||||||
|
|
||||||
def test_review_to_activity(self, _):
|
def test_review_to_activity(self, *_):
|
||||||
""" subclass of the base model version with a "pure" serializer """
|
""" subclass of the base model version with a "pure" serializer """
|
||||||
status = models.Review.objects.create(
|
status = models.Review.objects.create(
|
||||||
name="Review name",
|
name="Review name",
|
||||||
|
@ -262,7 +264,7 @@ class Status(TestCase):
|
||||||
self.assertEqual(activity["content"], "test content")
|
self.assertEqual(activity["content"], "test content")
|
||||||
self.assertEqual(activity["inReplyToBook"], self.book.remote_id)
|
self.assertEqual(activity["inReplyToBook"], self.book.remote_id)
|
||||||
|
|
||||||
def test_review_to_pure_activity(self, _):
|
def test_review_to_pure_activity(self, *_):
|
||||||
""" subclass of the base model version with a "pure" serializer """
|
""" subclass of the base model version with a "pure" serializer """
|
||||||
status = models.Review.objects.create(
|
status = models.Review.objects.create(
|
||||||
name="Review name",
|
name="Review name",
|
||||||
|
@ -285,7 +287,7 @@ class Status(TestCase):
|
||||||
)
|
)
|
||||||
self.assertEqual(activity["attachment"][0].name, "Test Edition")
|
self.assertEqual(activity["attachment"][0].name, "Test Edition")
|
||||||
|
|
||||||
def test_favorite(self, _):
|
def test_favorite(self, *_):
|
||||||
""" fav a status """
|
""" fav a status """
|
||||||
real_broadcast = models.Favorite.broadcast
|
real_broadcast = models.Favorite.broadcast
|
||||||
|
|
||||||
|
@ -311,7 +313,7 @@ class Status(TestCase):
|
||||||
self.assertEqual(activity["object"], status.remote_id)
|
self.assertEqual(activity["object"], status.remote_id)
|
||||||
models.Favorite.broadcast = real_broadcast
|
models.Favorite.broadcast = real_broadcast
|
||||||
|
|
||||||
def test_boost(self, _):
|
def test_boost(self, *_):
|
||||||
""" boosting, this one's a bit fussy """
|
""" boosting, this one's a bit fussy """
|
||||||
status = models.Status.objects.create(
|
status = models.Status.objects.create(
|
||||||
content="test content", user=self.local_user
|
content="test content", user=self.local_user
|
||||||
|
@ -323,7 +325,7 @@ class Status(TestCase):
|
||||||
self.assertEqual(activity["type"], "Announce")
|
self.assertEqual(activity["type"], "Announce")
|
||||||
self.assertEqual(activity, boost.to_activity(pure=True))
|
self.assertEqual(activity, boost.to_activity(pure=True))
|
||||||
|
|
||||||
def test_notification(self, _):
|
def test_notification(self, *_):
|
||||||
""" a simple model """
|
""" a simple model """
|
||||||
notification = models.Notification.objects.create(
|
notification = models.Notification.objects.create(
|
||||||
user=self.local_user, notification_type="FAVORITE"
|
user=self.local_user, notification_type="FAVORITE"
|
||||||
|
@ -335,7 +337,7 @@ class Status(TestCase):
|
||||||
user=self.local_user, notification_type="GLORB"
|
user=self.local_user, notification_type="GLORB"
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_create_broadcast(self, broadcast_mock):
|
def test_create_broadcast(self, _, broadcast_mock):
|
||||||
""" should send out two verions of a status on create """
|
""" should send out two verions of a status on create """
|
||||||
models.Comment.objects.create(
|
models.Comment.objects.create(
|
||||||
content="hi", user=self.local_user, book=self.book
|
content="hi", user=self.local_user, book=self.book
|
||||||
|
@ -355,7 +357,7 @@ class Status(TestCase):
|
||||||
self.assertEqual(args["type"], "Create")
|
self.assertEqual(args["type"], "Create")
|
||||||
self.assertEqual(args["object"]["type"], "Comment")
|
self.assertEqual(args["object"]["type"], "Comment")
|
||||||
|
|
||||||
def test_recipients_with_mentions(self, _):
|
def test_recipients_with_mentions(self, *_):
|
||||||
""" get recipients to broadcast a status """
|
""" get recipients to broadcast a status """
|
||||||
status = models.GeneratedNote.objects.create(
|
status = models.GeneratedNote.objects.create(
|
||||||
content="test content", user=self.local_user
|
content="test content", user=self.local_user
|
||||||
|
@ -364,7 +366,7 @@ class Status(TestCase):
|
||||||
|
|
||||||
self.assertEqual(status.recipients, [self.remote_user])
|
self.assertEqual(status.recipients, [self.remote_user])
|
||||||
|
|
||||||
def test_recipients_with_reply_parent(self, _):
|
def test_recipients_with_reply_parent(self, *_):
|
||||||
""" get recipients to broadcast a status """
|
""" get recipients to broadcast a status """
|
||||||
parent_status = models.GeneratedNote.objects.create(
|
parent_status = models.GeneratedNote.objects.create(
|
||||||
content="test content", user=self.remote_user
|
content="test content", user=self.remote_user
|
||||||
|
@ -375,7 +377,7 @@ class Status(TestCase):
|
||||||
|
|
||||||
self.assertEqual(status.recipients, [self.remote_user])
|
self.assertEqual(status.recipients, [self.remote_user])
|
||||||
|
|
||||||
def test_recipients_with_reply_parent_and_mentions(self, _):
|
def test_recipients_with_reply_parent_and_mentions(self, *_):
|
||||||
""" get recipients to broadcast a status """
|
""" get recipients to broadcast a status """
|
||||||
parent_status = models.GeneratedNote.objects.create(
|
parent_status = models.GeneratedNote.objects.create(
|
||||||
content="test content", user=self.remote_user
|
content="test content", user=self.remote_user
|
||||||
|
@ -388,7 +390,7 @@ class Status(TestCase):
|
||||||
self.assertEqual(status.recipients, [self.remote_user])
|
self.assertEqual(status.recipients, [self.remote_user])
|
||||||
|
|
||||||
@responses.activate
|
@responses.activate
|
||||||
def test_ignore_activity_boost(self, _):
|
def test_ignore_activity_boost(self, *_):
|
||||||
""" don't bother with most remote statuses """
|
""" don't bother with most remote statuses """
|
||||||
activity = activitypub.Announce(
|
activity = activitypub.Announce(
|
||||||
id="http://www.faraway.com/boost/12",
|
id="http://www.faraway.com/boost/12",
|
||||||
|
|
Loading…
Reference in a new issue