@@ -1906,106 +1906,5 @@ def test_feature_rollout_with_no_rollout(self):
19061906 self .assertEqual (len (experiment .variations ), 1 )
19071907 self .assertEqual (len (experiment .trafficAllocation ), 1 )
19081908
1909- def test_feature_rollout_everyone_else_is_last_rollout_rule (self ):
1910- """Test that the everyone else variation comes from the LAST rollout rule."""
1911- datafile = self ._build_datafile (
1912- experiments = [
1913- {
1914- 'id' : 'exp_fr' ,
1915- 'key' : 'feature_rollout_exp' ,
1916- 'status' : 'Running' ,
1917- 'forcedVariations' : {},
1918- 'layerId' : 'layer_1' ,
1919- 'audienceIds' : [],
1920- 'trafficAllocation' : [{'entityId' : 'fr_var' , 'endOfRange' : 5000 }],
1921- 'variations' : [
1922- {'key' : 'fr_var' , 'id' : 'fr_var' , 'featureEnabled' : True }
1923- ],
1924- 'type' : 'feature_rollout' ,
1925- },
1926- ],
1927- rollouts = [
1928- {
1929- 'id' : 'rollout_1' ,
1930- 'experiments' : [
1931- {
1932- 'id' : 'targeted_rule_1' ,
1933- 'key' : 'targeted_rule_1' ,
1934- 'status' : 'Running' ,
1935- 'forcedVariations' : {},
1936- 'layerId' : 'rollout_1' ,
1937- 'audienceIds' : ['aud_1' ],
1938- 'trafficAllocation' : [
1939- {'entityId' : 'targeted_var_1' , 'endOfRange' : 10000 }
1940- ],
1941- 'variations' : [
1942- {
1943- 'key' : 'targeted_var_1' ,
1944- 'id' : 'targeted_var_1' ,
1945- 'featureEnabled' : True ,
1946- }
1947- ],
1948- },
1949- {
1950- 'id' : 'targeted_rule_2' ,
1951- 'key' : 'targeted_rule_2' ,
1952- 'status' : 'Running' ,
1953- 'forcedVariations' : {},
1954- 'layerId' : 'rollout_1' ,
1955- 'audienceIds' : ['aud_2' ],
1956- 'trafficAllocation' : [
1957- {'entityId' : 'targeted_var_2' , 'endOfRange' : 10000 }
1958- ],
1959- 'variations' : [
1960- {
1961- 'key' : 'targeted_var_2' ,
1962- 'id' : 'targeted_var_2' ,
1963- 'featureEnabled' : True ,
1964- }
1965- ],
1966- },
1967- {
1968- 'id' : 'everyone_else_rule' ,
1969- 'key' : 'everyone_else_rule' ,
1970- 'status' : 'Running' ,
1971- 'forcedVariations' : {},
1972- 'layerId' : 'rollout_1' ,
1973- 'audienceIds' : [],
1974- 'trafficAllocation' : [
1975- {'entityId' : 'correct_everyone_var' , 'endOfRange' : 10000 }
1976- ],
1977- 'variations' : [
1978- {
1979- 'key' : 'correct_everyone_var' ,
1980- 'id' : 'correct_everyone_var' ,
1981- 'featureEnabled' : False ,
1982- }
1983- ],
1984- },
1985- ],
1986- }
1987- ],
1988- feature_flags = [
1989- {
1990- 'id' : 'flag_1' ,
1991- 'key' : 'test_flag' ,
1992- 'experimentIds' : ['exp_fr' ],
1993- 'rolloutId' : 'rollout_1' ,
1994- 'variables' : [],
1995- },
1996- ],
1997- )
1998-
1999- opt = optimizely .Optimizely (json .dumps (datafile ))
2000- config = opt .config_manager .get_config ()
2001-
2002- experiment = config .experiment_id_map ['exp_fr' ]
2003-
2004- # Should have injected the correct (last) everyone else variation
2005- variation_ids = [v ['id' ] if isinstance (v , dict ) else v .id for v in experiment .variations ]
2006- self .assertIn ('correct_everyone_var' , variation_ids )
2007- # Should NOT have injected targeted rule variations
2008- self .assertNotIn ('targeted_var_1' , variation_ids )
2009- self .assertNotIn ('targeted_var_2' , variation_ids )
20101909
20111910
0 commit comments