@@ -5483,3 +5483,43 @@ def test_send_odp_event__log_error_with_missing_integrations_data(self):
54835483
54845484 mock_logger .error .assert_called_with ('ODP is not integrated.' )
54855485 client .close ()
5486+
5487+ def test_send_odp_event__log_error_with_action_none (self ):
5488+ mock_logger = mock .Mock ()
5489+ client = optimizely .Optimizely (json .dumps (self .config_dict_with_audience_segments ), logger = mock_logger )
5490+
5491+ client .send_odp_event (type = 'wow' , action = None , identifiers = {'amazing' : 'fantastic' }, data = {})
5492+ client .close ()
5493+
5494+ mock_logger .error .assert_called_once_with ('ODP action is not valid (cannot be empty).' )
5495+
5496+ def test_send_odp_event__log_error_with_action_empty_string (self ):
5497+ mock_logger = mock .Mock ()
5498+ client = optimizely .Optimizely (json .dumps (self .config_dict_with_audience_segments ), logger = mock_logger )
5499+
5500+ client .send_odp_event (type = 'wow' , action = "" , identifiers = {'amazing' : 'fantastic' }, data = {})
5501+ client .close ()
5502+
5503+ mock_logger .error .assert_called_once_with ('ODP action is not valid (cannot be empty).' )
5504+
5505+ def test_send_odp_event__default_type_when_none (self ):
5506+ mock_logger = mock .Mock ()
5507+
5508+ client = optimizely .Optimizely (json .dumps (self .config_dict_with_audience_segments ), logger = mock_logger )
5509+ with mock .patch .object (client .odp_manager , 'send_event' ) as mock_send_event :
5510+ client .send_odp_event (type = None , action = "great" , identifiers = {'amazing' : 'fantastic' }, data = {})
5511+ client .close ()
5512+
5513+ mock_send_event .assert_called_with ('fullstack' , 'great' , {'amazing' : 'fantastic' }, {})
5514+ mock_logger .error .assert_not_called ()
5515+
5516+ def test_send_odp_event__default_type_when_empty_string (self ):
5517+ mock_logger = mock .Mock ()
5518+
5519+ client = optimizely .Optimizely (json .dumps (self .config_dict_with_audience_segments ), logger = mock_logger )
5520+ with mock .patch .object (client .odp_manager , 'send_event' ) as mock_send_event :
5521+ client .send_odp_event (type = "" , action = "great" , identifiers = {'amazing' : 'fantastic' }, data = {})
5522+ client .close ()
5523+
5524+ mock_send_event .assert_called_with ('fullstack' , 'great' , {'amazing' : 'fantastic' }, {})
5525+ mock_logger .error .assert_not_called ()
0 commit comments