@@ -1181,10 +1181,9 @@ def test_is_feature_enabled__returns_false_for_invalid_feature(self):
1181
1181
# Check that no event is sent
1182
1182
self .assertEqual (0 , mock_dispatch_event .call_count )
1183
1183
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 ):
1185
1185
""" 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. """
1188
1187
1189
1188
opt_obj = optimizely .Optimizely (json .dumps (self .config_dict_with_features ))
1190
1189
project_config = opt_obj .config
@@ -1240,10 +1239,9 @@ def test_is_feature_enabled__returns_true_for_feature_experiment_if_property_fea
1240
1239
'https://logx.optimizely.com/v1/events' ,
1241
1240
expected_params , 'POST' , {'Content-Type' : 'application/json' })
1242
1241
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 ):
1244
1243
""" 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. """
1247
1245
1248
1246
opt_obj = optimizely .Optimizely (json .dumps (self .config_dict_with_features ))
1249
1247
project_config = opt_obj .config
@@ -1268,13 +1266,41 @@ def test_is_feature_enabled__returns_false_for_feature_experiment_if_property_fe
1268
1266
1269
1267
mock_decision .assert_called_once_with (feature , 'test_user' , None )
1270
1268
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' })
1273
1300
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 ):
1275
1302
""" 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. """
1278
1304
1279
1305
opt_obj = optimizely .Optimizely (json .dumps (self .config_dict_with_features ))
1280
1306
project_config = opt_obj .config
@@ -1302,10 +1328,9 @@ def test_is_feature_enabled__returns_true_for_feature_rollout_if_property_featur
1302
1328
# Check that impression event is not sent
1303
1329
self .assertEqual (0 , mock_dispatch_event .call_count )
1304
1330
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 ):
1306
1332
""" 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. """
1309
1334
1310
1335
opt_obj = optimizely .Optimizely (json .dumps (self .config_dict_with_features ))
1311
1336
project_config = opt_obj .config
0 commit comments