File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
tests/integrations/unleash Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ class UnleashIntegration(Integration):
1919 _unleash_client = None # type: Optional[UnleashClient]
2020
2121 def __init__ (self , unleash_client ):
22- # type: (Optional[ UnleashClient] ) -> None
22+ # type: (UnleashClient) -> None
2323 self .__class__ ._unleash_client = unleash_client
2424
2525 @staticmethod
Original file line number Diff line number Diff line change @@ -254,6 +254,30 @@ async def runner():
254254 }
255255
256256
257+ def test_client_isolation (sentry_init , capture_events , uninstall_integration ):
258+ """
259+ If the integration is tracking a single client, evaluations from other clients should not be
260+ captured.
261+ """
262+ client = MockUnleashClient ()
263+ uninstall_integration (UnleashIntegration )
264+ sentry_init (integrations = [UnleashIntegration (client )]) # type: ignore
265+
266+ other_client = MockUnleashClient ()
267+
268+ other_client .is_enabled ("hello" )
269+ other_client .is_enabled ("world" )
270+ other_client .is_enabled ("other" )
271+ other_client .get_variant ("no_payload_feature" )
272+ other_client .get_variant ("json_feature" )
273+
274+ events = capture_events ()
275+ sentry_sdk .capture_exception (Exception ("something wrong!" ))
276+
277+ assert len (events ) == 1
278+ assert events [0 ]["contexts" ]["flags" ] == {"values" : []}
279+
280+
257281def test_wraps_original (sentry_init , uninstall_integration ):
258282 client = MockUnleashClient ()
259283 mock_is_enabled = mock .Mock (return_value = random () < 0.5 )
You can’t perform that action at this time.
0 commit comments