44import ldclient
55
66import sentry_sdk
7- import pytest
87
9- from ldclient import LDClient
108from ldclient .config import Config
119from ldclient .context import Context
1210from ldclient .integrations .test_data import TestData
1311
14- from sentry_sdk .integrations import DidNotEnable
1512from sentry_sdk .integrations .launchdarkly import LaunchDarklyIntegration
1613
1714
18- @pytest .mark .parametrize (
19- "use_global_client" ,
20- (False , True ),
21- )
22- def test_launchdarkly_integration (sentry_init , use_global_client ):
15+ def test_launchdarkly_integration (sentry_init ):
2316 td = TestData .data_source ()
2417 config = Config ("sdk-key" , update_processor_class = td )
25- if use_global_client :
26- ldclient .set_config (config )
27- sentry_init (integrations = [LaunchDarklyIntegration ()])
28- client = ldclient .get ()
29- else :
30- client = LDClient (config = config )
31- sentry_init (integrations = [LaunchDarklyIntegration (ld_client = client )])
18+ ldclient .set_config (config )
19+ client = ldclient .get ()
20+ sentry_init (integrations = [LaunchDarklyIntegration ()])
3221
3322 # Set test values
3423 td .update (td .flag ("hello" ).variation_for_all (True ))
@@ -48,8 +37,8 @@ def test_launchdarkly_integration(sentry_init, use_global_client):
4837
4938def test_launchdarkly_integration_threaded (sentry_init ):
5039 td = TestData .data_source ()
51- client = LDClient ( config = Config ( "sdk-key" , update_processor_class = td ) )
52- sentry_init (integrations = [LaunchDarklyIntegration (ld_client = client )])
40+ client = ldclient . get ( )
41+ sentry_init (integrations = [LaunchDarklyIntegration ()])
5342 context = Context .create ("user1" )
5443
5544 def task (flag_key ):
@@ -74,8 +63,8 @@ def task(flag_key):
7463def test_launchdarkly_integration_asyncio (sentry_init ):
7564 """Assert concurrently evaluated flags do not pollute one another."""
7665 td = TestData .data_source ()
77- client = LDClient ( config = Config ( "sdk-key" , update_processor_class = td ) )
78- sentry_init (integrations = [LaunchDarklyIntegration (ld_client = client )])
66+ client = ldclient . get ( )
67+ sentry_init (integrations = [LaunchDarklyIntegration ()])
7968 context = Context .create ("user1" )
8069
8170 async def task (flag_key ):
@@ -93,24 +82,3 @@ async def runner():
9382 results = asyncio .run (runner ()).result ()
9483 assert results [0 ] == ["hello" , "world" ]
9584 assert results [1 ] == ["hello" , "other" ]
96-
97-
98- def test_launchdarkly_integration_did_not_enable (monkeypatch ):
99- # Client is not passed in and set_config wasn't called.
100- # TODO: Bad practice to access internals like this. We can skip this test, or remove this
101- # case entirely (force user to pass in a client instance).
102- ldclient ._reset_client ()
103- try :
104- ldclient .__lock .lock ()
105- ldclient .__config = None
106- finally :
107- ldclient .__lock .unlock ()
108-
109- with pytest .raises (DidNotEnable ):
110- LaunchDarklyIntegration ()
111-
112- # Client not initialized.
113- client = LDClient (config = Config ("sdk-key" ))
114- monkeypatch .setattr (client , "is_initialized" , lambda : False )
115- with pytest .raises (DidNotEnable ):
116- LaunchDarklyIntegration (ld_client = client )
0 commit comments