@@ -862,28 +862,28 @@ def test_experiments_with_different_name_same_cache(self, m_parse_experiment):
862862
863863 def test_experiments_with_same_name_updated_cache (self ):
864864 self .experiments_factory .cfg_mtime = 0.0
865- ts = time . time () - THIRTY_DAYS
866- stop_ts_1 = ts + 500
867- stop_ts_2 = stop_ts_1 + 1000
865+
866+ version_1 = "1"
867+ version_2 = "2"
868868
869869 value1 = {
870870 "id" : 1 ,
871871 "name" : "test" ,
872872 "owner" : "" ,
873873 "type" : "r2" ,
874- "version" : "1" ,
875- "start_ts" : ts ,
876- "stop_ts" : stop_ts_1 ,
874+ "version" : version_1 ,
875+ "start_ts" : time . time () - THIRTY_DAYS ,
876+ "stop_ts" : time . time () + THIRTY_DAYS ,
877877 "experiment" : {"variants" : {"active" : 10 , "control_1" : 10 , "control_2" : 10 }},
878878 }
879879 value2 = {
880880 "id" : 1 ,
881881 "name" : "test" ,
882882 "owner" : "" ,
883883 "type" : "r2" ,
884- "version" : "1" ,
885- "start_ts" : ts ,
886- "stop_ts" : stop_ts_2 ,
884+ "version" : version_2 ,
885+ "start_ts" : time . time () - THIRTY_DAYS ,
886+ "stop_ts" : time . time () + THIRTY_DAYS ,
887887 "experiment" : {"variants" : {"active" : 10 , "control_1" : 10 , "control_2" : 10 }},
888888 }
889889
@@ -895,8 +895,8 @@ def test_experiments_with_same_name_updated_cache(self):
895895 experiment_one ._get_experiment ("test" )
896896
897897 self .assertTrue ("test" in self .experiments_factory ._global_cache )
898- self .assertEqual (experiment_one ._global_cache ["test" ].stop_ts , stop_ts_1 )
899- self .assertEqual (self .experiments_factory ._global_cache ["test" ].stop_ts , stop_ts_1 )
898+ self .assertEqual (experiment_one ._global_cache ["test" ].version , version_1 )
899+ self .assertEqual (self .experiments_factory ._global_cache ["test" ].version , version_1 )
900900
901901 # updated test config file to value2
902902 cfg_data = {"test" : value2 }
@@ -906,39 +906,38 @@ def test_experiments_with_same_name_updated_cache(self):
906906
907907 experiment_two ._get_experiment ("test" )
908908 self .assertTrue ("test" in self .experiments_factory ._global_cache )
909- self .assertEqual (experiment_two ._global_cache ["test" ].stop_ts , stop_ts_2 )
909+ self .assertEqual (experiment_two ._global_cache ["test" ].version , version_2 )
910910
911911 # experiment_one global cache still use old one
912- self .assertEqual (experiment_one ._global_cache ["test" ].stop_ts , stop_ts_1 )
912+ self .assertEqual (experiment_one ._global_cache ["test" ].version , version_1 )
913913
914914 # global cache was updated by experiment_two
915- self .assertEqual (self .experiments_factory ._global_cache ["test" ].stop_ts , stop_ts_2 )
915+ self .assertEqual (self .experiments_factory ._global_cache ["test" ].version , version_2 )
916916
917917 def test_experiments_with_different_name_updated_cache (self ):
918918 self .experiments_factory .cfg_mtime = 0.0
919919
920- ts = time .time () - THIRTY_DAYS
921- stop_ts_1 = ts + 500
922- stop_ts_2 = stop_ts_1 + 1000
920+ version_1 = "1"
921+ version_2 = "2"
923922
924923 value1 = {
925924 "id" : 1 ,
926925 "name" : "test1" ,
927926 "owner" : "" ,
928927 "type" : "r2" ,
929- "version" : "1" ,
930- "start_ts" : ts ,
931- "stop_ts" : stop_ts_1 ,
928+ "version" : version_1 ,
929+ "start_ts" : time . time () - THIRTY_DAYS ,
930+ "stop_ts" : time . time () + THIRTY_DAYS ,
932931 "experiment" : {"variants" : {"active" : 10 , "control_1" : 10 , "control_2" : 10 }},
933932 }
934933 value2 = {
935934 "id" : 2 ,
936935 "name" : "test2" ,
937936 "owner" : "test2" ,
938937 "type" : "r2" ,
939- "version" : "1" ,
940- "start_ts" : ts ,
941- "stop_ts" : stop_ts_2 ,
938+ "version" : version_2 ,
939+ "start_ts" : time . time () - THIRTY_DAYS ,
940+ "stop_ts" : time . time () + THIRTY_DAYS ,
942941 "experiment" : {"variants" : {"active" : 10 , "control_1" : 10 , "control_2" : 10 }},
943942 }
944943
@@ -951,7 +950,7 @@ def test_experiments_with_different_name_updated_cache(self):
951950
952951 self .assertTrue ("test1" in self .experiments_factory ._global_cache )
953952 self .assertFalse ("test2" in self .experiments_factory ._global_cache )
954- self .assertEqual (self .experiments_factory ._global_cache ["test1" ].stop_ts , stop_ts_1 )
953+ self .assertEqual (self .experiments_factory ._global_cache ["test1" ].version , version_1 )
955954
956955 # updated test config file
957956 # experiment_two add test2 into global cache
@@ -962,12 +961,12 @@ def test_experiments_with_different_name_updated_cache(self):
962961 experiment_two ._get_experiment ("test2" )
963962 self .assertTrue ("test2" in experiment_two ._global_cache )
964963 self .assertFalse ("test1" in experiment_two ._global_cache )
965- self .assertEqual (experiment_two ._global_cache ["test2" ].stop_ts , stop_ts_1 )
964+ self .assertEqual (experiment_two ._global_cache ["test2" ].version , version_2 )
966965
967966 # experiment_one global cache still use old one
968- self .assertEqual (experiment_one ._global_cache ["test1" ].stop_ts , stop_ts_1 )
967+ self .assertEqual (experiment_one ._global_cache ["test1" ].version , version_1 )
969968
970969 # global cache only contains test2 experiment
971970 self .assertTrue ("test2" in self .experiments_factory ._global_cache )
972971 self .assertFalse ("test1" in self .experiments_factory ._global_cache )
973- self .assertEqual (self .experiments_factory ._global_cache ["test2" ].stops_ts , stop_ts_2 )
972+ self .assertEqual (self .experiments_factory ._global_cache ["test2" ].version , version_2 )
0 commit comments