aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/staff/tests
diff options
context:
space:
mode:
authorGravatar Johannes Christ <[email protected]>2021-06-08 00:26:40 +0200
committerGravatar Johannes Christ <[email protected]>2021-06-08 00:29:59 +0200
commitc998d475440cf4819bad7ebc3ed19f31ce82baf4 (patch)
treebfdeba9a483ebb7646171c79f5b259c27f3d17dd /pydis_site/apps/staff/tests
parentFix `content` app tests not running on macOS (#519) (diff)
Move subdomains to query paths.
In more detail: - Use Django URL namespaces (e.g. `api:bot:infractions`) instead of `django_hosts` host argument. - Update the hosts file setup documentation to remove subdomain entries. - Update the hosts file setup documentation to mention that the entry of `pythondiscord.local` is not required and mainly for convenience. - Rename the `APISubdomainTestCase` to the more fitting `AuthenticatedAPITestCase`, as authentication is all that is left that the class is doing. - Drop dependency to `django_hosts`.
Diffstat (limited to 'pydis_site/apps/staff/tests')
-rw-r--r--pydis_site/apps/staff/tests/test_logs_view.py22
1 files changed, 9 insertions, 13 deletions
diff --git a/pydis_site/apps/staff/tests/test_logs_view.py b/pydis_site/apps/staff/tests/test_logs_view.py
index 00e0ab2f..45e9ce8f 100644
--- a/pydis_site/apps/staff/tests/test_logs_view.py
+++ b/pydis_site/apps/staff/tests/test_logs_view.py
@@ -1,6 +1,6 @@
-from django.test import Client, TestCase
+from django.test import TestCase
+from django.urls import reverse
from django.utils import timezone
-from django_hosts.resolvers import reverse, reverse_host
from pydis_site.apps.api.models.bot import DeletedMessage, MessageDeletionContext, Role, User
from pydis_site.apps.staff.templatetags.deletedmessage_filters import hex_colour
@@ -105,22 +105,18 @@ class TestLogsView(TestCase):
deletion_context=cls.deletion_context,
)
- def setUp(self):
- """Sets up a test client that automatically sets the correct HOST header."""
- self.client = Client(HTTP_HOST=reverse_host(host="staff"))
-
def test_logs_returns_200_for_existing_logs_pk(self):
- url = reverse('logs', host="staff", args=(self.deletion_context.id,))
+ url = reverse('staff:logs', args=(self.deletion_context.id,))
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
def test_logs_returns_404_for_nonexisting_logs_pk(self):
- url = reverse('logs', host="staff", args=(self.deletion_context.id + 100,))
+ url = reverse('staff:logs', args=(self.deletion_context.id + 100,))
response = self.client.get(url)
self.assertEqual(response.status_code, 404)
def test_author_color_is_set_in_response(self):
- url = reverse('logs', host="staff", args=(self.deletion_context.id,))
+ url = reverse('staff:logs', args=(self.deletion_context.id,))
response = self.client.get(url)
role_colour = hex_colour(self.developers_role.colour)
html_needle = (
@@ -129,7 +125,7 @@ class TestLogsView(TestCase):
self.assertInHTML(html_needle, response.content.decode())
def test_correct_messages_have_been_passed_to_template(self):
- url = reverse('logs', host="staff", args=(self.deletion_context.id,))
+ url = reverse('staff:logs', args=(self.deletion_context.id,))
response = self.client.get(url)
self.assertIn("messages", response.context)
self.assertListEqual(
@@ -138,7 +134,7 @@ class TestLogsView(TestCase):
)
def test_if_both_embeds_are_included_html_response(self):
- url = reverse('logs', host="staff", args=(self.deletion_context.id,))
+ url = reverse('staff:logs', args=(self.deletion_context.id,))
response = self.client.get(url)
html_response = response.content.decode()
@@ -151,7 +147,7 @@ class TestLogsView(TestCase):
self.assertInHTML(embed_colour_needle.format(colour=embed_two_colour), html_response)
def test_if_both_attachments_are_included_html_response(self):
- url = reverse('logs', host="staff", args=(self.deletion_context.id,))
+ url = reverse('staff:logs', args=(self.deletion_context.id,))
response = self.client.get(url)
html_response = response.content.decode()
@@ -166,7 +162,7 @@ class TestLogsView(TestCase):
)
def test_if_html_in_content_is_properly_escaped(self):
- url = reverse('logs', host="staff", args=(self.deletion_context.id,))
+ url = reverse('staff:logs', args=(self.deletion_context.id,))
response = self.client.get(url)
html_response = response.content.decode()