@@ -5386,7 +5386,7 @@ def test_send_odp_event__send_event_with_static_config_manager(self):
53865386 logger = mock_logger ,
53875387 )
53885388 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 = {})
53905390 client .close ()
53915391 mock_logger .error .assert_not_called ()
53925392 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):
54055405 client .config_manager .get_config ()
54065406
54075407 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 = {})
54095409 client .close ()
54105410
54115411 mock_logger .error .assert_not_called ()
@@ -5419,14 +5419,14 @@ def test_send_odp_event__log_error_when_odp_disabled(self):
54195419 settings = OptimizelySdkSettings (odp_disabled = True )
54205420 )
54215421 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 = {})
54235423 client .close ()
54245424 mock_logger .error .assert_called_with ('ODP is not enabled.' )
54255425
54265426 def test_send_odp_event__log_debug_if_datafile_not_ready (self ):
54275427 mock_logger = mock .Mock ()
54285428 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 = {})
54305430
54315431 mock_logger .debug .assert_called_with ('ODP event queue: cannot send before config has been set.' )
54325432 client .close ()
@@ -5449,7 +5449,7 @@ def test_send_odp_event__log_error_if_odp_not_enabled_with_polling_config_manage
54495449 client .config_manager .get_config ()
54505450
54515451 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 = {})
54535453 client .close ()
54545454
54555455 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):
54585458 mock_logger = mock .Mock ()
54595459 client = optimizely .Optimizely (json .dumps (self .config_dict_with_audience_segments ), logger = mock_logger )
54605460
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' : {}})
54625462 client .close ()
54635463
54645464 mock_logger .error .assert_called_with ('ODP data is not valid.' )
54655465
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+
54665484 def test_send_odp_event__log_error_with_missing_integrations_data (self ):
54675485 mock_logger = mock .Mock ()
54685486 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 = {})
54705488
54715489 mock_logger .error .assert_called_with ('ODP is not integrated.' )
54725490 client .close ()
0 commit comments