@@ -50,39 +50,24 @@ def test_constructor(self, mocked_stub, mocked_cls, mocked_channel):
5050 from google .cloud .speech ._gax import OPERATIONS_API_HOST
5151
5252 credentials = _make_credentials ()
53- mock_cnxn = mock .Mock (
54- credentials = credentials ,
55- spec = ['credentials' ],
56- )
53+ mock_cnxn = mock .Mock (credentials = credentials , spec = ['credentials' ])
5754 mock_client = mock .Mock (
58- _connection = mock_cnxn ,
59- _credentials = credentials ,
60- spec = ['_connection' , '_credentials' ],
61- )
55+ _connection = mock_cnxn , _credentials = credentials ,
56+ spec = ['_connection' , '_credentials' ])
6257
6358 speech_api = self ._make_one (mock_client )
6459 self .assertIs (speech_api ._client , mock_client )
65- self .assertIs (
66- speech_api ._gapic_api ,
67- mocked_cls .return_value ,
68- )
60+ self .assertIs (speech_api ._gapic_api , mocked_cls .return_value )
6961
7062 mocked_stub .assert_called_once_with (
71- mock_cnxn .credentials ,
72- DEFAULT_USER_AGENT ,
73- operations_grpc .OperationsStub ,
74- OPERATIONS_API_HOST ,
75- )
63+ mock_cnxn .credentials , DEFAULT_USER_AGENT ,
64+ operations_grpc .OperationsStub , OPERATIONS_API_HOST )
7665 mocked_cls .assert_called_once_with (
77- channel = mock .sentinel .channel ,
78- lib_name = 'gccl' ,
79- lib_version = __version__ ,
80- )
66+ channel = mock .sentinel .channel , lib_name = 'gccl' ,
67+ lib_version = __version__ )
8168 mocked_channel .assert_called_once_with (
82- mock_cnxn .credentials ,
83- DEFAULT_USER_AGENT ,
84- mocked_cls .SERVICE_ADDRESS ,
85- )
69+ mock_cnxn .credentials , DEFAULT_USER_AGENT ,
70+ mocked_cls .SERVICE_ADDRESS )
8671
8772
8873class TestSpeechGAXMakeRequests (unittest .TestCase ):
@@ -95,13 +80,11 @@ def _call_fut(self, sample, language_code, max_alternatives,
9580 interim_results ):
9681 from google .cloud .speech ._gax import _make_streaming_request
9782
98- return _make_streaming_request (sample = sample ,
99- language_code = language_code ,
100- max_alternatives = max_alternatives ,
101- profanity_filter = profanity_filter ,
102- speech_context = speech_context ,
103- single_utterance = single_utterance ,
104- interim_results = interim_results )
83+ return _make_streaming_request (
84+ sample = sample , language_code = language_code ,
85+ max_alternatives = max_alternatives ,
86+ profanity_filter = profanity_filter , speech_context = speech_context ,
87+ single_utterance = single_utterance , interim_results = interim_results )
10588
10689 def test_ctor (self ):
10790 from google .cloud import speech
@@ -110,29 +93,28 @@ def test_ctor(self):
11093 RecognitionConfig , SpeechContext , StreamingRecognitionConfig ,
11194 StreamingRecognizeRequest )
11295
113- sample = Sample (content = self . AUDIO_CONTENT ,
114- encoding = speech .Encoding .FLAC ,
115- sample_rate = self .SAMPLE_RATE )
96+ sample = Sample (
97+ content = self . AUDIO_CONTENT , encoding = speech .Encoding .FLAC ,
98+ sample_rate = self .SAMPLE_RATE )
11699 language_code = 'US-en'
117100 max_alternatives = 2
118101 profanity_filter = True
119102 speech_context = SpeechContext (phrases = self .HINTS )
120103 single_utterance = True
121104 interim_results = False
122105
123- streaming_request = self ._call_fut (sample , language_code ,
124- max_alternatives , profanity_filter ,
125- speech_context , single_utterance ,
126- interim_results )
106+ streaming_request = self ._call_fut (
107+ sample , language_code , max_alternatives , profanity_filter ,
108+ speech_context , single_utterance , interim_results )
127109 self .assertIsInstance (streaming_request , StreamingRecognizeRequest )
128110
129111 # This isn't set by _make_streaming_request().
130112 # The first request can only have `streaming_config` set.
131113 # The following requests can only have `audio_content` set.
132114 self .assertEqual (streaming_request .audio_content , b'' )
133115
134- self .assertIsInstance (streaming_request . streaming_config ,
135- StreamingRecognitionConfig )
116+ self .assertIsInstance (
117+ streaming_request . streaming_config , StreamingRecognitionConfig )
136118 streaming_config = streaming_request .streaming_config
137119 self .assertTrue (streaming_config .single_utterance )
138120 self .assertFalse (streaming_config .interim_results )
@@ -156,13 +138,11 @@ def _call_fut(self, sample, language_code, max_alternatives,
156138 interim_results ):
157139 from google .cloud .speech ._gax import _stream_requests
158140
159- return _stream_requests (sample = sample ,
160- language_code = language_code ,
161- max_alternatives = max_alternatives ,
162- profanity_filter = profanity_filter ,
163- speech_context = speech_context ,
164- single_utterance = single_utterance ,
165- interim_results = interim_results )
141+ return _stream_requests (
142+ sample = sample , language_code = language_code ,
143+ max_alternatives = max_alternatives ,
144+ profanity_filter = profanity_filter , speech_context = speech_context ,
145+ single_utterance = single_utterance , interim_results = interim_results )
166146
167147 def test_stream_requests (self ):
168148 from io import BytesIO
@@ -171,19 +151,18 @@ def test_stream_requests(self):
171151 from google .cloud .proto .speech .v1beta1 .cloud_speech_pb2 import (
172152 StreamingRecognitionConfig , StreamingRecognizeRequest )
173153
174- sample = Sample (stream = BytesIO ( self . AUDIO_CONTENT ),
175- encoding = speech .Encoding .FLAC ,
176- sample_rate = self .SAMPLE_RATE )
154+ sample = Sample (
155+ stream = BytesIO ( self . AUDIO_CONTENT ), encoding = speech .Encoding .FLAC ,
156+ sample_rate = self .SAMPLE_RATE )
177157 language_code = 'US-en'
178158 max_alternatives = 2
179159 profanity_filter = True
180160 speech_context = self .HINTS
181161 single_utterance = True
182162 interim_results = False
183- streaming_requests = self ._call_fut (sample , language_code ,
184- max_alternatives , profanity_filter ,
185- speech_context , single_utterance ,
186- interim_results )
163+ streaming_requests = self ._call_fut (
164+ sample , language_code , max_alternatives , profanity_filter ,
165+ speech_context , single_utterance , interim_results )
187166 all_requests = []
188167 for streaming_request in streaming_requests :
189168 self .assertIsInstance (streaming_request , StreamingRecognizeRequest )
@@ -198,5 +177,5 @@ def test_stream_requests(self):
198177 # The following requests can only have `audio_content` set.
199178 self .assertEqual (config_request .audio_content , b'' )
200179 self .assertEqual (streaming_request .audio_content , self .AUDIO_CONTENT )
201- self .assertIsInstance (config_request . streaming_config ,
202- StreamingRecognitionConfig )
180+ self .assertIsInstance (
181+ config_request . streaming_config , StreamingRecognitionConfig )
0 commit comments