diff --git a/lacommunaute/templates/layouts/base.html b/lacommunaute/templates/layouts/base.html index 4e49594d..2e2f4752 100644 --- a/lacommunaute/templates/layouts/base.html +++ b/lacommunaute/templates/layouts/base.html @@ -65,14 +65,16 @@ - {% if ENVIRONMENT == "DEV" %} -
-
-

- DEV MODE -

+ {% if ENVIRONMENT %} + {% if ENVIRONMENT != "PROD" %} +
+
+

+ {{ ENVIRONMENT }} MODE +

+
-
+ {% endif %} {% endif %} {% block header %} {% include "partials/header.html" %} diff --git a/lacommunaute/utils/tests/__snapshots__/tests_context_processor.ambr b/lacommunaute/utils/tests/__snapshots__/tests_context_processor.ambr new file mode 100644 index 00000000..a1377425 --- /dev/null +++ b/lacommunaute/utils/tests/__snapshots__/tests_context_processor.ambr @@ -0,0 +1,23 @@ +# serializer version: 1 +# name: test_prod_environment[DEV-True][Dev] + ''' +
+
+

+ DEV MODE +

+
+
+ ''' +# --- +# name: test_prod_environment[TEST-True][Test] + ''' +
+
+

+ TEST MODE +

+
+
+ ''' +# --- diff --git a/lacommunaute/utils/tests/tests_context_processor.py b/lacommunaute/utils/tests/tests_context_processor.py index 4c63ca16..30585371 100644 --- a/lacommunaute/utils/tests/tests_context_processor.py +++ b/lacommunaute/utils/tests/tests_context_processor.py @@ -2,20 +2,25 @@ from django.test import override_settings from lacommunaute.utils.enums import Environment +from lacommunaute.utils.testing import parse_response_to_soup @pytest.mark.parametrize( "env,expected", [ + (None, False), (Environment.PROD, False), - (Environment.TEST, False), + (Environment.TEST, True), (Environment.DEV, True), ], ) -def test_prod_environment(client, db, env, expected): +def test_prod_environment(client, db, env, expected, snapshot): with override_settings(ENVIRONMENT=env): response = client.get("/") assert ('id="debug-mode-banner"' in response.content.decode()) == expected + if expected: + content = parse_response_to_soup(response, selector="#debug-mode-banner") + assert str(content) == snapshot(name=env.label) def test_exposed_settings(client, db):