@@ -1182,10 +1182,9 @@ def test_is_feature_enabled__returns_false_for_invalid_feature(self):
11821182 # Check that no event is sent
11831183 self .assertEqual (0 , mock_dispatch_event .call_count )
11841184
1185- def test_is_feature_enabled__returns_true_for_feature_experiment_if_property_featureEnabled_is_true (self ):
1185+ def test_is_feature_enabled__returns_true_for_feature_experiment_if_feature_enabled_for_variation (self ):
11861186 """ Test that the feature is enabled for the user if bucketed into variation of an experiment and
1187- the variation's featureEnabled property is True.
1188- Also confirm that impression event is dispatched. """
1187+ the variation's featureEnabled property is True. Also confirm that impression event is dispatched. """
11891188
11901189 opt_obj = optimizely .Optimizely (json .dumps (self .config_dict_with_features ))
11911190 project_config = opt_obj .config
@@ -1241,10 +1240,9 @@ def test_is_feature_enabled__returns_true_for_feature_experiment_if_property_fea
12411240 'https://logx.optimizely.com/v1/events' ,
12421241 expected_params , 'POST' , {'Content-Type' : 'application/json' })
12431242
1244- def test_is_feature_enabled__returns_false_for_feature_experiment_if_property_featureEnabled_is_false (self ):
1243+ def test_is_feature_enabled__returns_false_for_feature_experiment_if_feature_disabled_for_variation (self ):
12451244 """ Test that the feature is disabled for the user if bucketed into variation of an experiment and
1246- the variation's featureEnabled property is False.
1247- Also confirm that impression event is not dispatched. """
1245+ the variation's featureEnabled property is False. Also confirm that impression event is dispatched. """
12481246
12491247 opt_obj = optimizely .Optimizely (json .dumps (self .config_dict_with_features ))
12501248 project_config = opt_obj .config
@@ -1269,13 +1267,41 @@ def test_is_feature_enabled__returns_false_for_feature_experiment_if_property_fe
12691267
12701268 mock_decision .assert_called_once_with (feature , 'test_user' , None )
12711269
1272- # Check that impression event is not sent
1273- self .assertEqual (0 , mock_dispatch_event .call_count )
1270+ # Check that impression event is sent
1271+ expected_params = {
1272+ 'account_id' : '12001' ,
1273+ 'project_id' : '111111' ,
1274+ 'visitors' : [{
1275+ 'visitor_id' : 'test_user' ,
1276+ 'attributes' : [],
1277+ 'snapshots' : [{
1278+ 'decisions' : [{
1279+ 'variation_id' : '111128' ,
1280+ 'experiment_id' : '111127' ,
1281+ 'campaign_id' : '111182'
1282+ }],
1283+ 'events' : [{
1284+ 'timestamp' : 42000 ,
1285+ 'entity_id' : '111182' ,
1286+ 'uuid' : 'a68cf1ad-0393-4e18-af87-efe8f01a7c9c' ,
1287+ 'key' : 'campaign_activated' ,
1288+ }]
1289+ }]
1290+ }],
1291+ 'client_version' : version .__version__ ,
1292+ 'client_name' : 'python-sdk' ,
1293+ 'anonymize_ip' : False ,
1294+ 'revision' : '1'
1295+ }
1296+ # Check that impression event is sent
1297+ self .assertEqual (1 , mock_dispatch_event .call_count )
1298+ self ._validate_event_object (mock_dispatch_event .call_args [0 ][0 ],
1299+ 'https://logx.optimizely.com/v1/events' ,
1300+ expected_params , 'POST' , {'Content-Type' : 'application/json' })
12741301
1275- def test_is_feature_enabled__returns_true_for_feature_rollout_if_property_featureEnabled_is_true (self ):
1302+ def test_is_feature_enabled__returns_true_for_feature_rollout_if_feature_enabled (self ):
12761303 """ Test that the feature is enabled for the user if bucketed into variation of a rollout and
1277- the variation's featureEnabled property is True.
1278- Also confirm that no impression event is dispatched. """
1304+ the variation's featureEnabled property is True. Also confirm that no impression event is dispatched. """
12791305
12801306 opt_obj = optimizely .Optimizely (json .dumps (self .config_dict_with_features ))
12811307 project_config = opt_obj .config
@@ -1303,10 +1329,9 @@ def test_is_feature_enabled__returns_true_for_feature_rollout_if_property_featur
13031329 # Check that impression event is not sent
13041330 self .assertEqual (0 , mock_dispatch_event .call_count )
13051331
1306- def test_is_feature_enabled__returns_false_for_feature_rollout_if_property_featureEnabled_is_false (self ):
1332+ def test_is_feature_enabled__returns_false_for_feature_rollout_if_feature_disabled (self ):
13071333 """ Test that the feature is disabled for the user if bucketed into variation of a rollout and
1308- the variation's featureEnabled property is False.
1309- Also confirm that no impression event is dispatched. """
1334+ the variation's featureEnabled property is False. Also confirm that no impression event is dispatched. """
13101335
13111336 opt_obj = optimizely .Optimizely (json .dumps (self .config_dict_with_features ))
13121337 project_config = opt_obj .config
0 commit comments