@@ -283,6 +283,8 @@ def test_decide__feature_test(self):
283283 'reasons' : expected .reasons ,
284284 'decision_event_dispatched' : True ,
285285 'variables' : expected .variables ,
286+ 'experiment_id' : mock_experiment .id ,
287+ 'variation_id' : mock_variation .id
286288 },
287289 )
288290
@@ -391,6 +393,24 @@ def test_decide_feature_rollout(self):
391393
392394 self .compare_opt_decisions (expected , actual )
393395
396+ # assert event count
397+ self .assertEqual (1 , mock_send_event .call_count )
398+
399+ # assert event payload
400+ expected_experiment = project_config .get_experiment_from_key (expected .rule_key )
401+ expected_var = project_config .get_variation_from_key (expected .rule_key , expected .variation_key )
402+ mock_send_event .assert_called_with (
403+ project_config ,
404+ expected_experiment ,
405+ expected_var ,
406+ expected .flag_key ,
407+ expected .rule_key ,
408+ 'rollout' ,
409+ expected .enabled ,
410+ 'test_user' ,
411+ user_attributes
412+ )
413+
394414 # assert notification count
395415 self .assertEqual (1 , mock_broadcast_decision .call_count )
396416
@@ -408,27 +428,11 @@ def test_decide_feature_rollout(self):
408428 'reasons' : expected .reasons ,
409429 'decision_event_dispatched' : True ,
410430 'variables' : expected .variables ,
431+ 'experiment_id' : expected_experiment .id ,
432+ 'variation_id' : expected_var .id
411433 },
412434 )
413435
414- # assert event count
415- self .assertEqual (1 , mock_send_event .call_count )
416-
417- # assert event payload
418- expected_experiment = project_config .get_experiment_from_key (expected .rule_key )
419- expected_var = project_config .get_variation_from_key (expected .rule_key , expected .variation_key )
420- mock_send_event .assert_called_with (
421- project_config ,
422- expected_experiment ,
423- expected_var ,
424- expected .flag_key ,
425- expected .rule_key ,
426- 'rollout' ,
427- expected .enabled ,
428- 'test_user' ,
429- user_attributes
430- )
431-
432436 def test_decide_feature_rollout__send_flag_decision_false (self ):
433437 opt_obj = optimizely .Optimizely (json .dumps (self .config_dict_with_features ))
434438 project_config = opt_obj .config_manager .get_config ()
@@ -467,6 +471,8 @@ def test_decide_feature_rollout__send_flag_decision_false(self):
467471 self .assertEqual (1 , mock_broadcast_decision .call_count )
468472
469473 # assert notification
474+ expected_experiment = project_config .get_experiment_from_key (expected .rule_key )
475+ expected_var = project_config .get_variation_from_key (expected .rule_key , expected .variation_key )
470476 mock_broadcast_decision .assert_called_with (
471477 enums .NotificationTypes .DECISION ,
472478 'flag' ,
@@ -480,6 +486,8 @@ def test_decide_feature_rollout__send_flag_decision_false(self):
480486 'reasons' : expected .reasons ,
481487 'decision_event_dispatched' : False ,
482488 'variables' : expected .variables ,
489+ 'experiment_id' : expected_experiment .id ,
490+ 'variation_id' : expected_var .id
483491 },
484492 )
485493
@@ -549,7 +557,9 @@ def test_decide_feature_null_variation(self):
549557 'reasons' : expected .reasons ,
550558 'decision_event_dispatched' : True ,
551559 'variables' : expected .variables ,
552- },
560+ 'experiment_id' : None ,
561+ 'variation_id' : None
562+ }
553563 )
554564
555565 # assert event count
@@ -632,6 +642,8 @@ def test_decide_feature_null_variation__send_flag_decision_false(self):
632642 'reasons' : expected .reasons ,
633643 'decision_event_dispatched' : False ,
634644 'variables' : expected .variables ,
645+ 'experiment_id' : None ,
646+ 'variation_id' : None
635647 },
636648 )
637649
@@ -701,6 +713,8 @@ def test_decide__option__disable_decision_event(self):
701713 'reasons' : expected .reasons ,
702714 'decision_event_dispatched' : False ,
703715 'variables' : expected .variables ,
716+ 'experiment_id' : mock_experiment .id ,
717+ 'variation_id' : mock_variation .id ,
704718 },
705719 )
706720
@@ -773,6 +787,8 @@ def test_decide__default_option__disable_decision_event(self):
773787 'reasons' : expected .reasons ,
774788 'decision_event_dispatched' : False ,
775789 'variables' : expected .variables ,
790+ 'experiment_id' : mock_experiment .id ,
791+ 'variation_id' : mock_variation .id
776792 },
777793 )
778794
@@ -834,6 +850,8 @@ def test_decide__option__exclude_variables(self):
834850 'reasons' : expected .reasons ,
835851 'decision_event_dispatched' : True ,
836852 'variables' : expected .variables ,
853+ 'experiment_id' : mock_experiment .id ,
854+ 'variation_id' : mock_variation .id ,
837855 },
838856 )
839857
@@ -948,6 +966,8 @@ def test_decide__option__enabled_flags_only(self):
948966 'reasons' : expected .reasons ,
949967 'decision_event_dispatched' : True ,
950968 'variables' : expected .variables ,
969+ 'experiment_id' : expected_experiment .id ,
970+ 'variation_id' : expected_var .id ,
951971 },
952972 )
953973
@@ -1006,7 +1026,7 @@ def test_decide__default_options__with__options(self):
10061026 enabled = True ,
10071027 variables = expected_variables ,
10081028 flag_key = 'test_feature_in_experiment' ,
1009- user_context = user_context
1029+ user_context = user_context ,
10101030 )
10111031
10121032 self .compare_opt_decisions (expected , actual )
@@ -1025,6 +1045,8 @@ def test_decide__default_options__with__options(self):
10251045 'reasons' : expected .reasons ,
10261046 'decision_event_dispatched' : False ,
10271047 'variables' : expected .variables ,
1048+ 'experiment_id' : mock_experiment .id ,
1049+ 'variation_id' : mock_variation .id
10281050 },
10291051 )
10301052
@@ -1490,6 +1512,9 @@ def test_should_return_valid_decision_after_setting_and_removing_forced_decision
14901512 'User "test_user" is in variation "control" of experiment test_experiment.' ]
14911513 )
14921514
1515+ expected_experiment = project_config .get_experiment_from_key (expected .rule_key )
1516+ expected_var = project_config .get_variation_from_key ('test_experiment' , expected .variation_key )
1517+
14931518 # assert notification count
14941519 self .assertEqual (1 , mock_broadcast_decision .call_count )
14951520
@@ -1507,12 +1532,11 @@ def test_should_return_valid_decision_after_setting_and_removing_forced_decision
15071532 'reasons' : expected .reasons ,
15081533 'decision_event_dispatched' : True ,
15091534 'variables' : expected .variables ,
1535+ 'experiment_id' : expected_experiment .id ,
1536+ 'variation_id' : expected_var .id
15101537 },
15111538 )
15121539
1513- expected_experiment = project_config .get_experiment_from_key (expected .rule_key )
1514- expected_var = project_config .get_variation_from_key ('test_experiment' , expected .variation_key )
1515-
15161540 mock_send_event .assert_called_with (
15171541 project_config ,
15181542 expected_experiment ,
0 commit comments