Skip to content

Commit 491ef25

Browse files
committed
Implement gateway_images_enabled flag
* Replace the existing env var based flag with a shiny new openfeature one This is a basic test implementation that will apply accross all environments currently
1 parent 5fc1866 commit 491ef25

3 files changed

Lines changed: 14 additions & 8 deletions

File tree

manage_breast_screening/mammograms/tests/views/test_appointment_workflow_views.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,12 @@ def test_creates_gateway_action(
242242
mock_send_action.assert_called_once_with(relay, action)
243243

244244
def test_redirects_to_gateway_images_when_enabled(
245-
self, clinical_user_client, monkeypatch, confirmed_identity_appointment
245+
self, clinical_user_client, with_flag_enabled, confirmed_identity_appointment
246246
):
247-
monkeypatch.setenv("GATEWAY_IMAGES_ENABLED", "true")
248-
RelayFactory.create(setting=confirmed_identity_appointment.clinic_slot.clinic.setting)
247+
with_flag_enabled("gateway_images")
248+
RelayFactory.create(
249+
setting=confirmed_identity_appointment.clinic_slot.clinic.setting
250+
)
249251

250252
with patch(
251253
"manage_breast_screening.gateway.relay_service.RelayService.send_action"
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import os
1+
from openfeature import api
22

33
from manage_breast_screening.gateway.models import Relay
44

55

66
def gateway_images_enabled(appointment):
77
"""Check if automatic gateway image retrieval is enabled."""
8-
if os.getenv("GATEWAY_IMAGES_ENABLED", "false").lower() == "true":
8+
feature_flags = api.get_client()
9+
if feature_flags.get_boolean_value("gateway_images", False):
910
return Relay.for_appointment(appointment) is not None
1011
return False

manage_breast_screening/tests/system/clinical/test_gateway_images.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import os
2-
1+
import pytest
32
from django.urls import reverse
43
from playwright.sync_api import expect
54

@@ -18,6 +17,10 @@
1817

1918

2019
class TestGatewayImages(SystemTestCase):
20+
@pytest.fixture(autouse=True)
21+
def flags(self, with_flag_enabled):
22+
self.with_flag_enabled = with_flag_enabled
23+
2124
def test_renders_no_images_content(self):
2225
self.given_i_am_logged_in_as_a_clinical_user()
2326
self.and_there_is_an_appointment()
@@ -63,7 +66,7 @@ def and_there_is_an_appointment(self):
6366
)
6467

6568
def and_gateway_images_are_enabled(self):
66-
os.environ["GATEWAY_IMAGES_ENABLED"] = "true"
69+
self.with_flag_enabled("gateway_images")
6770
RelayFactory(setting=self.appointment.clinic_slot.clinic.setting)
6871

6972
def when_i_visit_the_take_images_page(self):

0 commit comments

Comments
 (0)