aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site
diff options
context:
space:
mode:
authorGravatar ks129 <[email protected]>2021-04-15 16:26:47 +0300
committerGravatar ks129 <[email protected]>2021-05-03 20:19:50 +0300
commit61c48e9bbce7b3a4e683adb08072619a565b38bf (patch)
tree6b3036dfd9ced7220caf784318cf9c859fda772b /pydis_site
parentMigrate redirections definition to not include testing args (diff)
Update redirect app tests to take account recent changes
Diffstat (limited to 'pydis_site')
-rw-r--r--pydis_site/apps/redirect/tests.py33
1 files changed, 28 insertions, 5 deletions
diff --git a/pydis_site/apps/redirect/tests.py b/pydis_site/apps/redirect/tests.py
index 6d670a82..a4bab933 100644
--- a/pydis_site/apps/redirect/tests.py
+++ b/pydis_site/apps/redirect/tests.py
@@ -2,9 +2,13 @@ from django.conf import settings
from django.test import TestCase
from django.urls import reverse
+TESTING_ARGUMENTS = {"resources_resources_redirect": ("reading",)}
+
class RedirectTests(TestCase):
- def test_redirects(self):
+ """Survival tests for redirects."""
+
+ def test_redirects(self) -> None:
"""
Should redirect to given route based on redirect rules.
@@ -12,9 +16,28 @@ class RedirectTests(TestCase):
1. Redirects only once.
2. Redirects to right URL.
"""
- for original_path, (redirect_route, name, args) in settings.REDIRECTIONS.items():
- with self.subTest(original_path=original_path, redirect_route=redirect_route, name=name, args=args):
- resp = self.client.get(reverse(f"home:redirect:{name}", args=args), follow=True)
+ for original_path, (redirect_route, name, static_args) in settings.REDIRECTIONS.items():
+ with self.subTest(
+ original_path=original_path,
+ redirect_route=redirect_route,
+ name=name,
+ static_args=static_args,
+ args=TESTING_ARGUMENTS.get(name, ())
+ ):
+ resp = self.client.get(
+ reverse(
+ f"home:redirect:{name}",
+ args=TESTING_ARGUMENTS.get(name, ())
+ ),
+ follow=True
+ )
self.assertEqual(1, len(resp.redirect_chain))
- self.assertRedirects(resp, reverse(f"home:{redirect_route}", args=args))
+ self.assertRedirects(
+ resp,
+ reverse(
+ f"home:{redirect_route}",
+ args=TESTING_ARGUMENTS.get(name, ()) + static_args
+ ),
+ status_code=301
+ )