@@ -1384,96 +1384,37 @@ def setUp(self):
13841384 # Create config with holdouts
13851385 config_body_with_holdouts = self .config_dict_with_features .copy ()
13861386
1387- # Use correct feature flag IDs from the datafile
1388- boolean_feature_id = '91111' # boolean_single_variable_feature
1389- multi_variate_feature_id = '91114' # test_feature_in_experiment_and_rollout
1390-
13911387 config_body_with_holdouts ['holdouts' ] = [
13921388 {
13931389 'id' : 'holdout_1' ,
13941390 'key' : 'global_holdout' ,
13951391 'status' : 'Running' ,
13961392 'variations' : [],
13971393 'trafficAllocation' : [],
1398- 'audienceIds' : [],
1399- 'includedFlags' : [],
1400- 'excludedFlags' : [boolean_feature_id ]
1394+ 'audienceIds' : []
14011395 },
14021396 {
14031397 'id' : 'holdout_2' ,
14041398 'key' : 'specific_holdout' ,
14051399 'status' : 'Running' ,
14061400 'variations' : [],
14071401 'trafficAllocation' : [],
1408- 'audienceIds' : [],
1409- 'includedFlags' : [multi_variate_feature_id ],
1410- 'excludedFlags' : []
1402+ 'audienceIds' : []
14111403 },
14121404 {
14131405 'id' : 'holdout_3' ,
14141406 'key' : 'inactive_holdout' ,
14151407 'status' : 'Inactive' ,
14161408 'variations' : [],
14171409 'trafficAllocation' : [],
1418- 'audienceIds' : [],
1419- 'includedFlags' : [boolean_feature_id ],
1420- 'excludedFlags' : []
1410+ 'audienceIds' : []
14211411 }
14221412 ]
14231413
14241414 self .config_json_with_holdouts = json .dumps (config_body_with_holdouts )
14251415 opt_obj = optimizely .Optimizely (self .config_json_with_holdouts )
14261416 self .config_with_holdouts = opt_obj .config_manager .get_config ()
14271417
1428- def test_get_holdouts_for_flag__non_existent_flag (self ):
1429- """ Test that get_holdouts_for_flag returns empty array for non-existent flag. """
1430-
1431- holdouts = self .config_with_holdouts .get_holdouts_for_flag ('non_existent_flag' )
1432- self .assertEqual ([], holdouts )
1433-
1434- def test_get_holdouts_for_flag__returns_global_and_specific_holdouts (self ):
1435- """ Test that get_holdouts_for_flag returns global holdouts that do not exclude the flag
1436- and specific holdouts that include the flag. """
1437-
1438- holdouts = self .config_with_holdouts .get_holdouts_for_flag ('test_feature_in_experiment_and_rollout' )
1439- self .assertEqual (2 , len (holdouts ))
1440-
1441- global_holdout = next ((h for h in holdouts if h ['key' ] == 'global_holdout' ), None )
1442- self .assertIsNotNone (global_holdout )
1443- self .assertEqual ('holdout_1' , global_holdout ['id' ])
1444-
1445- specific_holdout = next ((h for h in holdouts if h ['key' ] == 'specific_holdout' ), None )
1446- self .assertIsNotNone (specific_holdout )
1447- self .assertEqual ('holdout_2' , specific_holdout ['id' ])
1448-
1449- def test_get_holdouts_for_flag__excludes_global_holdouts_for_excluded_flags (self ):
1450- """ Test that get_holdouts_for_flag does not return global holdouts that exclude the flag. """
1451-
1452- holdouts = self .config_with_holdouts .get_holdouts_for_flag ('boolean_single_variable_feature' )
1453- self .assertEqual (0 , len (holdouts ))
1454-
1455- global_holdout = next ((h for h in holdouts if h ['key' ] == 'global_holdout' ), None )
1456- self .assertIsNone (global_holdout )
1457-
1458- def test_get_holdouts_for_flag__caches_results (self ):
1459- """ Test that get_holdouts_for_flag caches results for subsequent calls. """
1460-
1461- holdouts1 = self .config_with_holdouts .get_holdouts_for_flag ('test_feature_in_experiment_and_rollout' )
1462- holdouts2 = self .config_with_holdouts .get_holdouts_for_flag ('test_feature_in_experiment_and_rollout' )
1463-
1464- # Should be the same object (cached)
1465- self .assertIs (holdouts1 , holdouts2 )
1466- self .assertEqual (2 , len (holdouts1 ))
1467-
1468- def test_get_holdouts_for_flag__returns_only_global_for_non_targeted_flags (self ):
1469- """ Test that get_holdouts_for_flag returns only global holdouts for flags not specifically targeted. """
1470-
1471- holdouts = self .config_with_holdouts .get_holdouts_for_flag ('test_feature_in_rollout' )
1472-
1473- # Should only include global holdout (not excluded and no specific targeting)
1474- self .assertEqual (1 , len (holdouts ))
1475- self .assertEqual ('global_holdout' , holdouts [0 ]['key' ])
1476-
14771418 def test_get_holdout__returns_holdout_for_valid_id (self ):
14781419 """ Test that get_holdout returns holdout when valid ID is provided. """
14791420
@@ -1516,36 +1457,6 @@ def test_get_holdout__does_not_log_when_found(self):
15161457 self .assertIsNotNone (result )
15171458 mock_logger .error .assert_not_called ()
15181459
1519- def test_holdout_initialization__categorizes_holdouts_properly (self ):
1520- """ Test that holdouts are properly categorized during initialization. """
1521-
1522- self .assertIn ('holdout_1' , self .config_with_holdouts .holdout_id_map )
1523- self .assertIn ('holdout_2' , self .config_with_holdouts .holdout_id_map )
1524- # Check if a holdout with ID 'holdout_1' exists in global_holdouts
1525- holdout_ids_in_global = [h .id for h in self .config_with_holdouts .global_holdouts ]
1526- self .assertIn ('holdout_1' , holdout_ids_in_global )
1527-
1528- # Use correct feature flag IDs
1529- boolean_feature_id = '91111'
1530- multi_variate_feature_id = '91114'
1531-
1532- self .assertIn (multi_variate_feature_id , self .config_with_holdouts .included_holdouts )
1533- self .assertTrue (len (self .config_with_holdouts .included_holdouts [multi_variate_feature_id ]) > 0 )
1534- self .assertNotIn (boolean_feature_id , self .config_with_holdouts .included_holdouts )
1535-
1536- self .assertIn (boolean_feature_id , self .config_with_holdouts .excluded_holdouts )
1537- self .assertTrue (len (self .config_with_holdouts .excluded_holdouts [boolean_feature_id ]) > 0 )
1538-
1539- def test_holdout_initialization__only_processes_running_holdouts (self ):
1540- """ Test that only running holdouts are processed during initialization. """
1541-
1542- self .assertNotIn ('holdout_3' , self .config_with_holdouts .holdout_id_map )
1543- self .assertNotIn ('holdout_3' , self .config_with_holdouts .global_holdouts )
1544-
1545- boolean_feature_id = '91111'
1546- included_for_boolean = self .config_with_holdouts .included_holdouts .get (boolean_feature_id )
1547- self .assertIsNone (included_for_boolean )
1548-
15491460
15501461class FeatureRolloutConfigTest (base .BaseTest ):
15511462 """Tests for Feature Rollout support in ProjectConfig parsing."""
0 commit comments