@@ -129,6 +129,7 @@ def test_sync_recognize_content_with_optional_params_no_gax(self):
129129
130130 from google .cloud import speech
131131 from google .cloud .speech .alternative import Alternative
132+ from google .cloud .speech .result import Result
132133 from unit_tests ._fixtures import SYNC_RECOGNIZE_RESPONSE
133134
134135 _B64_AUDIO_CONTENT = _bytes_to_unicode (b64encode (self .AUDIO_CONTENT ))
@@ -174,13 +175,16 @@ def test_sync_recognize_content_with_optional_params_no_gax(self):
174175 alternative = SYNC_RECOGNIZE_RESPONSE ['results' ][0 ]['alternatives' ][0 ]
175176 expected = Alternative .from_api_repr (alternative )
176177 self .assertEqual (len (response ), 1 )
177- self .assertIsInstance (response [0 ], Alternative )
178- self .assertEqual (response [0 ].transcript , expected .transcript )
179- self .assertEqual (response [0 ].confidence , expected .confidence )
178+ self .assertIsInstance (response [0 ], Result )
179+ self .assertEqual (len (response [0 ].alternatives ), 1 )
180+ alternative = response [0 ].alternatives [0 ]
181+ self .assertEqual (alternative .transcript , expected .transcript )
182+ self .assertEqual (alternative .confidence , expected .confidence )
180183
181184 def test_sync_recognize_source_uri_without_optional_params_no_gax (self ):
182185 from google .cloud import speech
183186 from google .cloud .speech .alternative import Alternative
187+ from google .cloud .speech .result import Result
184188 from unit_tests ._fixtures import SYNC_RECOGNIZE_RESPONSE
185189
186190 RETURNED = SYNC_RECOGNIZE_RESPONSE
@@ -214,9 +218,12 @@ def test_sync_recognize_source_uri_without_optional_params_no_gax(self):
214218 expected = Alternative .from_api_repr (
215219 SYNC_RECOGNIZE_RESPONSE ['results' ][0 ]['alternatives' ][0 ])
216220 self .assertEqual (len (response ), 1 )
217- self .assertIsInstance (response [0 ], Alternative )
218- self .assertEqual (response [0 ].transcript , expected .transcript )
219- self .assertEqual (response [0 ].confidence , expected .confidence )
221+ self .assertIsInstance (response [0 ], Result )
222+ self .assertEqual (len (response [0 ].alternatives ), 1 )
223+ alternative = response [0 ].alternatives [0 ]
224+
225+ self .assertEqual (alternative .transcript , expected .transcript )
226+ self .assertEqual (alternative .confidence , expected .confidence )
220227
221228 def test_sync_recognize_with_empty_results_no_gax (self ):
222229 from google .cloud import speech
@@ -710,19 +717,26 @@ class _MockGAPICSpeechAPI(object):
710717 _requests = None
711718 _response = None
712719 _results = None
720+
713721 SERVICE_ADDRESS = 'foo.apis.invalid'
714722
715723 def __init__ (self , response = None , channel = None ):
716724 self ._response = response
717725 self ._channel = channel
718726
719727 def async_recognize (self , config , audio ):
728+ from google .gapic .longrunning .operations_client import OperationsClient
729+ from google .gax import _OperationFuture
720730 from google .longrunning .operations_pb2 import Operation
731+ from google .cloud .proto .speech .v1beta1 .cloud_speech_pb2 import (
732+ AsyncRecognizeResponse )
721733
722734 self .config = config
723735 self .audio = audio
724- operation = Operation ()
725- return operation
736+ operations_client = mock .Mock (spec = OperationsClient )
737+ operation_future = _OperationFuture (Operation (), operations_client ,
738+ AsyncRecognizeResponse , {})
739+ return operation_future
726740
727741 def sync_recognize (self , config , audio ):
728742 self .config = config
0 commit comments