99from responses import matchers
1010
1111from flagsmith import Flagsmith , __version__
12+ from flagsmith .api .types import EnvironmentModel
1213from flagsmith .exceptions import (
1314 FlagsmithAPIError ,
1415 FlagsmithFeatureDoesNotExistError ,
@@ -545,11 +546,11 @@ def test_initialise_flagsmith_with_proxies() -> None:
545546 assert flagsmith .session .proxies == proxies
546547
547548
548- def test_offline_mode (evaluation_context : SDKEvaluationContext ) -> None :
549+ def test_offline_mode (environment : EnvironmentModel ) -> None :
549550 # Given
550551 class DummyOfflineHandler :
551- def get_evaluation_context (self ) -> SDKEvaluationContext :
552- return evaluation_context
552+ def get_environment (self ) -> EnvironmentModel :
553+ return environment
553554
554555 # When
555556 flagsmith = Flagsmith (offline_mode = True , offline_handler = DummyOfflineHandler ())
@@ -566,12 +567,12 @@ def get_evaluation_context(self) -> SDKEvaluationContext:
566567@responses .activate ()
567568def test_flagsmith_uses_offline_handler_if_set_and_no_api_response (
568569 mocker : MockerFixture ,
569- evaluation_context : SDKEvaluationContext ,
570+ environment : EnvironmentModel ,
570571) -> None :
571572 # Given
572573 api_url = "http://some.flagsmith.com/api/v1/"
573574 mock_offline_handler = mocker .MagicMock (spec = OfflineHandler )
574- mock_offline_handler .get_evaluation_context .return_value = evaluation_context
575+ mock_offline_handler .get_environment .return_value = environment
575576
576577 flagsmith = Flagsmith (
577578 environment_key = "some-key" ,
@@ -587,7 +588,7 @@ def test_flagsmith_uses_offline_handler_if_set_and_no_api_response(
587588 identity_flags = flagsmith .get_identity_flags ("identity" , traits = {})
588589
589590 # Then
590- mock_offline_handler .get_evaluation_context .assert_called_once_with ()
591+ mock_offline_handler .get_environment .assert_called_once_with ()
591592
592593 assert environment_flags .is_feature_enabled ("some_feature" ) is True
593594 assert environment_flags .get_feature_value ("some_feature" ) == "some-value"
@@ -599,13 +600,13 @@ def test_flagsmith_uses_offline_handler_if_set_and_no_api_response(
599600@responses .activate ()
600601def test_offline_mode__local_evaluation__correct_fallback (
601602 mocker : MockerFixture ,
602- evaluation_context : SDKEvaluationContext ,
603+ environment : EnvironmentModel ,
603604 caplog : pytest .LogCaptureFixture ,
604605) -> None :
605606 # Given
606607 api_url = "http://some.flagsmith.com/api/v1/"
607608 mock_offline_handler = mocker .MagicMock (spec = OfflineHandler )
608- mock_offline_handler .get_evaluation_context .return_value = evaluation_context
609+ mock_offline_handler .get_environment .return_value = environment
609610
610611 mocker .patch ("flagsmith.flagsmith.EnvironmentDataPollingManager" )
611612
@@ -623,7 +624,7 @@ def test_offline_mode__local_evaluation__correct_fallback(
623624 identity_flags = flagsmith .get_identity_flags ("identity" , traits = {})
624625
625626 # Then
626- mock_offline_handler .get_evaluation_context .assert_called_once_with ()
627+ mock_offline_handler .get_environment .assert_called_once_with ()
627628
628629 assert environment_flags .is_feature_enabled ("some_feature" ) is True
629630 assert environment_flags .get_feature_value ("some_feature" ) == "some-value"
0 commit comments