Skip to content
17 changes: 17 additions & 0 deletions pydotorg/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,20 @@ def test_download_index(self):
self.assertContains(response, "Browse Python 3.6.0 Documentation")
self.assertContains(response, "https://docs.python.org/3/whatsnew/3.6.html")
self.assertContains(response, "What's new in Python 3.6")

def test_legacy_sponsor_redirects(self):
"""Test that old sponsorship pages correctly redirect to modern active ones."""
redirect_cases = (
("/psf/sponsorship-old/", "psf-sponsors"),
("/psf/forms/sponsor-application/", "new_sponsorship_application"),
)
Comment on lines +38 to +43

Copilot AI Mar 31, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expected redirect target for /psf/sponsorship-old/ is asserted as reverse('psf-sponsors'). If the legacy redirect destination changes (e.g., to /psf/sponsorship/), this test needs to be updated to assert against the same canonical target to avoid locking in the wrong behavior.

Copilot uses AI. Check for mistakes.

for source_path, target_name in redirect_cases:
with self.subTest(source_path=source_path, target_name=target_name):
response = self.client.get(source_path)
self.assertRedirects(
response,
reverse(target_name),
status_code=301,
fetch_redirect_response=False,
)
10 changes: 9 additions & 1 deletion pydotorg/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.urls import include, path, re_path
from django.views.generic.base import TemplateView
from django.views.generic.base import RedirectView, TemplateView

from apps.cms.views import custom_404
from apps.downloads.views import ReleaseEditButton
Expand Down Expand Up @@ -35,6 +35,14 @@
path("blogs/", include("apps.blogs.urls")),
path("inner/", TemplateView.as_view(template_name="python/inner.html"), name="inner"),
# other section landing pages
path(
"psf/sponsorship-old/",
RedirectView.as_view(url="/psf/sponsorship/", permanent=True),
),
Comment thread
iampujan marked this conversation as resolved.
path(
"psf/forms/sponsor-application/",
RedirectView.as_view(pattern_name="new_sponsorship_application", permanent=True),
),
path("psf-landing/", TemplateView.as_view(template_name="psf/index.html"), name="psf-landing"),
path("psf/sponsors/", TemplateView.as_view(template_name="psf/sponsors-list.html"), name="psf-sponsors"),
path("docs-landing/", TemplateView.as_view(template_name="docs/index.html"), name="docs-landing"),
Expand Down
Loading