@@ -5386,7 +5386,7 @@ def test_send_odp_event__send_event_with_static_config_manager(self):
5386
5386
logger = mock_logger ,
5387
5387
)
5388
5388
with mock .patch ('requests.post' , return_value = self .fake_server_response (status_code = 200 )):
5389
- client .send_odp_event (type = 'wow' , action = 'great' , identifiers = {}, data = {})
5389
+ client .send_odp_event (type = 'wow' , action = 'great' , identifiers = {'amazing' : 'fantastic' }, data = {})
5390
5390
client .close ()
5391
5391
mock_logger .error .assert_not_called ()
5392
5392
mock_logger .debug .assert_called_with ('ODP event queue: flushing batch size 1.' )
@@ -5405,7 +5405,7 @@ def test_send_odp_event__send_event_with_polling_config_manager(self):
5405
5405
client .config_manager .get_config ()
5406
5406
5407
5407
with mock .patch ('requests.post' , return_value = self .fake_server_response (status_code = 200 )):
5408
- client .send_odp_event (type = 'wow' , action = 'great' , identifiers = {}, data = {})
5408
+ client .send_odp_event (type = 'wow' , action = 'great' , identifiers = {'amazing' : 'fantastic' }, data = {})
5409
5409
client .close ()
5410
5410
5411
5411
mock_logger .error .assert_not_called ()
@@ -5419,14 +5419,14 @@ def test_send_odp_event__log_error_when_odp_disabled(self):
5419
5419
settings = OptimizelySdkSettings (odp_disabled = True )
5420
5420
)
5421
5421
with mock .patch ('requests.post' , return_value = self .fake_server_response (status_code = 200 )):
5422
- client .send_odp_event (type = 'wow' , action = 'great' , identifiers = {}, data = {})
5422
+ client .send_odp_event (type = 'wow' , action = 'great' , identifiers = {'amazing' : 'fantastic' }, data = {})
5423
5423
client .close ()
5424
5424
mock_logger .error .assert_called_with ('ODP is not enabled.' )
5425
5425
5426
5426
def test_send_odp_event__log_debug_if_datafile_not_ready (self ):
5427
5427
mock_logger = mock .Mock ()
5428
5428
client = optimizely .Optimizely (sdk_key = 'test' , logger = mock_logger )
5429
- client .send_odp_event (type = 'wow' , action = 'great' , identifiers = {}, data = {})
5429
+ client .send_odp_event (type = 'wow' , action = 'great' , identifiers = {'amazing' : 'fantastic' }, data = {})
5430
5430
5431
5431
mock_logger .debug .assert_called_with ('ODP event queue: cannot send before config has been set.' )
5432
5432
client .close ()
@@ -5449,7 +5449,7 @@ def test_send_odp_event__log_error_if_odp_not_enabled_with_polling_config_manage
5449
5449
client .config_manager .get_config ()
5450
5450
5451
5451
with mock .patch ('requests.post' , return_value = self .fake_server_response (status_code = 200 )):
5452
- client .send_odp_event (type = 'wow' , action = 'great' , identifiers = {}, data = {})
5452
+ client .send_odp_event (type = 'wow' , action = 'great' , identifiers = {'amazing' : 'fantastic' }, data = {})
5453
5453
client .close ()
5454
5454
5455
5455
mock_logger .error .assert_called_with ('ODP is not enabled.' )
@@ -5458,15 +5458,33 @@ def test_send_odp_event__log_error_with_invalid_data(self):
5458
5458
mock_logger = mock .Mock ()
5459
5459
client = optimizely .Optimizely (json .dumps (self .config_dict_with_audience_segments ), logger = mock_logger )
5460
5460
5461
- client .send_odp_event (type = 'wow' , action = 'great' , identifiers = {}, data = {'test' : {}})
5461
+ client .send_odp_event (type = 'wow' , action = 'great' , identifiers = {'amazing' : 'fantastic' }, data = {'test' : {}})
5462
5462
client .close ()
5463
5463
5464
5464
mock_logger .error .assert_called_with ('ODP data is not valid.' )
5465
5465
5466
+ def test_send_odp_event__log_error_with_empty_identifiers (self ):
5467
+ mock_logger = mock .Mock ()
5468
+ client = optimizely .Optimizely (json .dumps (self .config_dict_with_audience_segments ), logger = mock_logger )
5469
+
5470
+ client .send_odp_event (type = 'wow' , action = 'great' , identifiers = {}, data = {})
5471
+ client .close ()
5472
+
5473
+ mock_logger .error .assert_called_with ('ODP events must have at least one key-value pair in identifiers.' )
5474
+
5475
+ def test_send_odp_event__log_error_with_no_identifiers (self ):
5476
+ mock_logger = mock .Mock ()
5477
+ client = optimizely .Optimizely (json .dumps (self .config_dict_with_audience_segments ), logger = mock_logger )
5478
+
5479
+ client .send_odp_event (type = 'wow' , action = 'great' , identifiers = None , data = {})
5480
+ client .close ()
5481
+
5482
+ mock_logger .error .assert_called_with ('ODP events must have at least one key-value pair in identifiers.' )
5483
+
5466
5484
def test_send_odp_event__log_error_with_missing_integrations_data (self ):
5467
5485
mock_logger = mock .Mock ()
5468
5486
client = optimizely .Optimizely (json .dumps (self .config_dict_with_typed_audiences ), logger = mock_logger )
5469
- client .send_odp_event (type = 'wow' , action = 'great' , identifiers = {}, data = {})
5487
+ client .send_odp_event (type = 'wow' , action = 'great' , identifiers = {'amazing' : 'fantastic' }, data = {})
5470
5488
5471
5489
mock_logger .error .assert_called_with ('ODP is not integrated.' )
5472
5490
client .close ()
0 commit comments