@@ -90,9 +90,8 @@ def test_ctor(self):
9090 creds = _make_credentials ()
9191 http = object ()
9292 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 )
93+ self .assertTrue (client ._credentials is creds )
94+ self .assertTrue (client ._http is http )
9695
9796 def test_ctor_use_gax_preset (self ):
9897 creds = _make_credentials ()
@@ -153,7 +152,9 @@ def test_sync_recognize_content_with_optional_params_no_gax(self):
153152 }
154153 credentials = _make_credentials ()
155154 client = self ._make_one (credentials = credentials , use_gax = False )
156- client ._connection = _Connection (RETURNED )
155+ speech_api = client .speech_api
156+ connection = _Connection (RETURNED )
157+ speech_api ._connection = connection
157158
158159 encoding = speech .Encoding .FLAC
159160
@@ -165,8 +166,8 @@ def test_sync_recognize_content_with_optional_params_no_gax(self):
165166 profanity_filter = True ,
166167 speech_context = self .HINTS )
167168
168- self .assertEqual (len (client . _connection ._requested ), 1 )
169- req = client . _connection ._requested [0 ]
169+ self .assertEqual (len (connection ._requested ), 1 )
170+ req = connection ._requested [0 ]
170171 self .assertEqual (len (req ), 3 )
171172 self .assertEqual (req ['data' ], REQUEST )
172173 self .assertEqual (req ['method' ], 'POST' )
@@ -199,7 +200,9 @@ def test_sync_recognize_source_uri_without_optional_params_no_gax(self):
199200 }
200201 credentials = _make_credentials ()
201202 client = self ._make_one (credentials = credentials , use_gax = False )
202- client ._connection = _Connection (RETURNED )
203+ speech_api = client .speech_api
204+ connection = _Connection (RETURNED )
205+ speech_api ._connection = connection
203206
204207 encoding = speech .Encoding .FLAC
205208
@@ -208,8 +211,8 @@ def test_sync_recognize_source_uri_without_optional_params_no_gax(self):
208211
209212 response = [i for i in sample .sync_recognize ()]
210213
211- self .assertEqual (len (client . _connection ._requested ), 1 )
212- req = client . _connection ._requested [0 ]
214+ self .assertEqual (len (connection ._requested ), 1 )
215+ req = connection ._requested [0 ]
213216 self .assertEqual (len (req ), 3 )
214217 self .assertEqual (req ['data' ], REQUEST )
215218 self .assertEqual (req ['method' ], 'POST' )
@@ -231,7 +234,8 @@ def test_sync_recognize_with_empty_results_no_gax(self):
231234
232235 credentials = _make_credentials ()
233236 client = self ._make_one (credentials = credentials , use_gax = False )
234- client ._connection = _Connection (SYNC_RECOGNIZE_EMPTY_RESPONSE )
237+ speech_api = client .speech_api
238+ speech_api ._connection = _Connection (SYNC_RECOGNIZE_EMPTY_RESPONSE )
235239
236240 sample = client .sample (source_uri = self .AUDIO_SOURCE_URI ,
237241 encoding = speech .Encoding .FLAC ,
@@ -248,8 +252,7 @@ def test_sync_recognize_with_empty_results_gax(self):
248252
249253 credentials = _make_credentials ()
250254 client = self ._make_one (credentials = credentials , use_gax = True )
251- client ._connection = _Connection ()
252- client ._connection .credentials = credentials
255+ client ._credentials = credentials
253256
254257 channel_args = []
255258 channel_obj = object ()
@@ -291,9 +294,7 @@ def test_sync_recognize_with_gax(self):
291294
292295 creds = _make_credentials ()
293296 client = self ._make_one (credentials = creds , use_gax = True )
294- client ._connection = _Connection ()
295- client ._connection .credentials = creds
296- client ._speech_api = None
297+ client ._credentials = creds
297298
298299 alternatives = [{
299300 'transcript' : 'testing 1 2 3' ,
@@ -352,8 +353,7 @@ def test_async_supported_encodings(self):
352353 from google .cloud import speech
353354
354355 credentials = _make_credentials ()
355- client = self ._make_one (credentials = credentials )
356- client ._connection = _Connection ({})
356+ client = self ._make_one (credentials = credentials , use_gax = True )
357357
358358 sample = client .sample (source_uri = self .AUDIO_SOURCE_URI ,
359359 encoding = speech .Encoding .FLAC ,
@@ -370,7 +370,8 @@ def test_async_recognize_no_gax(self):
370370
371371 credentials = _make_credentials ()
372372 client = self ._make_one (credentials = credentials , use_gax = False )
373- client ._connection = _Connection (RETURNED )
373+ speech_api = client .speech_api
374+ speech_api ._connection = _Connection (RETURNED )
374375
375376 sample = client .sample (source_uri = self .AUDIO_SOURCE_URI ,
376377 encoding = speech .Encoding .LINEAR16 ,
@@ -393,8 +394,7 @@ def test_async_recognize_with_gax(self):
393394 credentials = _make_credentials ()
394395 client = self ._make_one (credentials = credentials ,
395396 use_gax = True )
396- client ._connection = _Connection ()
397- client ._connection .credentials = credentials
397+ client ._credentials = credentials
398398
399399 channel_args = []
400400 channel_obj = object ()
@@ -434,7 +434,6 @@ def test_streaming_depends_on_gax(self):
434434
435435 credentials = _make_credentials ()
436436 client = self ._make_one (credentials = credentials , use_gax = False )
437- client .connection = _Connection ()
438437 sample = client .sample (content = self .AUDIO_CONTENT ,
439438 encoding = speech .Encoding .LINEAR16 ,
440439 sample_rate = self .SAMPLE_RATE )
@@ -453,8 +452,7 @@ def test_streaming_closed_stream(self):
453452 stream = BytesIO (b'Some audio data...' )
454453 credentials = _make_credentials ()
455454 client = self ._make_one (credentials = credentials )
456- client .connection = _Connection ()
457- client .connection .credentials = credentials
455+ client ._credentials = credentials
458456
459457 channel_args = []
460458 channel_obj = object ()
@@ -495,8 +493,7 @@ def test_stream_recognize_interim_results(self):
495493 stream = BytesIO (b'Some audio data...' )
496494 credentials = _make_credentials ()
497495 client = self ._make_one (credentials = credentials )
498- client .connection = _Connection ()
499- client .connection .credentials = credentials
496+ client ._credentials = credentials
500497
501498 alternatives = [{
502499 'transcript' : 'testing streaming 1 2 3' ,
@@ -576,8 +573,7 @@ def test_stream_recognize(self):
576573 stream = BytesIO (b'Some audio data...' )
577574 credentials = _make_credentials ()
578575 client = self ._make_one (credentials = credentials )
579- client .connection = _Connection ()
580- client .connection .credentials = credentials
576+ client ._credentials = credentials
581577
582578 alternatives = [{
583579 'transcript' : 'testing streaming 1 2 3' ,
@@ -633,8 +629,7 @@ def test_stream_recognize_no_results(self):
633629 stream = BytesIO (b'Some audio data...' )
634630 credentials = _make_credentials ()
635631 client = self ._make_one (credentials = credentials )
636- client .connection = _Connection ()
637- client .connection .credentials = credentials
632+ client ._credentials = credentials
638633
639634 responses = [_make_streaming_response ()]
640635
@@ -670,8 +665,7 @@ def test_speech_api_with_gax(self):
670665
671666 creds = _make_credentials ()
672667 client = self ._make_one (credentials = creds , use_gax = True )
673- client ._connection = _Connection ()
674- client ._connection .credentials = creds
668+ client ._credentials = creds
675669
676670 channel_args = []
677671 channel_obj = object ()
0 commit comments