@@ -1181,10 +1181,9 @@ def test_is_feature_enabled__returns_false_for_invalid_feature(self):
11811181 # Check that no event is sent
11821182 self .assertEqual (0 , mock_dispatch_event .call_count )
11831183
1184- def test_is_feature_enabled__returns_true_for_feature_experiment_if_property_featureEnabled_is_true (self ):
1184+ def test_is_feature_enabled__returns_true_for_feature_experiment_if_feature_enabled_for_variation (self ):
11851185 """ Test that the feature is enabled for the user if bucketed into variation of an experiment and
1186- the variation's featureEnabled property is True.
1187- Also confirm that impression event is dispatched. """
1186+ the variation's featureEnabled property is True. Also confirm that impression event is dispatched. """
11881187
11891188 opt_obj = optimizely .Optimizely (json .dumps (self .config_dict_with_features ))
11901189 project_config = opt_obj .config
@@ -1240,10 +1239,9 @@ def test_is_feature_enabled__returns_true_for_feature_experiment_if_property_fea
12401239 'https://logx.optimizely.com/v1/events' ,
12411240 expected_params , 'POST' , {'Content-Type' : 'application/json' })
12421241
1243- def test_is_feature_enabled__returns_false_for_feature_experiment_if_property_featureEnabled_is_false (self ):
1242+ def test_is_feature_enabled__returns_false_for_feature_experiment_if_feature_disabled_for_variation (self ):
12441243 """ Test that the feature is disabled for the user if bucketed into variation of an experiment and
1245- the variation's featureEnabled property is False.
1246- Also confirm that impression event is not dispatched. """
1244+ the variation's featureEnabled property is False. Also confirm that impression event is dispatched. """
12471245
12481246 opt_obj = optimizely .Optimizely (json .dumps (self .config_dict_with_features ))
12491247 project_config = opt_obj .config
@@ -1268,13 +1266,41 @@ def test_is_feature_enabled__returns_false_for_feature_experiment_if_property_fe
12681266
12691267 mock_decision .assert_called_once_with (feature , 'test_user' , None )
12701268
1271- # Check that impression event is not sent
1272- self .assertEqual (0 , mock_dispatch_event .call_count )
1269+ # Check that impression event is sent
1270+ expected_params = {
1271+ 'account_id' : '12001' ,
1272+ 'project_id' : '111111' ,
1273+ 'visitors' : [{
1274+ 'visitor_id' : 'test_user' ,
1275+ 'attributes' : [],
1276+ 'snapshots' : [{
1277+ 'decisions' : [{
1278+ 'variation_id' : '111128' ,
1279+ 'experiment_id' : '111127' ,
1280+ 'campaign_id' : '111182'
1281+ }],
1282+ 'events' : [{
1283+ 'timestamp' : 42000 ,
1284+ 'entity_id' : '111182' ,
1285+ 'uuid' : 'a68cf1ad-0393-4e18-af87-efe8f01a7c9c' ,
1286+ 'key' : 'campaign_activated' ,
1287+ }]
1288+ }]
1289+ }],
1290+ 'client_version' : version .__version__ ,
1291+ 'client_name' : 'python-sdk' ,
1292+ 'anonymize_ip' : False ,
1293+ 'revision' : '1'
1294+ }
1295+ # Check that impression event is sent
1296+ self .assertEqual (1 , mock_dispatch_event .call_count )
1297+ self ._validate_event_object (mock_dispatch_event .call_args [0 ][0 ],
1298+ 'https://logx.optimizely.com/v1/events' ,
1299+ expected_params , 'POST' , {'Content-Type' : 'application/json' })
12731300
1274- def test_is_feature_enabled__returns_true_for_feature_rollout_if_property_featureEnabled_is_true (self ):
1301+ def test_is_feature_enabled__returns_true_for_feature_rollout_if_feature_enabled (self ):
12751302 """ Test that the feature is enabled for the user if bucketed into variation of a rollout and
1276- the variation's featureEnabled property is True.
1277- Also confirm that no impression event is dispatched. """
1303+ the variation's featureEnabled property is True. Also confirm that no impression event is dispatched. """
12781304
12791305 opt_obj = optimizely .Optimizely (json .dumps (self .config_dict_with_features ))
12801306 project_config = opt_obj .config
@@ -1302,10 +1328,9 @@ def test_is_feature_enabled__returns_true_for_feature_rollout_if_property_featur
13021328 # Check that impression event is not sent
13031329 self .assertEqual (0 , mock_dispatch_event .call_count )
13041330
1305- def test_is_feature_enabled__returns_false_for_feature_rollout_if_property_featureEnabled_is_false (self ):
1331+ def test_is_feature_enabled__returns_false_for_feature_rollout_if_feature_disabled (self ):
13061332 """ Test that the feature is disabled for the user if bucketed into variation of a rollout and
1307- the variation's featureEnabled property is False.
1308- Also confirm that no impression event is dispatched. """
1333+ the variation's featureEnabled property is False. Also confirm that no impression event is dispatched. """
13091334
13101335 opt_obj = optimizely .Optimizely (json .dumps (self .config_dict_with_features ))
13111336 project_config = opt_obj .config
0 commit comments