@@ -2339,6 +2339,55 @@ def test_capture_is_called(self, patch_decide, patch_capture):
23392339 disable_geoip = None ,
23402340 )
23412341
2342+ @mock .patch ("posthog.client.decide" )
2343+ def test_capture_is_called_but_does_not_add_all_flags (self , patch_decide ):
2344+ patch_decide .return_value = {"featureFlags" : {"decide-flag" : "decide-value" }}
2345+ client = Client (FAKE_TEST_API_KEY , personal_api_key = FAKE_TEST_API_KEY )
2346+ client .feature_flags = [
2347+ {
2348+ "id" : 1 ,
2349+ "name" : "Beta Feature" ,
2350+ "key" : "complex-flag" ,
2351+ "active" : True ,
2352+ "filters" : {
2353+ "groups" : [
2354+ {
2355+ "properties" : [{"key" : "region" , "value" : "USA" }],
2356+ "rollout_percentage" : 100 ,
2357+ },
2358+ ],
2359+ },
2360+ },
2361+ {
2362+ "id" : 2 ,
2363+ "name" : "Gamma Feature" ,
2364+ "key" : "simple-flag" ,
2365+ "active" : True ,
2366+ "filters" : {
2367+ "groups" : [
2368+ {
2369+ "properties" : [],
2370+ "rollout_percentage" : 100 ,
2371+ },
2372+ ],
2373+ },
2374+ },
2375+ ]
2376+
2377+ self .assertTrue (
2378+ client .get_feature_flag ("complex-flag" , "some-distinct-id" , person_properties = {"region" : "USA" })
2379+ )
2380+
2381+ # Grab the capture message that was just added to the queue
2382+ msg = client .queue .get (block = False )
2383+ assert msg ["event" ] == "$feature_flag_called"
2384+ assert msg ["properties" ]["$feature_flag" ] == "complex-flag"
2385+ assert msg ["properties" ]["$feature_flag_response" ] is True
2386+ assert msg ["properties" ]["locally_evaluated" ] is True
2387+ assert msg ["properties" ]["$feature/complex-flag" ] is True
2388+ assert "$feature/simple-flag" not in msg ["properties" ]
2389+ assert "$active_feature_flags" not in msg ["properties" ]
2390+
23422391 @mock .patch .object (Client , "capture" )
23432392 @mock .patch ("posthog.client.decide" )
23442393 def test_capture_is_called_in_get_feature_flag_payload (self , patch_decide , patch_capture ):
0 commit comments