Coverage for benefits/urls.py: 65%

24 statements  

« prev     ^ index     » next       coverage.py v7.6.7, created at 2024-11-22 18:00 +0000

1""" 

2benefits URL Configuration 

3 

4The `urlpatterns` list routes URLs to views. For more information please see: 

5 https://docs.djangoproject.com/en/5.0/topics/http/urls/ 

6""" 

7 

8import logging 

9 

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 

15 

16logger = logging.getLogger(__name__) 

17 

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" 

22 

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] 

31 

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 

35 

36 def trigger_error(request): 

37 raise RuntimeError("Test error") 

38 

39 urlpatterns.append(path("error/", trigger_error)) 

40 

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)) 

44 

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 

48 

49 def test_secret(request): 

50 from benefits.secrets import get_secret_by_name 

51 

52 return HttpResponse(get_secret_by_name("testsecret")) 

53 

54 urlpatterns.append(path("testsecret/", test_secret)) 

55 

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")))