@@ -32,11 +32,11 @@ def test_toggles_rule_does_not_match(mocker, config):
32
32
"log_level" : "DEBUG" ,
33
33
"features" : {
34
34
"my_feature" : {
35
- "default_value " : expected_value ,
35
+ "feature_default_value " : expected_value ,
36
36
"rules" : [
37
37
{
38
38
"name" : "tenant id equals 345345435" ,
39
- "default_value " : "False" ,
39
+ "rule_default_value " : "False" ,
40
40
"restrictions" : [
41
41
{
42
42
"action" : ACTION .EQUALS .value ,
@@ -51,29 +51,29 @@ def test_toggles_rule_does_not_match(mocker, config):
51
51
}
52
52
53
53
conf_store = init_configuration_store (mocker , mocked_app_config_schema , config )
54
- toggle = conf_store .get_feature_toggle (feature_name = "my_feature" , rules_context = {}, default_value = False )
54
+ toggle = conf_store .get_feature_toggle (feature_name = "my_feature" , rules_context = {}, value_if_missing = False )
55
55
assert str (toggle ) == expected_value
56
56
57
57
58
58
# this test checks that if you try to get a feature that doesn't exist in the schema,
59
59
# you get the default value of False that was sent to the get_feature_toggle API
60
60
def test_toggles_no_restrictions_feature_does_not_exist (mocker , config ):
61
61
expected_value = False
62
- mocked_app_config_schema = {"log_level" : "DEBUG" , "features" : {"my_fake_feature" : {"default_value " : "True" }}}
62
+ mocked_app_config_schema = {"log_level" : "DEBUG" , "features" : {"my_fake_feature" : {"feature_default_value " : "True" }}}
63
63
64
64
conf_store = init_configuration_store (mocker , mocked_app_config_schema , config )
65
- toggle = conf_store .get_feature_toggle (feature_name = "my_feature" , rules_context = {}, default_value = expected_value )
65
+ toggle = conf_store .get_feature_toggle (feature_name = "my_feature" , rules_context = {}, value_if_missing = expected_value )
66
66
assert toggle == expected_value
67
67
68
68
69
69
# check that feature match works when they are no rules and we send rules_context.
70
70
# default value is False but the feature has a True default_value.
71
71
def test_toggles_no_rules (mocker , config ):
72
72
expected_value = "True"
73
- mocked_app_config_schema = {"log_level" : "DEBUG" , "features" : {"my_feature" : {"default_value " : expected_value }}}
73
+ mocked_app_config_schema = {"log_level" : "DEBUG" , "features" : {"my_feature" : {"feature_default_value " : expected_value }}}
74
74
conf_store = init_configuration_store (mocker , mocked_app_config_schema , config )
75
75
toggle = conf_store .get_feature_toggle (
76
- feature_name = "my_feature" , rules_context = {"tenant_id" : "6" , "username" : "a" }, default_value = False
76
+ feature_name = "my_feature" , rules_context = {"tenant_id" : "6" , "username" : "a" }, value_if_missing = False
77
77
)
78
78
assert str (toggle ) == expected_value
79
79
@@ -85,11 +85,11 @@ def test_toggles_restrictions_no_match(mocker, config):
85
85
"log_level" : "DEBUG" ,
86
86
"features" : {
87
87
"my_feature" : {
88
- "default_value " : expected_value ,
88
+ "feature_default_value " : expected_value ,
89
89
"rules" : [
90
90
{
91
91
"name" : "tenant id equals 345345435" ,
92
- "default_value " : "False" ,
92
+ "rule_default_value " : "False" ,
93
93
"restrictions" : [
94
94
{
95
95
"action" : ACTION .EQUALS .value ,
@@ -106,7 +106,7 @@ def test_toggles_restrictions_no_match(mocker, config):
106
106
toggle = conf_store .get_feature_toggle (
107
107
feature_name = "my_feature" ,
108
108
rules_context = {"tenant_id" : "6" , "username" : "a" }, # rule will not match
109
- default_value = False ,
109
+ value_if_missing = False ,
110
110
)
111
111
assert str (toggle ) == expected_value
112
112
@@ -120,11 +120,11 @@ def test_toggles_restrictions_rule_match_equal_multiple_restrictions(mocker, con
120
120
"log_level" : "DEBUG" ,
121
121
"features" : {
122
122
"my_feature" : {
123
- "default_value " : "True" ,
123
+ "feature_default_value " : "True" ,
124
124
"rules" : [
125
125
{
126
126
"name" : "tenant id equals 6 and username is a" ,
127
- "default_value " : expected_value ,
127
+ "rule_default_value " : expected_value ,
128
128
"restrictions" : [
129
129
{
130
130
"action" : ACTION .EQUALS .value , # this rule will match, it has multiple restrictions
@@ -149,7 +149,7 @@ def test_toggles_restrictions_rule_match_equal_multiple_restrictions(mocker, con
149
149
"tenant_id" : tenant_id_val ,
150
150
"username" : username_val ,
151
151
},
152
- default_value = True ,
152
+ value_if_missing = True ,
153
153
)
154
154
assert str (toggle ) == expected_value
155
155
@@ -163,11 +163,11 @@ def test_toggles_restrictions_no_rule_match_equal_multiple_restrictions(mocker,
163
163
"log_level" : "DEBUG" ,
164
164
"features" : {
165
165
"my_feature" : {
166
- "default_value " : expected_val ,
166
+ "feature_default_value " : expected_val ,
167
167
"rules" : [
168
168
{
169
169
"name" : "tenant id equals 645654 and username is a" , # rule will not match
170
- "default_value " : "False" ,
170
+ "rule_default_value " : "False" ,
171
171
"restrictions" : [
172
172
{
173
173
"action" : ACTION .EQUALS .value ,
@@ -187,7 +187,7 @@ def test_toggles_restrictions_no_rule_match_equal_multiple_restrictions(mocker,
187
187
}
188
188
conf_store = init_configuration_store (mocker , mocked_app_config_schema , config )
189
189
toggle = conf_store .get_feature_toggle (
190
- feature_name = "my_feature" , rules_context = {"tenant_id" : "6" , "username" : "a" }, default_value = False
190
+ feature_name = "my_feature" , rules_context = {"tenant_id" : "6" , "username" : "a" }, value_if_missing = False
191
191
)
192
192
assert str (toggle ) == expected_val
193
193
@@ -202,11 +202,11 @@ def test_toggles_restrictions_rule_match_multiple_actions_multiple_rules_multipl
202
202
"log_level" : "DEBUG" ,
203
203
"features" : {
204
204
"my_feature" : {
205
- "default_value " : expected_value_third_check ,
205
+ "feature_default_value " : expected_value_third_check ,
206
206
"rules" : [
207
207
{
208
208
"name" : "tenant id equals 6 and username startswith a" ,
209
- "default_value " : expected_value_first_check ,
209
+ "rule_default_value " : expected_value_first_check ,
210
210
"restrictions" : [
211
211
{
212
212
"action" : ACTION .EQUALS .value ,
@@ -222,7 +222,7 @@ def test_toggles_restrictions_rule_match_multiple_actions_multiple_rules_multipl
222
222
},
223
223
{
224
224
"name" : "tenant id equals 4446 and username startswith a and endswith z" ,
225
- "default_value " : expected_value_second_check ,
225
+ "rule_default_value " : expected_value_second_check ,
226
226
"restrictions" : [
227
227
{
228
228
"action" : ACTION .EQUALS .value ,
@@ -251,28 +251,28 @@ def test_toggles_restrictions_rule_match_multiple_actions_multiple_rules_multipl
251
251
toggle = conf_store .get_feature_toggle (
252
252
feature_name = "my_feature" ,
253
253
rules_context = {"tenant_id" : "6" , "username" : "abcd" },
254
- default_value = False ,
254
+ value_if_missing = False ,
255
255
)
256
256
assert str (toggle ) == expected_value_first_check
257
257
# match second rule
258
258
toggle = conf_store .get_feature_toggle (
259
259
feature_name = "my_feature" ,
260
260
rules_context = {"tenant_id" : "4446" , "username" : "az" },
261
- default_value = False ,
261
+ value_if_missing = False ,
262
262
)
263
263
assert str (toggle ) == expected_value_second_check
264
264
# match no rule
265
265
toggle = conf_store .get_feature_toggle (
266
266
feature_name = "my_feature" ,
267
267
rules_context = {"tenant_id" : "11114446" , "username" : "ab" },
268
- default_value = False ,
268
+ value_if_missing = False ,
269
269
)
270
270
assert str (toggle ) == expected_value_third_check
271
271
# feature doesn't exist
272
272
toggle = conf_store .get_feature_toggle (
273
273
feature_name = "my_fake_feature" ,
274
274
rules_context = {"tenant_id" : "11114446" , "username" : "ab" },
275
- default_value = expected_value_fourth_case ,
275
+ value_if_missing = expected_value_fourth_case ,
276
276
)
277
277
assert toggle == expected_value_fourth_case
278
278
@@ -284,11 +284,11 @@ def test_toggles_match_rule_with_contains_action(mocker, config):
284
284
"log_level" : "DEBUG" ,
285
285
"features" : {
286
286
"my_feature" : {
287
- "default_value " : expected_value ,
287
+ "feature_default_value " : expected_value ,
288
288
"rules" : [
289
289
{
290
290
"name" : "tenant id equals 345345435" ,
291
- "default_value " : True ,
291
+ "rule_default_value " : True ,
292
292
"restrictions" : [
293
293
{
294
294
"action" : ACTION .CONTAINS .value ,
@@ -305,7 +305,7 @@ def test_toggles_match_rule_with_contains_action(mocker, config):
305
305
toggle = conf_store .get_feature_toggle (
306
306
feature_name = "my_feature" ,
307
307
rules_context = {"tenant_id" : "6" , "username" : "a" }, # rule will match
308
- default_value = False ,
308
+ value_if_missing = False ,
309
309
)
310
310
assert toggle == expected_value
311
311
@@ -316,11 +316,11 @@ def test_toggles_no_match_rule_with_contains_action(mocker, config):
316
316
"log_level" : "DEBUG" ,
317
317
"features" : {
318
318
"my_feature" : {
319
- "default_value " : expected_value ,
319
+ "feature_default_value " : expected_value ,
320
320
"rules" : [
321
321
{
322
322
"name" : "tenant id equals 345345435" ,
323
- "default_value " : True ,
323
+ "rule_default_value " : True ,
324
324
"restrictions" : [
325
325
{
326
326
"action" : ACTION .CONTAINS .value ,
@@ -337,6 +337,6 @@ def test_toggles_no_match_rule_with_contains_action(mocker, config):
337
337
toggle = conf_store .get_feature_toggle (
338
338
feature_name = "my_feature" ,
339
339
rules_context = {"tenant_id" : "6" , "username" : "a" }, # rule will not match
340
- default_value = False ,
340
+ value_if_missing = False ,
341
341
)
342
342
assert toggle == expected_value
0 commit comments