@@ -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
}
@@ -311,6 +311,54 @@ def test_flags_no_match_rule_with_contains_action(mocker, config):
311
311
assert toggle == expected_value
312
312
313
313
314
+ def test_flags_match_rule_with_not_in_action (mocker , config ):
315
+ expected_value = True
316
+ mocked_app_config_schema = {
317
+ "my_feature" : {
318
+ "default" : False ,
319
+ "rules" : {
320
+ "tenant id is contained in [8, 2]" : {
321
+ "when_match" : expected_value ,
322
+ "conditions" : [
323
+ {
324
+ "action" : RuleAction .NOT_IN .value ,
325
+ "key" : "tenant_id" ,
326
+ "value" : ["10" , "4" ],
327
+ }
328
+ ],
329
+ }
330
+ },
331
+ }
332
+ }
333
+ feature_flags = init_feature_flags (mocker , mocked_app_config_schema , config )
334
+ toggle = feature_flags .evaluate (name = "my_feature" , context = {"tenant_id" : "6" , "username" : "a" }, default = False )
335
+ assert toggle == expected_value
336
+
337
+
338
+ def test_flags_no_match_rule_with_not_in_action (mocker , config ):
339
+ expected_value = False
340
+ mocked_app_config_schema = {
341
+ "my_feature" : {
342
+ "default" : expected_value ,
343
+ "rules" : {
344
+ "tenant id is contained in [8, 2]" : {
345
+ "when_match" : True ,
346
+ "conditions" : [
347
+ {
348
+ "action" : RuleAction .NOT_IN .value ,
349
+ "key" : "tenant_id" ,
350
+ "value" : ["6" , "4" ],
351
+ }
352
+ ],
353
+ }
354
+ },
355
+ }
356
+ }
357
+ feature_flags = init_feature_flags (mocker , mocked_app_config_schema , config )
358
+ toggle = feature_flags .evaluate (name = "my_feature" , context = {"tenant_id" : "6" , "username" : "a" }, default = False )
359
+ assert toggle == expected_value
360
+
361
+
314
362
def test_multiple_features_enabled (mocker , config ):
315
363
expected_value = ["my_feature" , "my_feature2" ]
316
364
mocked_app_config_schema = {
@@ -321,7 +369,7 @@ def test_multiple_features_enabled(mocker, config):
321
369
"when_match" : True ,
322
370
"conditions" : [
323
371
{
324
- "action" : RuleAction .CONTAINS .value ,
372
+ "action" : RuleAction .IN .value ,
325
373
"key" : "tenant_id" ,
326
374
"value" : ["6" , "2" ],
327
375
}
@@ -351,7 +399,7 @@ def test_multiple_features_only_some_enabled(mocker, config):
351
399
"when_match" : True ,
352
400
"conditions" : [
353
401
{
354
- "action" : RuleAction .CONTAINS .value ,
402
+ "action" : RuleAction .IN .value ,
355
403
"key" : "tenant_id" ,
356
404
"value" : ["6" , "2" ],
357
405
}
@@ -464,7 +512,7 @@ def test_features_jmespath_envelope(mocker, config):
464
512
assert toggle == expected_value
465
513
466
514
467
- # test_match_rule_with_contains_action
515
+ # test_match_rule_with_equals_action
468
516
def test_match_condition_with_dict_value (mocker , config ):
469
517
expected_value = True
470
518
mocked_app_config_schema = {
0 commit comments