@@ -63,6 +63,8 @@ def verify_flag_builder(desc: str, expected_props: dict, builder_actions: Callab
6363 pytest .param ({'variations' : ['a' , 'b' , 'c' ], 'fallthrough' : {'variation' : 2 }}, lambda f : f .variations ('a' , 'b' , 'c' ).variation_for_all (2 ), id = 'set variation index for all' ),
6464 pytest .param ({'offVariation' : 0 }, lambda f : f .off_variation (True ), id = 'set off variation boolean' ),
6565 pytest .param ({'variations' : ['a' , 'b' , 'c' ], 'offVariation' : 2 }, lambda f : f .variations ('a' , 'b' , 'c' ).off_variation (2 ), id = 'set off variation index' ),
66+ pytest .param ({'variations' : ['x' ], 'offVariation' : 0 }, lambda f : f .value_for_all ('x' ), id = 'value for all' ),
67+ pytest .param ({'on' : False , 'variations' : ['x' ], 'offVariation' : 0 }, lambda f : f .value_for_all ('x' ).on (False ), id = 'value for all with targeting off' ),
6668 pytest .param (
6769 {
6870 'targets' : [
@@ -280,6 +282,21 @@ def test_flag_evaluation_with_client():
280282 assert eval2 .reason ['kind' ] == 'FALLTHROUGH'
281283
282284
285+ def test_value_for_all_evaluates_to_value_when_targeting_is_off ():
286+ td = TestData .data_source ()
287+ store = InMemoryFeatureStore ()
288+
289+ client = LDClient (config = Config ('SDK_KEY' , update_processor_class = td , send_events = False , feature_store = store ))
290+
291+ td .update (td .flag (key = 'test-flag' ).value_for_all ('x' ).on (False ))
292+
293+ detail = client .variation_detail ('test-flag' , Context .create ('user1' ), default = 'default' )
294+
295+ assert detail .value == 'x'
296+ assert detail .variation_index == 0
297+ assert detail .reason ['kind' ] == 'OFF'
298+
299+
283300def test_flag_can_evaluate_all_flags ():
284301 td = TestData .data_source ()
285302 store = InMemoryFeatureStore ()
0 commit comments