mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-30 05:21:08 +00:00
Updates tests
This commit is contained in:
parent
da19089d34
commit
35cb3fa8fc
3 changed files with 18 additions and 11 deletions
|
@ -3,8 +3,8 @@
|
||||||
{% load bookwyrm_tags %}
|
{% load bookwyrm_tags %}
|
||||||
{% load humanize %}
|
{% load humanize %}
|
||||||
|
|
||||||
{% block title %}{{ username }}{% endblock %}
|
{% block title %}{{ user.username }}{% endblock %}
|
||||||
{% block header %}{{ username }}{% endblock %}
|
{% block header %}{{ user.username }}{% endblock %}
|
||||||
|
|
||||||
{% block panel %}
|
{% block panel %}
|
||||||
<div class="block">
|
<div class="block">
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
""" test for app action functionality """
|
""" test for app action functionality """
|
||||||
from unittest.mock import patch
|
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.test.client import RequestFactory
|
from django.test.client import RequestFactory
|
||||||
|
@ -115,22 +114,19 @@ class ReportViews(TestCase):
|
||||||
report.refresh_from_db()
|
report.refresh_from_db()
|
||||||
self.assertFalse(report.resolved)
|
self.assertFalse(report.resolved)
|
||||||
|
|
||||||
def test_deactivate_user(self):
|
def test_suspend_user(self):
|
||||||
""" toggle whether a user is able to log in """
|
""" toggle whether a user is able to log in """
|
||||||
self.assertTrue(self.rat.is_active)
|
self.assertTrue(self.rat.is_active)
|
||||||
report = models.Report.objects.create(reporter=self.local_user, user=self.rat)
|
|
||||||
request = self.factory.post("")
|
request = self.factory.post("")
|
||||||
request.user = self.local_user
|
request.user = self.local_user
|
||||||
request.user.is_superuser = True
|
request.user.is_superuser = True
|
||||||
|
|
||||||
# de-activate
|
# de-activate
|
||||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
views.suspend_user(request, self.local_user.id)
|
||||||
views.deactivate_user(request, report.id)
|
|
||||||
self.rat.refresh_from_db()
|
self.rat.refresh_from_db()
|
||||||
self.assertFalse(self.rat.is_active)
|
self.assertFalse(self.rat.is_active)
|
||||||
|
|
||||||
# re-activate
|
# re-activate
|
||||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
views.suspend_user(request, self.local_user.id)
|
||||||
views.deactivate_user(request, report.id)
|
|
||||||
self.rat.refresh_from_db()
|
self.rat.refresh_from_db()
|
||||||
self.assertTrue(self.rat.is_active)
|
self.assertTrue(self.rat.is_active)
|
||||||
|
|
|
@ -21,9 +21,9 @@ class UserAdminViews(TestCase):
|
||||||
)
|
)
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
def test_user_admin_page(self):
|
def test_user_admin_list_page(self):
|
||||||
""" there are so many views, this just makes sure it LOADS """
|
""" there are so many views, this just makes sure it LOADS """
|
||||||
view = views.UserAdmin.as_view()
|
view = views.UserAdminList.as_view()
|
||||||
request = self.factory.get("")
|
request = self.factory.get("")
|
||||||
request.user = self.local_user
|
request.user = self.local_user
|
||||||
request.user.is_superuser = True
|
request.user.is_superuser = True
|
||||||
|
@ -31,3 +31,14 @@ class UserAdminViews(TestCase):
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
result.render()
|
result.render()
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|
||||||
|
def test_user_admin_page(self):
|
||||||
|
""" there are so many views, this just makes sure it LOADS """
|
||||||
|
view = views.UserAdmin.as_view()
|
||||||
|
request = self.factory.get("")
|
||||||
|
request.user = self.local_user
|
||||||
|
request.user.is_superuser = True
|
||||||
|
result = view(request, self.local_user)
|
||||||
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
|
result.render()
|
||||||
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|
Loading…
Reference in a new issue