|
1 | 1 | import datetime
|
2 | 2 | import os
|
| 3 | +from http import HTTPStatus |
3 | 4 | from operator import attrgetter
|
4 | 5 | from pathlib import Path
|
5 | 6 |
|
6 | 7 | from django.conf import settings
|
7 | 8 | from django.contrib.sites.models import Site
|
8 | 9 | from django.template import Context, Template
|
9 | 10 | from django.test import TestCase
|
10 |
| -from django.urls import set_urlconf |
| 11 | +from django.urls import reverse, set_urlconf |
11 | 12 |
|
| 13 | +from djangoproject.urls import www as www_urls |
12 | 14 | from releases.models import Release
|
13 | 15 |
|
14 | 16 | from .models import Document, DocumentRelease
|
@@ -123,6 +125,30 @@ def test_get_available_languages_by_version(self):
|
123 | 125 | self.assertEqual(list(get('3.0')), [])
|
124 | 126 |
|
125 | 127 |
|
| 128 | +class RedirectsTests(TestCase): |
| 129 | + |
| 130 | + @classmethod |
| 131 | + def tearDownClass(cls): |
| 132 | + # cleanup URLconfs changed by django-hosts |
| 133 | + set_urlconf(None) |
| 134 | + super().tearDownClass() |
| 135 | + |
| 136 | + def test_team_url(self): |
| 137 | + # This URL is linked from the docs. |
| 138 | + self.assertEqual('/foundation/teams/', reverse('members:teams', urlconf=www_urls)) |
| 139 | + |
| 140 | + def test_internals_team(self): |
| 141 | + response = self.client.get( |
| 142 | + '/en/dev/internals/team/', |
| 143 | + HTTP_HOST='docs.djangoproject.dev:8000', |
| 144 | + ) |
| 145 | + self.assertRedirects( |
| 146 | + response, |
| 147 | + 'https://www.djangoproject.com/foundation/teams/', |
| 148 | + status_code=HTTPStatus.MOVED_PERMANENTLY, |
| 149 | + ) |
| 150 | + |
| 151 | + |
126 | 152 | class SearchFormTestCase(TestCase):
|
127 | 153 | fixtures = ['doc_test_fixtures']
|
128 | 154 |
|
|
0 commit comments