@@ -263,7 +263,7 @@ def test_flags_conditions_rule_match_multiple_actions_multiple_rules_multiple_co
263263
264264
265265# 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 ):
267267 expected_value = True
268268 mocked_app_config_schema = {
269269 "my_feature" : {
@@ -273,7 +273,7 @@ def test_flags_match_rule_with_contains_action(mocker, config):
273273 "when_match" : expected_value ,
274274 "conditions" : [
275275 {
276- "action" : RuleAction .CONTAINS .value ,
276+ "action" : RuleAction .IN .value ,
277277 "key" : "tenant_id" ,
278278 "value" : ["6" , "2" ],
279279 }
@@ -287,7 +287,7 @@ def test_flags_match_rule_with_contains_action(mocker, config):
287287 assert toggle == expected_value
288288
289289
290- def test_flags_no_match_rule_with_contains_action (mocker , config ):
290+ def test_flags_no_match_rule_with_in_action (mocker , config ):
291291 expected_value = False
292292 mocked_app_config_schema = {
293293 "my_feature" : {
@@ -297,7 +297,7 @@ def test_flags_no_match_rule_with_contains_action(mocker, config):
297297 "when_match" : True ,
298298 "conditions" : [
299299 {
300- "action" : RuleAction .CONTAINS .value ,
300+ "action" : RuleAction .IN .value ,
301301 "key" : "tenant_id" ,
302302 "value" : ["8" , "2" ],
303303 }
@@ -311,6 +311,54 @@ def test_flags_no_match_rule_with_contains_action(mocker, config):
311311 assert toggle == expected_value
312312
313313
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+
314362def test_multiple_features_enabled (mocker , config ):
315363 expected_value = ["my_feature" , "my_feature2" ]
316364 mocked_app_config_schema = {
@@ -321,7 +369,7 @@ def test_multiple_features_enabled(mocker, config):
321369 "when_match" : True ,
322370 "conditions" : [
323371 {
324- "action" : RuleAction .CONTAINS .value ,
372+ "action" : RuleAction .IN .value ,
325373 "key" : "tenant_id" ,
326374 "value" : ["6" , "2" ],
327375 }
@@ -351,7 +399,7 @@ def test_multiple_features_only_some_enabled(mocker, config):
351399 "when_match" : True ,
352400 "conditions" : [
353401 {
354- "action" : RuleAction .CONTAINS .value ,
402+ "action" : RuleAction .IN .value ,
355403 "key" : "tenant_id" ,
356404 "value" : ["6" , "2" ],
357405 }
@@ -464,7 +512,7 @@ def test_features_jmespath_envelope(mocker, config):
464512 assert toggle == expected_value
465513
466514
467- # test_match_rule_with_contains_action
515+ # test_match_rule_with_equals_action
468516def test_match_condition_with_dict_value (mocker , config ):
469517 expected_value = True
470518 mocked_app_config_schema = {
0 commit comments