From d6b43cd95ec748afa4b11e7175e2c2f64f3fa993 Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Wed, 13 Nov 2024 10:51:16 +0100 Subject: [PATCH 1/3] Put the carbon-txt-preview behind a flag --- apps/accounts/admin_site.py | 6 +++--- apps/greencheck/tests/views/test_api_carbon_txt.py | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/apps/accounts/admin_site.py b/apps/accounts/admin_site.py index 201a22f0..1c03fa94 100644 --- a/apps/accounts/admin_site.py +++ b/apps/accounts/admin_site.py @@ -12,7 +12,7 @@ from django.shortcuts import render from django.urls import path, reverse from django.views.generic.edit import FormView - +from waffle.mixins import WaffleFlagMixin from apps.greencheck.views import GreenUrlsView @@ -88,10 +88,11 @@ def clean(self): ) -class CarbonTxtCheckView(LoginRequiredMixin, FormView): +class CarbonTxtCheckView(WaffleFlagMixin, LoginRequiredMixin, FormView): template_name = "carbon_txt_preview.html" form_class = CarbonTxtForm success_url = "/admin/carbon-txt-preview" + waffle_flag = "carbon-txt-preview" def form_valid(self, form): """Show the valid""" @@ -238,7 +239,6 @@ def get_app_list(self, request, app_label=None): if app_label: return app_list - verification_request_item = { "name": "New provider portal", "app_label": "greencheck", diff --git a/apps/greencheck/tests/views/test_api_carbon_txt.py b/apps/greencheck/tests/views/test_api_carbon_txt.py index 95ea01d0..abf71536 100644 --- a/apps/greencheck/tests/views/test_api_carbon_txt.py +++ b/apps/greencheck/tests/views/test_api_carbon_txt.py @@ -17,6 +17,8 @@ rf = APIRequestFactory() +from waffle.testutils import override_flag + @pytest.fixture def carbon_txt_string(): @@ -84,6 +86,18 @@ def test_carbon_txt_url_and_content( assert response.status_code == 200 + @pytest.mark.parametrize("active,status_code", [(True, 200), (False, 404)]) + def test_carbon_txt_preview_behind_flag( + self, db, settings, client, active, status_code + ): + """ + Check that our preview is now behind a flag + """ + with override_flag("carbon-txt-preview", active=active): + url_path = reverse("greenweb_admin:carbon_txt_preview") + response = client.get(url_path, follow=True) + assert response.status_code == status_code + class TestProviderSharedSecretAPI: """ From 8a898ddee41837d575ba7c02179ae50aca6b20c1 Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Wed, 13 Nov 2024 11:04:16 +0100 Subject: [PATCH 2/3] Update flag name for consistency --- apps/accounts/admin_site.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/accounts/admin_site.py b/apps/accounts/admin_site.py index 1c03fa94..24bd51ec 100644 --- a/apps/accounts/admin_site.py +++ b/apps/accounts/admin_site.py @@ -92,7 +92,7 @@ class CarbonTxtCheckView(WaffleFlagMixin, LoginRequiredMixin, FormView): template_name = "carbon_txt_preview.html" form_class = CarbonTxtForm success_url = "/admin/carbon-txt-preview" - waffle_flag = "carbon-txt-preview" + waffle_flag = "carbon_txt_preview" def form_valid(self, form): """Show the valid""" From 24c71f794a2dd391b82a74c3a22f96420336b379 Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Wed, 13 Nov 2024 11:11:01 +0100 Subject: [PATCH 3/3] Update the test too, duh --- apps/greencheck/tests/views/test_api_carbon_txt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/greencheck/tests/views/test_api_carbon_txt.py b/apps/greencheck/tests/views/test_api_carbon_txt.py index abf71536..609859a2 100644 --- a/apps/greencheck/tests/views/test_api_carbon_txt.py +++ b/apps/greencheck/tests/views/test_api_carbon_txt.py @@ -93,7 +93,7 @@ def test_carbon_txt_preview_behind_flag( """ Check that our preview is now behind a flag """ - with override_flag("carbon-txt-preview", active=active): + with override_flag("carbon_txt_preview", active=active): url_path = reverse("greenweb_admin:carbon_txt_preview") response = client.get(url_path, follow=True) assert response.status_code == status_code