@@ -68,18 +68,18 @@ def test_toggles_rule_does_not_match(mocker, config):
68
68
}
69
69
70
70
conf_store = init_configuration_store (mocker , mocked_app_config_schema , config )
71
- toggle = conf_store .get_feature_toggle (feature_name = "my_feature" , context = {}, value_if_missing = False )
71
+ toggle = conf_store .evaluate (feature_name = "my_feature" , context = {}, default = False )
72
72
assert toggle == expected_value
73
73
74
74
75
75
# this test checks that if you try to get a feature that doesn't exist in the schema,
76
- # you get the default value of False that was sent to the get_feature_toggle API
76
+ # you get the default value of False that was sent to the evaluate API
77
77
def test_toggles_no_conditions_feature_does_not_exist (mocker , config ):
78
78
expected_value = False
79
79
mocked_app_config_schema = {"features" : {"my_fake_feature" : {"feature_default_value" : True }}}
80
80
81
81
conf_store = init_configuration_store (mocker , mocked_app_config_schema , config )
82
- toggle = conf_store .get_feature_toggle (feature_name = "my_feature" , context = {}, value_if_missing = expected_value )
82
+ toggle = conf_store .evaluate (feature_name = "my_feature" , context = {}, default = expected_value )
83
83
assert toggle == expected_value
84
84
85
85
@@ -89,9 +89,7 @@ def test_toggles_no_rules(mocker, config):
89
89
expected_value = True
90
90
mocked_app_config_schema = {"features" : {"my_feature" : {"feature_default_value" : expected_value }}}
91
91
conf_store = init_configuration_store (mocker , mocked_app_config_schema , config )
92
- toggle = conf_store .get_feature_toggle (
93
- feature_name = "my_feature" , context = {"tenant_id" : "6" , "username" : "a" }, value_if_missing = False
94
- )
92
+ toggle = conf_store .evaluate (feature_name = "my_feature" , context = {"tenant_id" : "6" , "username" : "a" }, default = False )
95
93
assert toggle == expected_value
96
94
97
95
@@ -119,9 +117,7 @@ def test_toggles_conditions_no_match(mocker, config):
119
117
},
120
118
}
121
119
conf_store = init_configuration_store (mocker , mocked_app_config_schema , config )
122
- toggle = conf_store .get_feature_toggle (
123
- feature_name = "my_feature" , context = {"tenant_id" : "6" , "username" : "a" }, value_if_missing = False
124
- )
120
+ toggle = conf_store .evaluate (feature_name = "my_feature" , context = {"tenant_id" : "6" , "username" : "a" }, default = False )
125
121
assert toggle == expected_value
126
122
127
123
@@ -156,13 +152,13 @@ def test_toggles_conditions_rule_match_equal_multiple_conditions(mocker, config)
156
152
},
157
153
}
158
154
conf_store = init_configuration_store (mocker , mocked_app_config_schema , config )
159
- toggle = conf_store .get_feature_toggle (
155
+ toggle = conf_store .evaluate (
160
156
feature_name = "my_feature" ,
161
157
context = {
162
158
"tenant_id" : tenant_id_val ,
163
159
"username" : username_val ,
164
160
},
165
- value_if_missing = True ,
161
+ default = True ,
166
162
)
167
163
assert toggle == expected_value
168
164
@@ -198,9 +194,7 @@ def test_toggles_conditions_no_rule_match_equal_multiple_conditions(mocker, conf
198
194
},
199
195
}
200
196
conf_store = init_configuration_store (mocker , mocked_app_config_schema , config )
201
- toggle = conf_store .get_feature_toggle (
202
- feature_name = "my_feature" , context = {"tenant_id" : "6" , "username" : "a" }, value_if_missing = False
203
- )
197
+ toggle = conf_store .evaluate (feature_name = "my_feature" , context = {"tenant_id" : "6" , "username" : "a" }, default = False )
204
198
assert toggle == expected_val
205
199
206
200
@@ -259,25 +253,25 @@ def test_toggles_conditions_rule_match_multiple_actions_multiple_rules_multiple_
259
253
260
254
conf_store = init_configuration_store (mocker , mocked_app_config_schema , config )
261
255
# match first rule
262
- toggle = conf_store .get_feature_toggle (
263
- feature_name = "my_feature" , context = {"tenant_id" : "6" , "username" : "abcd" }, value_if_missing = False
256
+ toggle = conf_store .evaluate (
257
+ feature_name = "my_feature" , context = {"tenant_id" : "6" , "username" : "abcd" }, default = False
264
258
)
265
259
assert toggle == expected_value_first_check
266
260
# match second rule
267
- toggle = conf_store .get_feature_toggle (
268
- feature_name = "my_feature" , context = {"tenant_id" : "4446" , "username" : "az" }, value_if_missing = False
261
+ toggle = conf_store .evaluate (
262
+ feature_name = "my_feature" , context = {"tenant_id" : "4446" , "username" : "az" }, default = False
269
263
)
270
264
assert toggle == expected_value_second_check
271
265
# match no rule
272
- toggle = conf_store .get_feature_toggle (
273
- feature_name = "my_feature" , context = {"tenant_id" : "11114446" , "username" : "ab" }, value_if_missing = False
266
+ toggle = conf_store .evaluate (
267
+ feature_name = "my_feature" , context = {"tenant_id" : "11114446" , "username" : "ab" }, default = False
274
268
)
275
269
assert toggle == expected_value_third_check
276
270
# feature doesn't exist
277
- toggle = conf_store .get_feature_toggle (
271
+ toggle = conf_store .evaluate (
278
272
feature_name = "my_fake_feature" ,
279
273
context = {"tenant_id" : "11114446" , "username" : "ab" },
280
- value_if_missing = expected_value_fourth_case ,
274
+ default = expected_value_fourth_case ,
281
275
)
282
276
assert toggle == expected_value_fourth_case
283
277
@@ -306,9 +300,7 @@ def test_toggles_match_rule_with_contains_action(mocker, config):
306
300
},
307
301
}
308
302
conf_store = init_configuration_store (mocker , mocked_app_config_schema , config )
309
- toggle = conf_store .get_feature_toggle (
310
- feature_name = "my_feature" , context = {"tenant_id" : "6" , "username" : "a" }, value_if_missing = False
311
- )
303
+ toggle = conf_store .evaluate (feature_name = "my_feature" , context = {"tenant_id" : "6" , "username" : "a" }, default = False )
312
304
assert toggle == expected_value
313
305
314
306
@@ -335,9 +327,7 @@ def test_toggles_no_match_rule_with_contains_action(mocker, config):
335
327
},
336
328
}
337
329
conf_store = init_configuration_store (mocker , mocked_app_config_schema , config )
338
- toggle = conf_store .get_feature_toggle (
339
- feature_name = "my_feature" , context = {"tenant_id" : "6" , "username" : "a" }, value_if_missing = False
340
- )
330
+ toggle = conf_store .evaluate (feature_name = "my_feature" , context = {"tenant_id" : "6" , "username" : "a" }, default = False )
341
331
assert toggle == expected_value
342
332
343
333
@@ -425,10 +415,10 @@ def test_get_feature_toggle_handles_error(mocker, config):
425
415
schema_fetcher = init_fetcher_side_effect (mocker , config , GetParameterError ())
426
416
conf_store = FeatureFlags (schema_fetcher )
427
417
428
- # WHEN calling get_feature_toggle
429
- toggle = conf_store .get_feature_toggle (feature_name = "Foo" , value_if_missing = False )
418
+ # WHEN calling evaluate
419
+ toggle = conf_store .evaluate (feature_name = "Foo" , default = False )
430
420
431
- # THEN handle the error and return the value_if_missing
421
+ # THEN handle the error and return the default
432
422
assert toggle is False
433
423
434
424
0 commit comments