@@ -285,3 +285,49 @@ def test_invalid_config_in_service(self):
285285 err_msg = "Config must be of type firebase_admin.dataconnect.ConnectorConfig"
286286 with pytest .raises (ValueError , match = err_msg ):
287287 self .service .get_client (None )
288+
289+
290+ class TestDataConnectServiceIntegration :
291+
292+ def setup_method (self ):
293+ self .cred = testutils .MockCredential ()
294+ self .app1 = firebase_admin .initialize_app (self .cred , name = "integ_app1" )
295+ self .app2 = firebase_admin .initialize_app (self .cred , name = "integ_app2" )
296+
297+ self .config1 = BASE_CONFIG
298+ self .config2 = dataconnect .ConnectorConfig (
299+ service_id = "service2" , location = "us-east4" , connector = "conn2"
300+ )
301+ self .config1_copy = dataconnect .ConnectorConfig (
302+ service_id = "starterproject" , location = "us-east4" , connector = "my_connector"
303+ )
304+
305+ def teardown_method (self , method ):
306+ del method
307+ testutils .cleanup_apps ()
308+
309+ def test_overall_client_retrieval_and_caching (self ):
310+ client1a = dataconnect .client (self .config1 , app = self .app1 )
311+ client1b = dataconnect .client (self .config1_copy , app = self .app1 )
312+ client2 = dataconnect .client (self .config2 , app = self .app1 )
313+
314+ assert isinstance (client1a , dataconnect .DataConnect )
315+ assert client1a .app is self .app1
316+ assert client1a .config is self .config1
317+
318+ # Same config
319+ assert client1b is client1a
320+
321+ # Different config
322+ assert isinstance (client2 , dataconnect .DataConnect )
323+ assert client2 .app is self .app1
324+ assert client2 .config is self .config2
325+ assert client2 is not client1a
326+
327+ # Different app
328+ client1_app2 = dataconnect .client (self .config1 , app = self .app2 )
329+
330+ assert isinstance (client1_app2 , dataconnect .DataConnect )
331+ assert client1_app2 .app is self .app2
332+ assert client1_app2 .config is self .config1
333+ assert client1_app2 is not client1a
0 commit comments