From 3b7facd565f1b4c80ef646afa4b8a8718f5de21c Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Tue, 13 Jun 2023 12:20:11 -0400 Subject: [PATCH] fix: Add names to the error page urls. Some of the static_template_view tests use names to get the URLs for the error pages for testing, so I added names and updated the test to match the new names. I also updated the `test_404` function because we're no longer rendering the 404 page in a different way from the 500 page so the response includes the correct response code and content type. This reduces the number of differences between the 404 handler and the 500 handler. --- lms/djangoapps/static_template_view/tests/test_views.py | 8 ++++---- lms/urls.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lms/djangoapps/static_template_view/tests/test_views.py b/lms/djangoapps/static_template_view/tests/test_views.py index f876c8897b..c8f04fc8c0 100644 --- a/lms/djangoapps/static_template_view/tests/test_views.py +++ b/lms/djangoapps/static_template_view/tests/test_views.py @@ -67,16 +67,16 @@ class MarketingSiteViewTests(TestCase): """ Test the 404 view. """ - url = reverse('static_template_view.views.render_404') + url = reverse('render_404') resp = self.client.get(url) - assert resp.status_code == 200 - assert resp['Content-Type'] == 'text/html' + assert resp.status_code == 404 + assert resp['Content-Type'] == 'text/html; charset=utf-8' def test_500(self): """ Test the 500 view. """ - url = reverse('static_template_view.views.render_500') + url = reverse('render_500') resp = self.client.get(url) assert resp.status_code == 500 assert resp['Content-Type'] == 'text/html; charset=utf-8' diff --git a/lms/urls.py b/lms/urls.py index 58a5cd0a3f..390e6f9c8b 100644 --- a/lms/urls.py +++ b/lms/urls.py @@ -216,10 +216,10 @@ urlpatterns = [ namespace='api_discounts')), # Provide URLs where we can see the rendered error pages without having to force an error. - path('403', handler403), - path('404', handler404), - path('429', handler429), - path('500', handler500), + path('403', handler403, name='render_403'), + path('404', handler404, name='render_404'), + path('429', handler429, name='render_429'), + path('500', handler500, name='render_500'), ] if settings.FEATURES.get('ENABLE_MOBILE_REST_API'):