Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put the carbon-txt-preview route behind a flag #624

Merged
merged 3 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/accounts/admin_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"""
Expand Down Expand Up @@ -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",
Expand Down
14 changes: 14 additions & 0 deletions apps/greencheck/tests/views/test_api_carbon_txt.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

rf = APIRequestFactory()

from waffle.testutils import override_flag


@pytest.fixture
def carbon_txt_string():
Expand Down Expand Up @@ -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:
"""
Expand Down