@@ -85,14 +85,11 @@ def _make_one(self, *args, **kw):
8585 return self ._get_target_class ()(* args , ** kw )
8686
8787 def test_ctor (self ):
88- from google .cloud .speech ._http import Connection
89-
9088 creds = _make_credentials ()
9189 http = object ()
9290 client = self ._make_one (credentials = creds , http = http )
93- self .assertIsInstance (client ._connection , Connection )
94- self .assertTrue (client ._connection .credentials is creds )
95- self .assertTrue (client ._connection .http is http )
91+ self .assertTrue (client ._credentials is creds )
92+ self .assertTrue (client ._http is http )
9693
9794 def test_ctor_use_gax_preset (self ):
9895 creds = _make_credentials ()
@@ -153,7 +150,9 @@ def test_sync_recognize_content_with_optional_params_no_gax(self):
153150 }
154151 credentials = _make_credentials ()
155152 client = self ._make_one (credentials = credentials , use_gax = False )
156- client ._connection = _Connection (RETURNED )
153+ speech_api = client .speech_api
154+ connection = _Connection (RETURNED )
155+ speech_api ._connection = connection
157156
158157 encoding = speech .Encoding .FLAC
159158
@@ -165,8 +164,8 @@ def test_sync_recognize_content_with_optional_params_no_gax(self):
165164 profanity_filter = True ,
166165 speech_context = self .HINTS )
167166
168- self .assertEqual (len (client . _connection ._requested ), 1 )
169- req = client . _connection ._requested [0 ]
167+ self .assertEqual (len (connection ._requested ), 1 )
168+ req = connection ._requested [0 ]
170169 self .assertEqual (len (req ), 3 )
171170 self .assertEqual (req ['data' ], REQUEST )
172171 self .assertEqual (req ['method' ], 'POST' )
@@ -199,7 +198,9 @@ def test_sync_recognize_source_uri_without_optional_params_no_gax(self):
199198 }
200199 credentials = _make_credentials ()
201200 client = self ._make_one (credentials = credentials , use_gax = False )
202- client ._connection = _Connection (RETURNED )
201+ speech_api = client .speech_api
202+ connection = _Connection (RETURNED )
203+ speech_api ._connection = connection
203204
204205 encoding = speech .Encoding .FLAC
205206
@@ -208,8 +209,8 @@ def test_sync_recognize_source_uri_without_optional_params_no_gax(self):
208209
209210 response = [i for i in sample .sync_recognize ()]
210211
211- self .assertEqual (len (client . _connection ._requested ), 1 )
212- req = client . _connection ._requested [0 ]
212+ self .assertEqual (len (connection ._requested ), 1 )
213+ req = connection ._requested [0 ]
213214 self .assertEqual (len (req ), 3 )
214215 self .assertEqual (req ['data' ], REQUEST )
215216 self .assertEqual (req ['method' ], 'POST' )
@@ -231,7 +232,8 @@ def test_sync_recognize_with_empty_results_no_gax(self):
231232
232233 credentials = _make_credentials ()
233234 client = self ._make_one (credentials = credentials , use_gax = False )
234- client ._connection = _Connection (SYNC_RECOGNIZE_EMPTY_RESPONSE )
235+ speech_api = client .speech_api
236+ speech_api ._connection = _Connection (SYNC_RECOGNIZE_EMPTY_RESPONSE )
235237
236238 sample = client .sample (source_uri = self .AUDIO_SOURCE_URI ,
237239 encoding = speech .Encoding .FLAC ,
@@ -248,8 +250,7 @@ def test_sync_recognize_with_empty_results_gax(self):
248250
249251 credentials = _make_credentials ()
250252 client = self ._make_one (credentials = credentials , use_gax = True )
251- client ._connection = _Connection ()
252- client ._connection .credentials = credentials
253+ client ._credentials = credentials
253254
254255 channel_args = []
255256 channel_obj = object ()
@@ -291,9 +292,7 @@ def test_sync_recognize_with_gax(self):
291292
292293 creds = _make_credentials ()
293294 client = self ._make_one (credentials = creds , use_gax = True )
294- client ._connection = _Connection ()
295- client ._connection .credentials = creds
296- client ._speech_api = None
295+ client ._credentials = creds
297296
298297 alternatives = [{
299298 'transcript' : 'testing 1 2 3' ,
@@ -352,8 +351,7 @@ def test_async_supported_encodings(self):
352351 from google .cloud import speech
353352
354353 credentials = _make_credentials ()
355- client = self ._make_one (credentials = credentials )
356- client ._connection = _Connection ({})
354+ client = self ._make_one (credentials = credentials , use_gax = True )
357355
358356 sample = client .sample (source_uri = self .AUDIO_SOURCE_URI ,
359357 encoding = speech .Encoding .FLAC ,
@@ -370,7 +368,8 @@ def test_async_recognize_no_gax(self):
370368
371369 credentials = _make_credentials ()
372370 client = self ._make_one (credentials = credentials , use_gax = False )
373- client ._connection = _Connection (RETURNED )
371+ speech_api = client .speech_api
372+ speech_api ._connection = _Connection (RETURNED )
374373
375374 sample = client .sample (source_uri = self .AUDIO_SOURCE_URI ,
376375 encoding = speech .Encoding .LINEAR16 ,
@@ -393,8 +392,7 @@ def test_async_recognize_with_gax(self):
393392 credentials = _make_credentials ()
394393 client = self ._make_one (credentials = credentials ,
395394 use_gax = True )
396- client ._connection = _Connection ()
397- client ._connection .credentials = credentials
395+ client ._credentials = credentials
398396
399397 channel_args = []
400398 channel_obj = object ()
@@ -434,7 +432,6 @@ def test_streaming_depends_on_gax(self):
434432
435433 credentials = _make_credentials ()
436434 client = self ._make_one (credentials = credentials , use_gax = False )
437- client .connection = _Connection ()
438435 sample = client .sample (content = self .AUDIO_CONTENT ,
439436 encoding = speech .Encoding .LINEAR16 ,
440437 sample_rate = self .SAMPLE_RATE )
@@ -453,8 +450,7 @@ def test_streaming_closed_stream(self):
453450 stream = BytesIO (b'Some audio data...' )
454451 credentials = _make_credentials ()
455452 client = self ._make_one (credentials = credentials )
456- client .connection = _Connection ()
457- client .connection .credentials = credentials
453+ client ._credentials = credentials
458454
459455 channel_args = []
460456 channel_obj = object ()
@@ -495,8 +491,7 @@ def test_stream_recognize_interim_results(self):
495491 stream = BytesIO (b'Some audio data...' )
496492 credentials = _make_credentials ()
497493 client = self ._make_one (credentials = credentials )
498- client .connection = _Connection ()
499- client .connection .credentials = credentials
494+ client ._credentials = credentials
500495
501496 alternatives = [{
502497 'transcript' : 'testing streaming 1 2 3' ,
@@ -576,8 +571,7 @@ def test_stream_recognize(self):
576571 stream = BytesIO (b'Some audio data...' )
577572 credentials = _make_credentials ()
578573 client = self ._make_one (credentials = credentials )
579- client .connection = _Connection ()
580- client .connection .credentials = credentials
574+ client ._credentials = credentials
581575
582576 alternatives = [{
583577 'transcript' : 'testing streaming 1 2 3' ,
@@ -633,8 +627,7 @@ def test_stream_recognize_no_results(self):
633627 stream = BytesIO (b'Some audio data...' )
634628 credentials = _make_credentials ()
635629 client = self ._make_one (credentials = credentials )
636- client .connection = _Connection ()
637- client .connection .credentials = credentials
630+ client ._credentials = credentials
638631
639632 responses = [_make_streaming_response ()]
640633
@@ -670,8 +663,7 @@ def test_speech_api_with_gax(self):
670663
671664 creds = _make_credentials ()
672665 client = self ._make_one (credentials = creds , use_gax = True )
673- client ._connection = _Connection ()
674- client ._connection .credentials = creds
666+ client ._credentials = creds
675667
676668 channel_args = []
677669 channel_obj = object ()
0 commit comments