Coverage for benefits/urls.py: 65%
24 statements
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-22 18:00 +0000
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-22 18:00 +0000
1"""
2benefits URL Configuration
4The `urlpatterns` list routes URLs to views. For more information please see:
5 https://docs.djangoproject.com/en/5.0/topics/http/urls/
6"""
8import logging
10from django.conf import settings
11from django.contrib import admin
12from django.http import HttpResponse
13from django.urls import include, path
14from django.conf.urls.static import static
16logger = logging.getLogger(__name__)
18handler400 = "benefits.core.views.bad_request"
19handler403 = "benefits.core.views.bad_request"
20handler404 = "benefits.core.views.page_not_found"
21handler500 = "benefits.core.views.server_error"
23urlpatterns = [
24 path("", include("benefits.core.urls")),
25 path("eligibility/", include("benefits.eligibility.urls")),
26 path("enrollment/", include("benefits.enrollment.urls")),
27 path("i18n/", include("django.conf.urls.i18n")),
28 path("oauth/", include("benefits.oauth.urls")),
29 path("in_person/", include("benefits.in_person.urls")),
30]
32if settings.DEBUG: 32 ↛ 36line 32 didn't jump to line 36 because the condition on line 32 was never true
33 # based on
34 # https://docs.sentry.io/platforms/python/guides/django/#verify
36 def trigger_error(request):
37 raise RuntimeError("Test error")
39 urlpatterns.append(path("error/", trigger_error))
41 # serve user-uploaded media files
42 # https://docs.djangoproject.com/en/5.1/howto/static-files/#serving-files-uploaded-by-a-user-during-development
43 urlpatterns.extend(static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT))
45 # simple route to read a pre-defined "secret"
46 # this "secret" does not contain sensitive information
47 # and is only configured in the dev environment for testing/debugging
49 def test_secret(request):
50 from benefits.secrets import get_secret_by_name
52 return HttpResponse(get_secret_by_name("testsecret"))
54 urlpatterns.append(path("testsecret/", test_secret))
56logger.debug("Register admin urls")
57urlpatterns.append(path("admin/", admin.site.urls))
58urlpatterns.append(path("google_sso/", include("django_google_sso.urls", namespace="django_google_sso")))