@@ -263,7 +263,7 @@ def test_flags_conditions_rule_match_multiple_actions_multiple_rules_multiple_co
263
263
264
264
265
265
# check a case where the feature exists but the rule doesn't match so we revert to the default value of the feature
266
- def test_flags_match_rule_with_contains_action (mocker , config ):
266
+ def test_flags_match_rule_with_in_action (mocker , config ):
267
267
expected_value = True
268
268
mocked_app_config_schema = {
269
269
"my_feature" : {
@@ -273,7 +273,7 @@ def test_flags_match_rule_with_contains_action(mocker, config):
273
273
"when_match" : expected_value ,
274
274
"conditions" : [
275
275
{
276
- "action" : RuleAction .CONTAINS .value ,
276
+ "action" : RuleAction .IN .value ,
277
277
"key" : "tenant_id" ,
278
278
"value" : ["6" , "2" ],
279
279
}
@@ -287,7 +287,7 @@ def test_flags_match_rule_with_contains_action(mocker, config):
287
287
assert toggle == expected_value
288
288
289
289
290
- def test_flags_no_match_rule_with_contains_action (mocker , config ):
290
+ def test_flags_no_match_rule_with_in_action (mocker , config ):
291
291
expected_value = False
292
292
mocked_app_config_schema = {
293
293
"my_feature" : {
@@ -297,7 +297,7 @@ def test_flags_no_match_rule_with_contains_action(mocker, config):
297
297
"when_match" : True ,
298
298
"conditions" : [
299
299
{
300
- "action" : RuleAction .CONTAINS .value ,
300
+ "action" : RuleAction .IN .value ,
301
301
"key" : "tenant_id" ,
302
302
"value" : ["8" , "2" ],
303
303
}
@@ -310,6 +310,30 @@ def test_flags_no_match_rule_with_contains_action(mocker, config):
310
310
toggle = feature_flags .evaluate (name = "my_feature" , context = {"tenant_id" : "6" , "username" : "a" }, default = False )
311
311
assert toggle == expected_value
312
312
313
+ def test_flags_match_rule_with_not_in_action (mocker , config ):
314
+ expected_value = True
315
+ mocked_app_config_schema = {
316
+ "my_feature" : {
317
+ "default" : False ,
318
+ "rules" : {
319
+ "tenant id is contained in [8, 2]" : {
320
+ "when_match" : expected_value ,
321
+ "conditions" : [
322
+ {
323
+ "action" : RuleAction .NOT_IN .value ,
324
+ "key" : "tenant_id" ,
325
+ "value" : ["10" , "4" ],
326
+ }
327
+ ],
328
+ }
329
+ },
330
+ }
331
+ }
332
+ feature_flags = init_feature_flags (mocker , mocked_app_config_schema , config )
333
+ toggle = feature_flags .evaluate (name = "my_feature" , context = {"tenant_id" : "6" , "username" : "a" }, default = False )
334
+ assert toggle == expected_value
335
+
336
+
313
337
314
338
def test_multiple_features_enabled (mocker , config ):
315
339
expected_value = ["my_feature" , "my_feature2" ]
@@ -321,7 +345,7 @@ def test_multiple_features_enabled(mocker, config):
321
345
"when_match" : True ,
322
346
"conditions" : [
323
347
{
324
- "action" : RuleAction .CONTAINS .value ,
348
+ "action" : RuleAction .IN .value ,
325
349
"key" : "tenant_id" ,
326
350
"value" : ["6" , "2" ],
327
351
}
@@ -351,7 +375,7 @@ def test_multiple_features_only_some_enabled(mocker, config):
351
375
"when_match" : True ,
352
376
"conditions" : [
353
377
{
354
- "action" : RuleAction .CONTAINS .value ,
378
+ "action" : RuleAction .IN .value ,
355
379
"key" : "tenant_id" ,
356
380
"value" : ["6" , "2" ],
357
381
}
@@ -464,7 +488,7 @@ def test_features_jmespath_envelope(mocker, config):
464
488
assert toggle == expected_value
465
489
466
490
467
- # test_match_rule_with_contains_action
491
+ # test_match_rule_with_equals_action
468
492
def test_match_condition_with_dict_value (mocker , config ):
469
493
expected_value = True
470
494
mocked_app_config_schema = {
0 commit comments