@@ -96,7 +96,7 @@ def test_build_environment_api_key_document(django_environment_api_key):
9696
9797
9898def test_build_environment_document_with_multiple_feature_state_versions (
99- django_project ,
99+ django_project , mocker
100100):
101101 # Given
102102 yesterday = utcnow_with_tz () - timedelta (days = 1 )
@@ -108,12 +108,31 @@ def test_build_environment_document_with_multiple_feature_state_versions(
108108 )
109109
110110 # and 3 feature states for the same feature, 2 with live_from dates in the past and
111- # one with a live from date in the future
111+ # one with a live from date in the future. Note that, due to the fact that we are
112+ # using the FeatureState.__gt__ method to compare feature states (which is too
113+ # complicated to replicate here), we're exposing a mock to pass to the __gt__ method
114+ # on the DjangoFeatureState class we're using here. We then mimic the behaviour of
115+ # the method in the FeatureState class in the Django project.
112116 default_fs_kwargs = {"feature" : feature , "live_from" : yesterday , "enabled" : True }
113- feature_state_v1 = DjangoFeatureState (id = 1 , version = 1 , ** default_fs_kwargs )
114- feature_state_v2 = DjangoFeatureState (id = 2 , version = 2 , ** default_fs_kwargs )
117+
118+ gt_mock_fs_1 = mocker .MagicMock (return_value = False )
119+ feature_state_v1 = DjangoFeatureState (
120+ id = 1 , version = 1 , ** default_fs_kwargs , gt_mock = gt_mock_fs_1
121+ )
122+
123+ gt_mock_fs_2 = mocker .MagicMock (return_value = True )
124+ feature_state_v2 = DjangoFeatureState (
125+ id = 2 , version = 2 , ** default_fs_kwargs , gt_mock = gt_mock_fs_2
126+ )
127+
128+ gt_mock_fs_3 = mocker .MagicMock (return_value = False )
115129 feature_state_v3 = DjangoFeatureState (
116- id = 3 , version = 3 , feature = feature , enabled = True , live_from = tomorrow
130+ id = 3 ,
131+ version = 3 ,
132+ feature = feature ,
133+ enabled = True ,
134+ live_from = tomorrow ,
135+ gt_mock = gt_mock_fs_3 ,
117136 )
118137
119138 django_environment = DjangoEnvironment (
@@ -132,21 +151,41 @@ def test_build_environment_document_with_multiple_feature_state_versions(
132151
133152
134153def test_build_identity_document_with_multiple_feature_state_versions (
135- django_environment , django_disabled_feature_state
154+ django_environment , django_disabled_feature_state , mocker
136155):
137156 # Given
138157 yesterday = utcnow_with_tz () - timedelta (days = 1 )
139158 tomorrow = utcnow_with_tz () + timedelta (days = 1 )
140159 feature = django_disabled_feature_state .feature
141160
161+ gt_mock_identity_fs_1 = mocker .MagicMock (return_value = False )
142162 identity_feature_state_v1 = DjangoFeatureState (
143- id = 2 , version = 1 , feature = feature , live_from = yesterday , enabled = True
163+ id = 2 ,
164+ version = 1 ,
165+ feature = feature ,
166+ live_from = yesterday ,
167+ enabled = True ,
168+ gt_mock = gt_mock_identity_fs_1 ,
144169 )
170+
171+ gt_mock_identity_fs_2 = mocker .MagicMock (return_value = True )
145172 identity_feature_state_v2 = DjangoFeatureState (
146- id = 3 , version = 2 , feature = feature , live_from = yesterday , enabled = True
173+ id = 3 ,
174+ version = 2 ,
175+ feature = feature ,
176+ live_from = yesterday ,
177+ enabled = True ,
178+ gt_mock = gt_mock_identity_fs_2 ,
147179 )
180+
181+ gt_mock_identity_fs_3 = mocker .MagicMock (return_value = False )
148182 identity_feature_state_v3 = DjangoFeatureState (
149- id = 3 , version = 2 , feature = feature , live_from = tomorrow , enabled = True
183+ id = 3 ,
184+ version = 2 ,
185+ feature = feature ,
186+ live_from = tomorrow ,
187+ enabled = True ,
188+ gt_mock = gt_mock_identity_fs_3 ,
150189 )
151190 django_identity = DjangoIdentity (
152191 id = 1 ,
0 commit comments