@@ -43,7 +43,7 @@ def init_fetcher_side_effect(mocker, config: Config, side_effect) -> AppConfigFe
43
43
44
44
45
45
# this test checks that we get correct value of feature that exists in the schema.
46
- # we also don't send an empty rules_context dict in this case
46
+ # we also don't send an empty context dict in this case
47
47
def test_toggles_rule_does_not_match (mocker , config ):
48
48
expected_value = True
49
49
mocked_app_config_schema = {
@@ -68,7 +68,7 @@ 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" , rules_context = {}, value_if_missing = False )
71
+ toggle = conf_store .get_feature_toggle (feature_name = "my_feature" , context = {}, value_if_missing = False )
72
72
assert toggle == expected_value
73
73
74
74
@@ -79,18 +79,18 @@ def test_toggles_no_conditions_feature_does_not_exist(mocker, config):
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" , rules_context = {}, value_if_missing = expected_value )
82
+ toggle = conf_store .get_feature_toggle (feature_name = "my_feature" , context = {}, value_if_missing = expected_value )
83
83
assert toggle == expected_value
84
84
85
85
86
- # check that feature match works when they are no rules and we send rules_context .
86
+ # check that feature match works when they are no rules and we send context .
87
87
# default value is False but the feature has a True default_value.
88
88
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
92
toggle = conf_store .get_feature_toggle (
93
- feature_name = "my_feature" , rules_context = {"tenant_id" : "6" , "username" : "a" }, value_if_missing = False
93
+ feature_name = "my_feature" , context = {"tenant_id" : "6" , "username" : "a" }, value_if_missing = False
94
94
)
95
95
assert toggle == expected_value
96
96
@@ -120,9 +120,7 @@ def test_toggles_conditions_no_match(mocker, config):
120
120
}
121
121
conf_store = init_configuration_store (mocker , mocked_app_config_schema , config )
122
122
toggle = conf_store .get_feature_toggle (
123
- feature_name = "my_feature" ,
124
- rules_context = {"tenant_id" : "6" , "username" : "a" }, # rule will not match
125
- value_if_missing = False ,
123
+ feature_name = "my_feature" , context = {"tenant_id" : "6" , "username" : "a" }, value_if_missing = False
126
124
)
127
125
assert toggle == expected_value
128
126
@@ -160,7 +158,7 @@ def test_toggles_conditions_rule_match_equal_multiple_conditions(mocker, config)
160
158
conf_store = init_configuration_store (mocker , mocked_app_config_schema , config )
161
159
toggle = conf_store .get_feature_toggle (
162
160
feature_name = "my_feature" ,
163
- rules_context = {
161
+ context = {
164
162
"tenant_id" : tenant_id_val ,
165
163
"username" : username_val ,
166
164
},
@@ -201,7 +199,7 @@ def test_toggles_conditions_no_rule_match_equal_multiple_conditions(mocker, conf
201
199
}
202
200
conf_store = init_configuration_store (mocker , mocked_app_config_schema , config )
203
201
toggle = conf_store .get_feature_toggle (
204
- feature_name = "my_feature" , rules_context = {"tenant_id" : "6" , "username" : "a" }, value_if_missing = False
202
+ feature_name = "my_feature" , context = {"tenant_id" : "6" , "username" : "a" }, value_if_missing = False
205
203
)
206
204
assert toggle == expected_val
207
205
@@ -262,29 +260,23 @@ def test_toggles_conditions_rule_match_multiple_actions_multiple_rules_multiple_
262
260
conf_store = init_configuration_store (mocker , mocked_app_config_schema , config )
263
261
# match first rule
264
262
toggle = conf_store .get_feature_toggle (
265
- feature_name = "my_feature" ,
266
- rules_context = {"tenant_id" : "6" , "username" : "abcd" },
267
- value_if_missing = False ,
263
+ feature_name = "my_feature" , context = {"tenant_id" : "6" , "username" : "abcd" }, value_if_missing = False
268
264
)
269
265
assert toggle == expected_value_first_check
270
266
# match second rule
271
267
toggle = conf_store .get_feature_toggle (
272
- feature_name = "my_feature" ,
273
- rules_context = {"tenant_id" : "4446" , "username" : "az" },
274
- value_if_missing = False ,
268
+ feature_name = "my_feature" , context = {"tenant_id" : "4446" , "username" : "az" }, value_if_missing = False
275
269
)
276
270
assert toggle == expected_value_second_check
277
271
# match no rule
278
272
toggle = conf_store .get_feature_toggle (
279
- feature_name = "my_feature" ,
280
- rules_context = {"tenant_id" : "11114446" , "username" : "ab" },
281
- value_if_missing = False ,
273
+ feature_name = "my_feature" , context = {"tenant_id" : "11114446" , "username" : "ab" }, value_if_missing = False
282
274
)
283
275
assert toggle == expected_value_third_check
284
276
# feature doesn't exist
285
277
toggle = conf_store .get_feature_toggle (
286
278
feature_name = "my_fake_feature" ,
287
- rules_context = {"tenant_id" : "11114446" , "username" : "ab" },
279
+ context = {"tenant_id" : "11114446" , "username" : "ab" },
288
280
value_if_missing = expected_value_fourth_case ,
289
281
)
290
282
assert toggle == expected_value_fourth_case
@@ -315,9 +307,7 @@ def test_toggles_match_rule_with_contains_action(mocker, config):
315
307
}
316
308
conf_store = init_configuration_store (mocker , mocked_app_config_schema , config )
317
309
toggle = conf_store .get_feature_toggle (
318
- feature_name = "my_feature" ,
319
- rules_context = {"tenant_id" : "6" , "username" : "a" }, # rule will match
320
- value_if_missing = False ,
310
+ feature_name = "my_feature" , context = {"tenant_id" : "6" , "username" : "a" }, value_if_missing = False
321
311
)
322
312
assert toggle == expected_value
323
313
@@ -346,9 +336,7 @@ def test_toggles_no_match_rule_with_contains_action(mocker, config):
346
336
}
347
337
conf_store = init_configuration_store (mocker , mocked_app_config_schema , config )
348
338
toggle = conf_store .get_feature_toggle (
349
- feature_name = "my_feature" ,
350
- rules_context = {"tenant_id" : "6" , "username" : "a" }, # rule will not match
351
- value_if_missing = False ,
339
+ feature_name = "my_feature" , context = {"tenant_id" : "6" , "username" : "a" }, value_if_missing = False
352
340
)
353
341
assert toggle == expected_value
354
342
@@ -379,9 +367,7 @@ def test_multiple_features_enabled(mocker, config):
379
367
},
380
368
}
381
369
conf_store = init_configuration_store (mocker , mocked_app_config_schema , config )
382
- enabled_list : List [str ] = conf_store .get_all_enabled_feature_toggles (
383
- rules_context = {"tenant_id" : "6" , "username" : "a" }
384
- )
370
+ enabled_list : List [str ] = conf_store .get_all_enabled_feature_toggles (context = {"tenant_id" : "6" , "username" : "a" })
385
371
assert enabled_list == expected_value
386
372
387
373
@@ -430,9 +416,7 @@ def test_multiple_features_only_some_enabled(mocker, config):
430
416
},
431
417
}
432
418
conf_store = init_configuration_store (mocker , mocked_app_config_schema , config )
433
- enabled_list : List [str ] = conf_store .get_all_enabled_feature_toggles (
434
- rules_context = {"tenant_id" : "6" , "username" : "a" }
435
- )
419
+ enabled_list : List [str ] = conf_store .get_all_enabled_feature_toggles (context = {"tenant_id" : "6" , "username" : "a" })
436
420
assert enabled_list == expected_value
437
421
438
422
@@ -454,7 +438,7 @@ def test_get_all_enabled_feature_toggles_handles_error(mocker, config):
454
438
conf_store = ConfigurationStore (schema_fetcher )
455
439
456
440
# WHEN calling get_all_enabled_feature_toggles
457
- toggles = conf_store .get_all_enabled_feature_toggles (rules_context = None )
441
+ toggles = conf_store .get_all_enabled_feature_toggles (context = None )
458
442
459
443
# THEN handle the error and return an empty list
460
444
assert toggles == []
0 commit comments