mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-26 01:50:34 +00:00
Fixes tests and incorrect class method reference
This commit is contained in:
parent
b3a519c082
commit
affaf3d0ba
2 changed files with 25 additions and 9 deletions
|
@ -78,8 +78,8 @@ class ReportViews(TestCase):
|
||||||
validate_html(result.render())
|
validate_html(result.render())
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|
||||||
def test_report_comment(self):
|
def test_report_action(self):
|
||||||
"""comment on a report"""
|
"""action on a report"""
|
||||||
view = views.ReportAdmin.as_view()
|
view = views.ReportAdmin.as_view()
|
||||||
request = self.factory.post("", {"note": "hi"})
|
request = self.factory.post("", {"note": "hi"})
|
||||||
request.user = self.local_user
|
request.user = self.local_user
|
||||||
|
@ -87,15 +87,17 @@ class ReportViews(TestCase):
|
||||||
|
|
||||||
view(request, report.id)
|
view(request, report.id)
|
||||||
|
|
||||||
comment = models.ReportComment.objects.get()
|
action = models.ReportAction.objects.get()
|
||||||
self.assertEqual(comment.user, self.local_user)
|
self.assertEqual(action.user, self.local_user)
|
||||||
self.assertEqual(comment.note, "hi")
|
self.assertEqual(action.note, "hi")
|
||||||
self.assertEqual(comment.report, report)
|
self.assertEqual(action.report, report)
|
||||||
|
self.assertEqual(action.action_type, "comment")
|
||||||
|
|
||||||
def test_resolve_report(self):
|
def test_resolve_report(self):
|
||||||
"""toggle report resolution status"""
|
"""toggle report resolution status"""
|
||||||
report = models.Report.objects.create(reporter=self.local_user, user=self.rat)
|
report = models.Report.objects.create(reporter=self.local_user, user=self.rat)
|
||||||
self.assertFalse(report.resolved)
|
self.assertFalse(report.resolved)
|
||||||
|
self.assertFalse(models.ReportAction.objects.exists())
|
||||||
request = self.factory.post("")
|
request = self.factory.post("")
|
||||||
request.user = self.local_user
|
request.user = self.local_user
|
||||||
|
|
||||||
|
@ -104,11 +106,25 @@ class ReportViews(TestCase):
|
||||||
report.refresh_from_db()
|
report.refresh_from_db()
|
||||||
self.assertTrue(report.resolved)
|
self.assertTrue(report.resolved)
|
||||||
|
|
||||||
|
# check that the action was noted
|
||||||
|
self.assertTrue(
|
||||||
|
models.ReportAction.objects.filter(
|
||||||
|
report=report, action_type="resolve", user=self.local_user
|
||||||
|
).exists()
|
||||||
|
)
|
||||||
|
|
||||||
# un-resolve
|
# un-resolve
|
||||||
views.resolve_report(request, report.id)
|
views.resolve_report(request, report.id)
|
||||||
report.refresh_from_db()
|
report.refresh_from_db()
|
||||||
self.assertFalse(report.resolved)
|
self.assertFalse(report.resolved)
|
||||||
|
|
||||||
|
# check that the action was noted
|
||||||
|
self.assertTrue(
|
||||||
|
models.ReportAction.objects.filter(
|
||||||
|
report=report, action_type="reopen", user=self.local_user
|
||||||
|
).exists()
|
||||||
|
)
|
||||||
|
|
||||||
@patch("bookwyrm.suggested_users.rerank_suggestions_task.delay")
|
@patch("bookwyrm.suggested_users.rerank_suggestions_task.delay")
|
||||||
@patch("bookwyrm.activitystreams.populate_stream_task.delay")
|
@patch("bookwyrm.activitystreams.populate_stream_task.delay")
|
||||||
@patch("bookwyrm.suggested_users.remove_user_task.delay")
|
@patch("bookwyrm.suggested_users.remove_user_task.delay")
|
||||||
|
|
|
@ -97,7 +97,7 @@ def suspend_user(request, user_id, report_id=None):
|
||||||
# this isn't a full deletion, so we don't want to tell the world
|
# this isn't a full deletion, so we don't want to tell the world
|
||||||
user.save(broadcast=False)
|
user.save(broadcast=False)
|
||||||
|
|
||||||
models.ReportAction.record_action(report_id, USER_SUSPENSION, request.user)
|
models.Report.record_action(report_id, USER_SUSPENSION, request.user)
|
||||||
return redirect_to_referer(request, "settings-user", user.id)
|
return redirect_to_referer(request, "settings-user", user.id)
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ def unsuspend_user(request, user_id, report_id=None):
|
||||||
# this isn't a full deletion, so we don't want to tell the world
|
# this isn't a full deletion, so we don't want to tell the world
|
||||||
user.save(broadcast=False)
|
user.save(broadcast=False)
|
||||||
|
|
||||||
models.ReportAction.record_action(report_id, USER_UNSUSPENSION, request.user)
|
models.Report.record_action(report_id, USER_UNSUSPENSION, request.user)
|
||||||
return redirect_to_referer(request, "settings-user", user.id)
|
return redirect_to_referer(request, "settings-user", user.id)
|
||||||
|
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ def moderator_delete_user(request, user_id, report_id=None):
|
||||||
user.delete()
|
user.delete()
|
||||||
|
|
||||||
# make a note of the fact that we did this
|
# make a note of the fact that we did this
|
||||||
models.ReportAction.record_action(report_id, USER_DELETION, request.user)
|
models.Report.record_action(report_id, USER_DELETION, request.user)
|
||||||
return redirect_to_referer(request, "settings-user", user.id)
|
return redirect_to_referer(request, "settings-user", user.id)
|
||||||
|
|
||||||
form.errors["password"] = ["Invalid password"]
|
form.errors["password"] = ["Invalid password"]
|
||||||
|
|
Loading…
Reference in a new issue