More tests
This commit is contained in:
parent
d212cbfd3c
commit
ae81d6cf71
3 changed files with 32 additions and 8 deletions
|
@ -40,14 +40,6 @@ class InboxActivities(TestCase):
|
|||
remote_id="https://example.com/status/1",
|
||||
)
|
||||
|
||||
self.create_json = {
|
||||
"id": "hi",
|
||||
"type": "Create",
|
||||
"actor": "hi",
|
||||
"to": ["https://www.w3.org/ns/activitystreams#public"],
|
||||
"cc": ["https://example.com/user/mouse/followers"],
|
||||
"object": {},
|
||||
}
|
||||
models.SiteSettings.objects.create()
|
||||
|
||||
def test_delete_status(self):
|
||||
|
@ -137,3 +129,20 @@ class InboxActivities(TestCase):
|
|||
# nothing happens.
|
||||
views.inbox.activity_task(activity)
|
||||
self.assertEqual(models.User.objects.filter(is_active=True).count(), 2)
|
||||
|
||||
def test_delete_list(self):
|
||||
"""delete a list"""
|
||||
book_list = models.List.objects.create(
|
||||
name="test list",
|
||||
user=self.remote_user,
|
||||
)
|
||||
activity = {
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
"id": "https://example.com/users/test-user#delete",
|
||||
"type": "Delete",
|
||||
"actor": "https://example.com/users/test-user",
|
||||
"to": ["https://www.w3.org/ns/activitystreams#Public"],
|
||||
"object": book_list.remote_id,
|
||||
}
|
||||
views.inbox.activity_task(activity)
|
||||
self.assertFalse(models.List.objects.exists())
|
||||
|
|
|
@ -87,6 +87,11 @@ class ListActionViews(TestCase):
|
|||
request.user = self.local_user
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay") as mock:
|
||||
views.delete_list(request, self.list.id)
|
||||
activity = json.loads(mock.call_args[0][1])
|
||||
self.assertEqual(activity["type"], "Delete")
|
||||
self.assertEqual(activity["actor"], self.local_user.remote_id)
|
||||
self.assertEqual(activity["object"], self.list.remote_id)
|
||||
|
||||
self.assertEqual(mock.call_count, 1)
|
||||
self.assertFalse(models.List.objects.exists())
|
||||
self.assertFalse(models.ListItem.objects.exists())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue