@@ -4890,66 +4890,6 @@ def test_odp_events_not_sent_with_legacy_apis(self):
4890
4890
4891
4891
client .close ()
4892
4892
4893
- def test_activate_with_cmab_uuid (self ):
4894
- """ Test that activate includes CMAB UUID when available from CMAB service. """
4895
- expected_cmab_uuid = "test-cmab-uuid-123"
4896
- variation_result = {
4897
- 'variation' : self .project_config .get_variation_from_id ('test_experiment' , '111129' ),
4898
- 'cmab_uuid' : expected_cmab_uuid ,
4899
- 'reasons' : [],
4900
- 'error' : False
4901
- }
4902
-
4903
- with mock .patch (
4904
- 'optimizely.decision_service.DecisionService.get_variation' ,
4905
- return_value = variation_result ,
4906
- ), mock .patch ('time.time' , return_value = 42 ), mock .patch (
4907
- 'uuid.uuid4' , return_value = 'a68cf1ad-0393-4e18-af87-efe8f01a7c9c'
4908
- ), mock .patch (
4909
- 'optimizely.event.event_processor.BatchEventProcessor.process'
4910
- ) as mock_process :
4911
- result = self .optimizely .activate ('test_experiment' , 'test_user' )
4912
- self .assertEqual ('variation' , result )
4913
-
4914
- # Verify the impression event includes CMAB UUID
4915
- impression_event = mock_process .call_args [0 ][0 ]
4916
- self .assertEqual (impression_event .cmab_uuid , expected_cmab_uuid )
4917
-
4918
- # Verify the log event includes CMAB UUID in metadata
4919
- log_event = EventFactory .create_log_event (impression_event , self .optimizely .logger )
4920
- metadata = log_event .params ['visitors' ][0 ]['snapshots' ][0 ]['decisions' ][0 ]['metadata' ]
4921
- self .assertIn ('cmab_uuid' , metadata )
4922
- self .assertEqual (metadata ['cmab_uuid' ], expected_cmab_uuid )
4923
-
4924
- def test_activate_without_cmab_uuid (self ):
4925
- """ Test that activate works correctly when CMAB service returns None. """
4926
- variation_result = {
4927
- 'variation' : self .project_config .get_variation_from_id ('test_experiment' , '111129' ),
4928
- 'cmab_uuid' : None ,
4929
- 'reasons' : [],
4930
- 'error' : False
4931
- }
4932
-
4933
- with mock .patch (
4934
- 'optimizely.decision_service.DecisionService.get_variation' ,
4935
- return_value = variation_result ,
4936
- ), mock .patch ('time.time' , return_value = 42 ), mock .patch (
4937
- 'uuid.uuid4' , return_value = 'a68cf1ad-0393-4e18-af87-efe8f01a7c9c'
4938
- ), mock .patch (
4939
- 'optimizely.event.event_processor.BatchEventProcessor.process'
4940
- ) as mock_process :
4941
- result = self .optimizely .activate ('test_experiment' , 'test_user' )
4942
- self .assertEqual ('variation' , result )
4943
-
4944
- # Verify the impression event has no CMAB UUID
4945
- impression_event = mock_process .call_args [0 ][0 ]
4946
- self .assertIsNone (impression_event .cmab_uuid )
4947
-
4948
- # Verify the log event does not include CMAB UUID in metadata
4949
- log_event = EventFactory .create_log_event (impression_event , self .optimizely .logger )
4950
- metadata = log_event .params ['visitors' ][0 ]['snapshots' ][0 ]['decisions' ][0 ]['metadata' ]
4951
- self .assertNotIn ('cmab_uuid' , metadata )
4952
-
4953
4893
def test_get_variation_with_cmab_uuid (self ):
4954
4894
""" Test that get_variation works correctly with CMAB UUID. """
4955
4895
expected_cmab_uuid = "get-variation-cmab-uuid"
@@ -4965,7 +4905,7 @@ def test_get_variation_with_cmab_uuid(self):
4965
4905
return_value = variation_result ,
4966
4906
), mock .patch ('optimizely.notification_center.NotificationCenter.send_notifications' ) as mock_broadcast :
4967
4907
variation = self .optimizely .get_variation ('test_experiment' , 'test_user' )
4968
- self .assertEqual ('variation' , variation [ 'variation' ]. key )
4908
+ self .assertEqual ('variation' , variation )
4969
4909
4970
4910
# Verify decision notification is sent with correct parameters
4971
4911
mock_broadcast .assert_any_call (
@@ -4990,7 +4930,7 @@ def test_get_variation_without_cmab_uuid(self):
4990
4930
return_value = variation_result ,
4991
4931
), mock .patch ('optimizely.notification_center.NotificationCenter.send_notifications' ) as mock_broadcast :
4992
4932
variation = self .optimizely .get_variation ('test_experiment' , 'test_user' )
4993
- self .assertEqual ('variation' , variation [ 'variation' ]. key )
4933
+ self .assertEqual ('variation' , variation )
4994
4934
4995
4935
# Verify decision notification is sent correctly
4996
4936
mock_broadcast .assert_any_call (
0 commit comments