@@ -283,6 +283,8 @@ def test_decide__feature_test(self):
283
283
'reasons' : expected .reasons ,
284
284
'decision_event_dispatched' : True ,
285
285
'variables' : expected .variables ,
286
+ 'experiment_id' : mock_experiment .id ,
287
+ 'variation_id' : mock_variation .id
286
288
},
287
289
)
288
290
@@ -391,6 +393,24 @@ def test_decide_feature_rollout(self):
391
393
392
394
self .compare_opt_decisions (expected , actual )
393
395
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
+
394
414
# assert notification count
395
415
self .assertEqual (1 , mock_broadcast_decision .call_count )
396
416
@@ -408,27 +428,11 @@ def test_decide_feature_rollout(self):
408
428
'reasons' : expected .reasons ,
409
429
'decision_event_dispatched' : True ,
410
430
'variables' : expected .variables ,
431
+ 'experiment_id' : expected_experiment .id ,
432
+ 'variation_id' : expected_var .id
411
433
},
412
434
)
413
435
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
-
432
436
def test_decide_feature_rollout__send_flag_decision_false (self ):
433
437
opt_obj = optimizely .Optimizely (json .dumps (self .config_dict_with_features ))
434
438
project_config = opt_obj .config_manager .get_config ()
@@ -467,6 +471,8 @@ def test_decide_feature_rollout__send_flag_decision_false(self):
467
471
self .assertEqual (1 , mock_broadcast_decision .call_count )
468
472
469
473
# 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 )
470
476
mock_broadcast_decision .assert_called_with (
471
477
enums .NotificationTypes .DECISION ,
472
478
'flag' ,
@@ -480,6 +486,8 @@ def test_decide_feature_rollout__send_flag_decision_false(self):
480
486
'reasons' : expected .reasons ,
481
487
'decision_event_dispatched' : False ,
482
488
'variables' : expected .variables ,
489
+ 'experiment_id' : expected_experiment .id ,
490
+ 'variation_id' : expected_var .id
483
491
},
484
492
)
485
493
@@ -549,7 +557,9 @@ def test_decide_feature_null_variation(self):
549
557
'reasons' : expected .reasons ,
550
558
'decision_event_dispatched' : True ,
551
559
'variables' : expected .variables ,
552
- },
560
+ 'experiment_id' : None ,
561
+ 'variation_id' : None
562
+ }
553
563
)
554
564
555
565
# assert event count
@@ -632,6 +642,8 @@ def test_decide_feature_null_variation__send_flag_decision_false(self):
632
642
'reasons' : expected .reasons ,
633
643
'decision_event_dispatched' : False ,
634
644
'variables' : expected .variables ,
645
+ 'experiment_id' : None ,
646
+ 'variation_id' : None
635
647
},
636
648
)
637
649
@@ -701,6 +713,8 @@ def test_decide__option__disable_decision_event(self):
701
713
'reasons' : expected .reasons ,
702
714
'decision_event_dispatched' : False ,
703
715
'variables' : expected .variables ,
716
+ 'experiment_id' : mock_experiment .id ,
717
+ 'variation_id' : mock_variation .id ,
704
718
},
705
719
)
706
720
@@ -773,6 +787,8 @@ def test_decide__default_option__disable_decision_event(self):
773
787
'reasons' : expected .reasons ,
774
788
'decision_event_dispatched' : False ,
775
789
'variables' : expected .variables ,
790
+ 'experiment_id' : mock_experiment .id ,
791
+ 'variation_id' : mock_variation .id
776
792
},
777
793
)
778
794
@@ -834,6 +850,8 @@ def test_decide__option__exclude_variables(self):
834
850
'reasons' : expected .reasons ,
835
851
'decision_event_dispatched' : True ,
836
852
'variables' : expected .variables ,
853
+ 'experiment_id' : mock_experiment .id ,
854
+ 'variation_id' : mock_variation .id ,
837
855
},
838
856
)
839
857
@@ -948,6 +966,8 @@ def test_decide__option__enabled_flags_only(self):
948
966
'reasons' : expected .reasons ,
949
967
'decision_event_dispatched' : True ,
950
968
'variables' : expected .variables ,
969
+ 'experiment_id' : expected_experiment .id ,
970
+ 'variation_id' : expected_var .id ,
951
971
},
952
972
)
953
973
@@ -1006,7 +1026,7 @@ def test_decide__default_options__with__options(self):
1006
1026
enabled = True ,
1007
1027
variables = expected_variables ,
1008
1028
flag_key = 'test_feature_in_experiment' ,
1009
- user_context = user_context
1029
+ user_context = user_context ,
1010
1030
)
1011
1031
1012
1032
self .compare_opt_decisions (expected , actual )
@@ -1025,6 +1045,8 @@ def test_decide__default_options__with__options(self):
1025
1045
'reasons' : expected .reasons ,
1026
1046
'decision_event_dispatched' : False ,
1027
1047
'variables' : expected .variables ,
1048
+ 'experiment_id' : mock_experiment .id ,
1049
+ 'variation_id' : mock_variation .id
1028
1050
},
1029
1051
)
1030
1052
@@ -1490,6 +1512,9 @@ def test_should_return_valid_decision_after_setting_and_removing_forced_decision
1490
1512
'User "test_user" is in variation "control" of experiment test_experiment.' ]
1491
1513
)
1492
1514
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
+
1493
1518
# assert notification count
1494
1519
self .assertEqual (1 , mock_broadcast_decision .call_count )
1495
1520
@@ -1507,12 +1532,11 @@ def test_should_return_valid_decision_after_setting_and_removing_forced_decision
1507
1532
'reasons' : expected .reasons ,
1508
1533
'decision_event_dispatched' : True ,
1509
1534
'variables' : expected .variables ,
1535
+ 'experiment_id' : expected_experiment .id ,
1536
+ 'variation_id' : expected_var .id
1510
1537
},
1511
1538
)
1512
1539
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
-
1516
1540
mock_send_event .assert_called_with (
1517
1541
project_config ,
1518
1542
expected_experiment ,
0 commit comments