Skip to content

Commit ef9d7fc

Browse files
authored
Merge pull request #2647 from daspecster/fix-speech-async-connection
Expose connection property on _JSONSpeechAPI.
2 parents 0fdb9d2 + ed281fb commit ef9d7fc

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

packages/google-cloud-python-speech/google/cloud/speech/client.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,15 @@ def __init__(self, client):
230230
self._client = client
231231
self._connection = client.connection
232232

233+
@property
234+
def connection(self):
235+
"""Connection property.
236+
237+
:rtype: :class:`~google.cloud.core.connection.Connection`
238+
:returns: Instance of ``Connection``
239+
"""
240+
return self._connection
241+
233242
def async_recognize(self, sample, language_code=None,
234243
max_alternatives=None, profanity_filter=None,
235244
speech_context=None):

packages/google-cloud-python-speech/unit_tests/test_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,14 @@ def test_speech_api_with_gax(self):
294294
self.assertIsInstance(client.speech_api, GAPICSpeechAPI)
295295

296296
def test_speech_api_without_gax(self):
297+
from google.cloud.connection import Connection
297298
from google.cloud.speech.client import _JSONSpeechAPI
298299

299300
creds = _Credentials()
300301
client = self._makeOne(credentials=creds, use_gax=False)
301302
self.assertIsNone(client._speech_api)
302303
self.assertIsInstance(client.speech_api, _JSONSpeechAPI)
304+
self.assertIsInstance(client.speech_api.connection, Connection)
303305

304306
def test_speech_api_preset(self):
305307
creds = _Credentials()

0 commit comments

Comments
 (0)