mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 19:41:11 +00:00
Adds deletion test
This commit is contained in:
parent
15344b6a8e
commit
f5de1c903e
1 changed files with 21 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
|||
""" test for app action functionality """
|
||||
import json
|
||||
from unittest.mock import patch
|
||||
from django.template.response import TemplateResponse
|
||||
from django.test import TestCase
|
||||
|
@ -137,3 +138,23 @@ class ReportViews(TestCase):
|
|||
views.unsuspend_user(request, self.rat.id)
|
||||
self.rat.refresh_from_db()
|
||||
self.assertTrue(self.rat.is_active)
|
||||
|
||||
@patch("bookwyrm.suggested_users.rerank_suggestions_task.delay")
|
||||
@patch("bookwyrm.suggested_users.remove_user_task.delay")
|
||||
def test_delete_user(self, *_):
|
||||
"""toggle whether a user is able to log in"""
|
||||
self.assertTrue(self.rat.is_active)
|
||||
request = self.factory.post("", {"password": "password"})
|
||||
request.user = self.local_user
|
||||
request.user.is_superuser = True
|
||||
|
||||
# de-activate
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay") as mock:
|
||||
views.moderator_delete_user(request, self.rat.id)
|
||||
self.assertEqual(mock.call_count, 1)
|
||||
activity = json.loads(mock.call_args[0][1])
|
||||
self.assertEqual(activity["type"], "Delete")
|
||||
|
||||
self.rat.refresh_from_db()
|
||||
self.assertFalse(self.rat.is_active)
|
||||
self.assertEqual(self.rat.deactivation_reason, "moderator_deletion")
|
||||
|
|
Loading…
Reference in a new issue