diff --git a/optimizely/helpers/event_tag_utils.py b/optimizely/helpers/event_tag_utils.py index 7e26e0e7..bf6c967b 100644 --- a/optimizely/helpers/event_tag_utils.py +++ b/optimizely/helpers/event_tag_utils.py @@ -16,6 +16,7 @@ REVENUE_METRIC_TYPE = 'revenue' NUMERIC_METRIC_TYPE = 'value' + def get_revenue_value(event_tags): if event_tags is None: return None @@ -33,6 +34,7 @@ def get_revenue_value(event_tags): return raw_value + def get_numeric_value(event_tags): if event_tags is None: return None @@ -49,4 +51,4 @@ def get_numeric_value(event_tags): if not isinstance(raw_value, float): return None - return raw_value \ No newline at end of file + return raw_value diff --git a/tests/helpers_tests/test_event_tag_utils.py b/tests/helpers_tests/test_event_tag_utils.py index dcf3bc63..0508d14f 100644 --- a/tests/helpers_tests/test_event_tag_utils.py +++ b/tests/helpers_tests/test_event_tag_utils.py @@ -92,4 +92,3 @@ def test_get_numeric_value__value_tag(self): min_float = sys.float_info.min self.assertEqual(min_float, event_tag_utils.get_numeric_value({'value': min_float})) - diff --git a/tests/test_event_builder.py b/tests/test_event_builder.py index d708aafc..98e04750 100644 --- a/tests/test_event_builder.py +++ b/tests/test_event_builder.py @@ -257,7 +257,10 @@ def test_create_conversion_event__with_event_tags(self): with mock.patch('time.time', return_value=42.123), \ mock.patch('optimizely.bucketer.Bucketer._generate_bucket_value', return_value=5042): event_obj = self.event_builder.create_conversion_event( - 'test_event', 'test_user', {'test_attribute': 'test_value'}, {'revenue': 4200, 'value': 1.234, 'non-revenue': 'abc'}, + 'test_event', + 'test_user', + {'test_attribute': 'test_value'}, + {'revenue': 4200, 'value': 1.234, 'non-revenue': 'abc'}, [('111127', '111129')] ) @@ -321,7 +324,10 @@ def test_create_conversion_event__with_event_tags_revenue(self): with mock.patch('time.time', return_value=42.123), \ mock.patch('optimizely.bucketer.Bucketer._generate_bucket_value', return_value=5042): event_obj = self.event_builder.create_conversion_event( - 'test_event', 'test_user', {'test_attribute': 'test_value'}, {'revenue': 4200, 'non-revenue': 'abc'}, + 'test_event', + 'test_user', + {'test_attribute': 'test_value'}, + {'revenue': 4200, 'non-revenue': 'abc'}, [('111127', '111129')] ) @@ -451,7 +457,10 @@ def test_create_conversion_event__with_invalid_event_tags(self): with mock.patch('time.time', return_value=42.123), \ mock.patch('optimizely.bucketer.Bucketer._generate_bucket_value', return_value=5042): event_obj = self.event_builder.create_conversion_event( - 'test_event', 'test_user', {'test_attribute': 'test_value'}, {'revenue': '4200', 'value': '1.234', 'non-revenue': 'abc'}, + 'test_event', + 'test_user', + {'test_attribute': 'test_value'}, + {'revenue': '4200', 'value': '1.234', 'non-revenue': 'abc'}, [('111127', '111129')] ) # Sort event features based on ID @@ -649,7 +658,10 @@ def test_create_conversion_event__with_event_tags(self): mock.patch('optimizely.bucketer.Bucketer._generate_bucket_value', return_value=5042), \ mock.patch('uuid.uuid4', return_value='a68cf1ad-0393-4e18-af87-efe8f01a7c9c'): event_obj = self.event_builder.create_conversion_event( - 'test_event', 'test_user', {'test_attribute': 'test_value'}, {'revenue': 4200, 'value': 1.234, 'non-revenue': 'abc'}, + 'test_event', + 'test_user', + {'test_attribute': 'test_value'}, + {'revenue': 4200, 'value': 1.234, 'non-revenue': 'abc'}, [('111127', '111129')] ) self._validate_event_object(event_obj, @@ -700,7 +712,10 @@ def test_create_conversion_event__with_invalid_event_tags(self): mock.patch('optimizely.bucketer.Bucketer._generate_bucket_value', return_value=5042), \ mock.patch('uuid.uuid4', return_value='a68cf1ad-0393-4e18-af87-efe8f01a7c9c'): event_obj = self.event_builder.create_conversion_event( - 'test_event', 'test_user', {'test_attribute': 'test_value'}, {'revenue': '4200', 'value': '1.234', 'non-revenue': 'abc'}, + 'test_event', + 'test_user', + {'test_attribute': 'test_value'}, + {'revenue': '4200', 'value': '1.234', 'non-revenue': 'abc'}, [('111127', '111129')] ) self._validate_event_object(event_obj, diff --git a/tests/test_optimizely.py b/tests/test_optimizely.py index 52044d39..6a80c4c4 100644 --- a/tests/test_optimizely.py +++ b/tests/test_optimizely.py @@ -383,7 +383,7 @@ def test_track__with_event_tags(self): mock.patch('time.time', return_value=42), \ mock.patch('optimizely.event_dispatcher.EventDispatcher.dispatch_event') as mock_dispatch_event: self.optimizely.track('test_event', 'test_user', attributes={'test_attribute': 'test_value'}, - event_tags={'revenue': 4200, 'value':1.234, 'non-revenue': 'abc'}) + event_tags={'revenue': 4200, 'value': 1.234, 'non-revenue': 'abc'}) expected_params = { 'visitorId': 'test_user', @@ -527,7 +527,7 @@ def test_track__with_event_tags_numeric_value(self): mock.patch('time.time', return_value=42), \ mock.patch('optimizely.event_dispatcher.EventDispatcher.dispatch_event') as mock_dispatch_event: self.optimizely.track('test_event', 'test_user', attributes={'test_attribute': 'test_value'}, - event_tags={'value':1.234, 'non-revenue': 'abc'}) + event_tags={'value': 1.234, 'non-revenue': 'abc'}) expected_params = { 'visitorId': 'test_user',