@@ -90,9 +90,8 @@ def test_ctor(self):
90
90
creds = _make_credentials ()
91
91
http = object ()
92
92
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 )
96
95
97
96
def test_ctor_use_gax_preset (self ):
98
97
creds = _make_credentials ()
@@ -153,7 +152,9 @@ def test_sync_recognize_content_with_optional_params_no_gax(self):
153
152
}
154
153
credentials = _make_credentials ()
155
154
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
157
158
158
159
encoding = speech .Encoding .FLAC
159
160
@@ -165,8 +166,8 @@ def test_sync_recognize_content_with_optional_params_no_gax(self):
165
166
profanity_filter = True ,
166
167
speech_context = self .HINTS )
167
168
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 ]
170
171
self .assertEqual (len (req ), 3 )
171
172
self .assertEqual (req ['data' ], REQUEST )
172
173
self .assertEqual (req ['method' ], 'POST' )
@@ -199,7 +200,9 @@ def test_sync_recognize_source_uri_without_optional_params_no_gax(self):
199
200
}
200
201
credentials = _make_credentials ()
201
202
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
203
206
204
207
encoding = speech .Encoding .FLAC
205
208
@@ -208,8 +211,8 @@ def test_sync_recognize_source_uri_without_optional_params_no_gax(self):
208
211
209
212
response = [i for i in sample .sync_recognize ()]
210
213
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 ]
213
216
self .assertEqual (len (req ), 3 )
214
217
self .assertEqual (req ['data' ], REQUEST )
215
218
self .assertEqual (req ['method' ], 'POST' )
@@ -231,7 +234,8 @@ def test_sync_recognize_with_empty_results_no_gax(self):
231
234
232
235
credentials = _make_credentials ()
233
236
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 )
235
239
236
240
sample = client .sample (source_uri = self .AUDIO_SOURCE_URI ,
237
241
encoding = speech .Encoding .FLAC ,
@@ -248,8 +252,7 @@ def test_sync_recognize_with_empty_results_gax(self):
248
252
249
253
credentials = _make_credentials ()
250
254
client = self ._make_one (credentials = credentials , use_gax = True )
251
- client ._connection = _Connection ()
252
- client ._connection .credentials = credentials
255
+ client ._credentials = credentials
253
256
254
257
channel_args = []
255
258
channel_obj = object ()
@@ -291,9 +294,7 @@ def test_sync_recognize_with_gax(self):
291
294
292
295
creds = _make_credentials ()
293
296
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
297
298
298
299
alternatives = [{
299
300
'transcript' : 'testing 1 2 3' ,
@@ -352,8 +353,7 @@ def test_async_supported_encodings(self):
352
353
from google .cloud import speech
353
354
354
355
credentials = _make_credentials ()
355
- client = self ._make_one (credentials = credentials )
356
- client ._connection = _Connection ({})
356
+ client = self ._make_one (credentials = credentials , use_gax = True )
357
357
358
358
sample = client .sample (source_uri = self .AUDIO_SOURCE_URI ,
359
359
encoding = speech .Encoding .FLAC ,
@@ -370,7 +370,8 @@ def test_async_recognize_no_gax(self):
370
370
371
371
credentials = _make_credentials ()
372
372
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 )
374
375
375
376
sample = client .sample (source_uri = self .AUDIO_SOURCE_URI ,
376
377
encoding = speech .Encoding .LINEAR16 ,
@@ -393,8 +394,7 @@ def test_async_recognize_with_gax(self):
393
394
credentials = _make_credentials ()
394
395
client = self ._make_one (credentials = credentials ,
395
396
use_gax = True )
396
- client ._connection = _Connection ()
397
- client ._connection .credentials = credentials
397
+ client ._credentials = credentials
398
398
399
399
channel_args = []
400
400
channel_obj = object ()
@@ -434,7 +434,6 @@ def test_streaming_depends_on_gax(self):
434
434
435
435
credentials = _make_credentials ()
436
436
client = self ._make_one (credentials = credentials , use_gax = False )
437
- client .connection = _Connection ()
438
437
sample = client .sample (content = self .AUDIO_CONTENT ,
439
438
encoding = speech .Encoding .LINEAR16 ,
440
439
sample_rate = self .SAMPLE_RATE )
@@ -453,8 +452,7 @@ def test_streaming_closed_stream(self):
453
452
stream = BytesIO (b'Some audio data...' )
454
453
credentials = _make_credentials ()
455
454
client = self ._make_one (credentials = credentials )
456
- client .connection = _Connection ()
457
- client .connection .credentials = credentials
455
+ client ._credentials = credentials
458
456
459
457
channel_args = []
460
458
channel_obj = object ()
@@ -495,8 +493,7 @@ def test_stream_recognize_interim_results(self):
495
493
stream = BytesIO (b'Some audio data...' )
496
494
credentials = _make_credentials ()
497
495
client = self ._make_one (credentials = credentials )
498
- client .connection = _Connection ()
499
- client .connection .credentials = credentials
496
+ client ._credentials = credentials
500
497
501
498
alternatives = [{
502
499
'transcript' : 'testing streaming 1 2 3' ,
@@ -576,8 +573,7 @@ def test_stream_recognize(self):
576
573
stream = BytesIO (b'Some audio data...' )
577
574
credentials = _make_credentials ()
578
575
client = self ._make_one (credentials = credentials )
579
- client .connection = _Connection ()
580
- client .connection .credentials = credentials
576
+ client ._credentials = credentials
581
577
582
578
alternatives = [{
583
579
'transcript' : 'testing streaming 1 2 3' ,
@@ -633,8 +629,7 @@ def test_stream_recognize_no_results(self):
633
629
stream = BytesIO (b'Some audio data...' )
634
630
credentials = _make_credentials ()
635
631
client = self ._make_one (credentials = credentials )
636
- client .connection = _Connection ()
637
- client .connection .credentials = credentials
632
+ client ._credentials = credentials
638
633
639
634
responses = [_make_streaming_response ()]
640
635
@@ -670,8 +665,7 @@ def test_speech_api_with_gax(self):
670
665
671
666
creds = _make_credentials ()
672
667
client = self ._make_one (credentials = creds , use_gax = True )
673
- client ._connection = _Connection ()
674
- client ._connection .credentials = creds
668
+ client ._credentials = creds
675
669
676
670
channel_args = []
677
671
channel_obj = object ()
0 commit comments