Add test for sentry-debug endpoint

This commit is contained in:
2024-10-15 14:09:51 +02:00
parent d16a207a83
commit c1a85486cc
3 changed files with 42 additions and 6 deletions

View File

@@ -17,6 +17,7 @@ from ajax_select import urls as ajax_select_urls
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.http import Http404
from django.urls import include, path
from django.views.i18n import JavaScriptCatalog
from ninja_extra import NinjaExtraAPI
@@ -71,11 +72,12 @@ if settings.DEBUG:
urlpatterns += [path("__debug__/", include(debug_toolbar.urls))]
if settings.SENTRY_ENV == "development" and settings.SENTRY_DSN:
def sentry_debug(request):
"""Sentry debug endpoint
This function always crash and allows us to test
the sentry configuration and the modal popup
the sentry configuration and the modal popup
displayed to users on production
The error will be displayed on Sentry
@@ -83,8 +85,9 @@ if settings.SENTRY_ENV == "development" and settings.SENTRY_DSN:
NOTE : you need to specify the SENTRY_DSN setting in settings_custom.py
"""
if settings.SENTRY_ENV != "development" or not settings.SENTRY_DSN:
raise Http404
_division_by_zero = 1 / 0
def raise_exception(request):
_division_by_zero = 1 / 0
urlpatterns += [path("sentry-debug/", raise_exception)]
urlpatterns += [path("sentry-debug/", sentry_debug, name="sentry-debug")]