From e4c94aa971c3f974563ae083ebed8534bb25b24c Mon Sep 17 00:00:00 2001 From: Matt <38562764+LavMatt@users.noreply.github.com> Date: Thu, 10 Oct 2024 14:15:55 +0100 Subject: [PATCH] feat: add switch for table details is_nullable column (#927) * feat: add switch for table details is_nullable column we are turning this off because currently metadata are not accurate * test: update unit test to mock waffle switch --- Makefile | 1 + templates/details_table.html | 9 +++++++-- tests/test_views.py | 14 ++++++++++---- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 01c139c5..f87ee910 100644 --- a/Makefile +++ b/Makefile @@ -54,6 +54,7 @@ migrate: setup_waffle_switches: poetry run python manage.py waffle_switch search-sort-radio-buttons off --create poetry run python manage.py waffle_switch display-result-tags off --create + poetry run python manage.py waffle_switch show_is_nullable_in_table_details_column off --create # Run makemessages messages: diff --git a/templates/details_table.html b/templates/details_table.html index da9835b7..fbe10eda 100644 --- a/templates/details_table.html +++ b/templates/details_table.html @@ -1,6 +1,7 @@ {% extends "details_base.html" %} {% load markdown %} {% load i18n %} +{% load waffle_tags %} {% block extra_details %}
@@ -13,7 +14,9 @@ {% translate "Column name" %} {% translate "Description" %} {% translate "Type" %} - {% translate "Is Nullable" %} + {% switch 'show_is_nullable_in_table_details_column' %} + {% translate "Is Nullable" %} + {% endswitch %} @@ -28,7 +31,9 @@ {% endif %} {{column.type|title}} - {{column.nullable|yesno:"Yes,No,"}} + {% switch 'show_is_nullable_in_table_details_column' %} + {{column.nullable|yesno:"Yes,No,"}} + {% endswitch %} {% endfor %} diff --git a/tests/test_views.py b/tests/test_views.py index 28b6acc8..0a0000e5 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -1,5 +1,6 @@ import pytest from django.urls import reverse +from waffle.testutils import override_switch class TestHomePage: @@ -41,10 +42,15 @@ def test_bad_form(self, client): class TestTableView: - def test_table(self, client): - response = client.get( - reverse("home:details", kwargs={"urn": "fake", "result_type": "table"}) - ) + @pytest.mark.parametrize("switch_bool", [True, False]) + @pytest.mark.django_db + def test_table(self, client, switch_bool): + with override_switch( + name="show_is_nullable_in_table_details_column", active=switch_bool + ): + response = client.get( + reverse("home:details", kwargs={"urn": "fake", "result_type": "table"}) + ) assert response.status_code == 200 assert response.headers["Cache-Control"] == "max-age=300, private"