@@ -1022,57 +1022,6 @@ def test_track__with_event_tags__forced_bucketing(self):
10221022 self ._validate_event_object (mock_dispatch_event .call_args [0 ][0 ], 'https://logx.optimizely.com/v1/events' ,
10231023 expected_params , 'POST' , {'Content-Type' : 'application/json' })
10241024
1025- def test_track__with_deprecated_event_value (self ):
1026- """ Test that track calls dispatch_event with right params when event_value information is provided. """
1027-
1028- with mock .patch ('optimizely.decision_service.DecisionService.get_variation' ,
1029- return_value = self .project_config .get_variation_from_id (
1030- 'test_experiment' , '111128'
1031- )) as mock_get_variation , \
1032- mock .patch ('time.time' , return_value = 42 ), \
1033- mock .patch ('uuid.uuid4' , return_value = 'a68cf1ad-0393-4e18-af87-efe8f01a7c9c' ), \
1034- mock .patch ('optimizely.event_dispatcher.EventDispatcher.dispatch_event' ) as mock_dispatch_event :
1035- self .optimizely .track ('test_event' , 'test_user' , attributes = {'test_attribute' : 'test_value' }, event_tags = 4200 )
1036-
1037- expected_params = {
1038- 'account_id' : '12001' ,
1039- 'project_id' : '111001' ,
1040- 'visitors' : [{
1041- 'visitor_id' : 'test_user' ,
1042- 'attributes' : [{
1043- 'type' : 'custom' ,
1044- 'value' : 'test_value' ,
1045- 'entity_id' : '111094' ,
1046- 'key' : 'test_attribute'
1047- }],
1048- 'snapshots' : [{
1049- 'decisions' : [{
1050- 'variation_id' : '111128' ,
1051- 'experiment_id' : '111127' ,
1052- 'campaign_id' : '111182'
1053- }],
1054- 'events' : [{
1055- 'entity_id' : '111095' ,
1056- 'key' : 'test_event' ,
1057- 'revenue' : 4200 ,
1058- 'tags' : {
1059- 'revenue' : 4200 ,
1060- },
1061- 'timestamp' : 42000 ,
1062- 'uuid' : 'a68cf1ad-0393-4e18-af87-efe8f01a7c9c' ,
1063- }]
1064- }],
1065- }],
1066- 'client_version' : version .__version__ ,
1067- 'client_name' : 'python-sdk' ,
1068- 'anonymize_ip' : False
1069- }
1070- mock_get_variation .assert_called_once_with (self .project_config .get_experiment_from_key ('test_experiment' ),
1071- 'test_user' , {'test_attribute' : 'test_value' })
1072- self .assertEqual (1 , mock_dispatch_event .call_count )
1073- self ._validate_event_object (mock_dispatch_event .call_args [0 ][0 ], 'https://logx.optimizely.com/v1/events' ,
1074- expected_params , 'POST' , {'Content-Type' : 'application/json' })
1075-
10761025 def test_track__with_invalid_event_tags (self ):
10771026 """ Test that track calls dispatch_event with right params when invalid event tags are provided. """
10781027
@@ -1727,6 +1676,12 @@ def test_track__with_attributes__invalid_attributes(self):
17271676 self .assertRaisesRegexp (exceptions .InvalidAttributeException , enums .Errors .INVALID_ATTRIBUTE_FORMAT ,
17281677 self .optimizely .track , 'test_event' , 'test_user' , attributes = 'invalid' )
17291678
1679+ def test_track__with_event_tag__invalid_event_tag (self ):
1680+ """ Test that track raises exception if event_tag is in invalid format. """
1681+
1682+ self .assertRaisesRegexp (exceptions .InvalidEventTagException , enums .Errors .INVALID_EVENT_TAG_FORMAT ,
1683+ self .optimizely .track , 'test_event' , 'test_user' , event_tags = 4200 )
1684+
17301685 def test_get_variation__with_attributes__invalid_attributes (self ):
17311686 """ Test that get variation raises exception if attributes are in invalid format. """
17321687
@@ -1847,23 +1802,16 @@ def test_track__invalid_attributes(self):
18471802
18481803 mock_logging .assert_called_once_with (enums .LogLevels .ERROR , 'Provided attributes are in an invalid format.' )
18491804
1850- def test_track__deprecated_event_tag (self ):
1851- """ Test that expected log messages are logged during track when attributes are in invalid format. """
1852-
1853- with mock .patch ('optimizely.logger.SimpleLogger.log' ) as mock_logging :
1854- self .optimizely .track ('test_event' , 'test_user' , event_tags = 4200 )
1855-
1856- mock_logging .assert_any_call (enums .LogLevels .WARNING ,
1857- 'Event value is deprecated in track call. '
1858- 'Use event tags to pass in revenue value instead.' )
1859-
18601805 def test_track__invalid_event_tag (self ):
1861- """ Test that expected log messages are logged during track when attributes are in invalid format. """
1806+ """ Test that expected log messages are logged during track when event_tag is in invalid format. """
18621807
18631808 with mock .patch ('optimizely.logger.SimpleLogger.log' ) as mock_logging :
18641809 self .optimizely .track ('test_event' , 'test_user' , event_tags = '4200' )
1810+ mock_logging .assert_called_once_with (enums .LogLevels .ERROR , 'Provided event tags are in an invalid format.' )
18651811
1866- mock_logging .assert_called_once_with (enums .LogLevels .ERROR , 'Provided event tags are in an invalid format.' )
1812+ with mock .patch ('optimizely.logger.SimpleLogger.log' ) as mock_logging :
1813+ self .optimizely .track ('test_event' , 'test_user' , event_tags = 4200 )
1814+ mock_logging .assert_called_once_with (enums .LogLevels .ERROR , 'Provided event tags are in an invalid format.' )
18671815
18681816 def test_track__dispatch_raises_exception (self ):
18691817 """ Test that track logs dispatch failure gracefully. """
0 commit comments