From 8f66feeaa5da34c7c67b0c681503a679ebf8a771 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sun, 2 Oct 2022 19:25:36 +0100 Subject: [PATCH] Remove test 404 and 500 paths outside dev --- .gitlab-ci.yml | 1 + justfile | 2 +- website/settings.py | 2 ++ website/urls.py | 11 +++++++++-- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 51b169d..f53a356 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -64,6 +64,7 @@ test_python: variables: POSTGRES_HOST_AUTH_METHOD: trust DATABASE_URL: postgres://postgres@postgres/postgres + TEST: "true" script: - apt-get update && apt-get install --yes git libpq-dev - ./manage.py collectstatic --noinput --clear diff --git a/justfile b/justfile index 4dfb54e..9ac7434 100644 --- a/justfile +++ b/justfile @@ -24,7 +24,7 @@ build: pip {{ ARGS }} test *ARGS: - ./manage.py test {{ ARGS }} + TEST=true ./manage.py test {{ ARGS }} coverage: coverage run ./manage.py test --keepdb diff --git a/website/settings.py b/website/settings.py index 8ca6110..43cebc0 100644 --- a/website/settings.py +++ b/website/settings.py @@ -12,12 +12,14 @@ env = environ.Env( SPOTIFY_PROXY_HOST=(str, ""), SEO_INDEX=(bool, False), SENTRY_DSN=(str, ""), + TEST=(bool, False), ) # Read local secrets environ.Env.read_env(BASE_DIR / ".env") DEBUG = env("DEBUG") +TEST = env("TEST") SECRET_KEY = env("SECRET_KEY") diff --git a/website/urls.py b/website/urls.py index b9a1278..a76f33a 100644 --- a/website/urls.py +++ b/website/urls.py @@ -40,8 +40,6 @@ urlpatterns = [ KeybaseView.as_view(), name="keybase", ), - path("404/", page_not_found, name="404"), - path("500/", server_error, name="500"), path("feed/", AllPagesFeed(), name="feed"), path(".health/", include("health_check.urls")), path("", include("website.legacy.urls")), @@ -67,6 +65,15 @@ if settings.DEBUG: # Add django-debug-toolbar urlpatterns.append(path("__debug__/", include("debug_toolbar.urls"))) + +if settings.DEBUG or settings.TEST: + urlpatterns.extend( + [ + path("404/", page_not_found, name="404"), + path("500/", server_error, name="500"), + ] + ) + urlpatterns = urlpatterns + [ # For anything not caught by a more specific rule above, hand over to # Wagtail's page serving mechanism. This should be the last pattern in