@@ -1438,6 +1438,29 @@ def side_effect(*args, **kwargs):
1438
1438
mock_is_feature_enabled .assert_any_call ('test_feature_in_group' , 'user_1' , None )
1439
1439
mock_is_feature_enabled .assert_any_call ('test_feature_in_experiment_and_rollout' , 'user_1' , None )
1440
1440
1441
+ def test_get_enabled_features_returns_a_sorted_list (self ):
1442
+ """ Test that get_enabled_features returns a sorted list of enabled feature keys. """
1443
+
1444
+ opt_obj = optimizely .Optimizely (json .dumps (self .config_dict_with_features ))
1445
+
1446
+ with mock .patch ('optimizely.optimizely.Optimizely.is_feature_enabled' ,
1447
+ return_value = True ) as mock_is_feature_enabled :
1448
+ received_features = opt_obj .get_enabled_features ('user_1' )
1449
+
1450
+ mock_is_feature_enabled .assert_any_call ('test_feature_in_experiment' , 'user_1' , None )
1451
+ mock_is_feature_enabled .assert_any_call ('test_feature_in_rollout' , 'user_1' , None )
1452
+ mock_is_feature_enabled .assert_any_call ('test_feature_in_group' , 'user_1' , None )
1453
+ mock_is_feature_enabled .assert_any_call ('test_feature_in_experiment_and_rollout' , 'user_1' , None )
1454
+
1455
+ expected_sorted_features = [
1456
+ 'test_feature_in_experiment' ,
1457
+ 'test_feature_in_experiment_and_rollout' ,
1458
+ 'test_feature_in_group' ,
1459
+ 'test_feature_in_rollout'
1460
+ ]
1461
+
1462
+ self .assertEqual (expected_sorted_features , received_features )
1463
+
1441
1464
def test_get_enabled_features__invalid_object (self ):
1442
1465
""" Test that get_enabled_features returns empty list if Optimizely object is not valid. """
1443
1466
0 commit comments