Allow to specify TTS language in the service call. (#5047)

* Allow to specify TTS language in the service call.

* Allow to specify TTS language in the service call.

* Respect 79 char limit

* Fix "Too many blank lines"

* Fix "Too many blank lines"

* Fix "Too many blank lines"

* Change language to be optional parameter of *get_tts_audio

* Change language to be optional parameter of *get_tts_audio

* Respect 79 char limit

* Don't pass "None

* Use default of "None" for TTS language

* Use default of "None" for TTS language

* Don't pass "None"

* Change TTS cache key to be hash_lang_engine

* Change language from demo to en

* Fix wrong replace
This commit is contained in:
andrey-git authored and Pascal Vizeli committed 2016-12-27 17:01:22 +01:00
1 parent 68865ec27b
commit 4728fa8da6
8 files changed
+206 -38

No files matched your search

+30 -2
View File
@@ -80,8 +80,8 @@ class TestTTSGooglePlatform(object):
@patch('gtts_token.gtts_token.Token.calculate_token', autospec=True,
return_value=5)
def test_service_say_german(self, mock_calculate, aioclient_mock):
"""Test service call say with german code."""
def test_service_say_german_config(self, mock_calculate, aioclient_mock):
"""Test service call say with german code in the config."""
calls = mock_service(self.hass, DOMAIN_MP, SERVICE_PLAY_MEDIA)
self.url_param['tl'] = 'de'
@@ -106,6 +106,34 @@ class TestTTSGooglePlatform(object):
assert len(calls) == 1
assert len(aioclient_mock.mock_calls) == 1
@patch('gtts_token.gtts_token.Token.calculate_token', autospec=True,
return_value=5)
def test_service_say_german_service(self, mock_calculate, aioclient_mock):
"""Test service call say with german code in the service."""
calls = mock_service(self.hass, DOMAIN_MP, SERVICE_PLAY_MEDIA)
self.url_param['tl'] = 'de'
aioclient_mock.get(
self.url, params=self.url_param, status=200, content=b'test')
config = {
tts.DOMAIN: {
'platform': 'google',
}
}
with assert_setup_component(1, tts.DOMAIN):
setup_component(self.hass, tts.DOMAIN, config)
self.hass.services.call(tts.DOMAIN, 'google_say', {
tts.ATTR_MESSAGE: "I person is on front of your door.",
tts.ATTR_LANGUAGE: "de"
})
self.hass.block_till_done()
assert len(calls) == 1
assert len(aioclient_mock.mock_calls) == 1
@patch('gtts_token.gtts_token.Token.calculate_token', autospec=True,
return_value=5)
def test_service_say_error(self, mock_calculate, aioclient_mock):