diff --git a/apps/accounts/admin_site.py b/apps/accounts/admin_site.py index 201a22f0..24bd51ec 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..609859a2 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: """