Rename google/tts.py to google_translate/tts.py (#23090)

* Rename google/tts.py to google_translate/tts.py

* Move config migration before load config file

Migrate default config google tts to google_translate tts

* Revert change in process component config

* Fix tests
This commit is contained in:
Jason Hu authored and Paulus Schoutsen committed 2019-04-16 14:27:07 -07:00
1 parent ca524233ec
commit 308d1fbba0
13 files changed
+83 -24

No files matched your search

@@ -0,0 +1 @@
"""Tests for the Google Translate integration."""
@@ -47,7 +47,7 @@ class TestTTSGooglePlatform:
"""Test setup component."""
config = {
tts.DOMAIN: {
'platform': 'google',
'platform': 'google_translate',
}
}
@@ -65,14 +65,14 @@ class TestTTSGooglePlatform:
config = {
tts.DOMAIN: {
'platform': 'google',
'platform': 'google_translate',
}
}
with assert_setup_component(1, tts.DOMAIN):
setup_component(self.hass, tts.DOMAIN, config)
self.hass.services.call(tts.DOMAIN, 'google_say', {
self.hass.services.call(tts.DOMAIN, 'google_translate_say', {
tts.ATTR_MESSAGE: "90% of I person is on front of your door.",
})
self.hass.block_till_done()
@@ -93,7 +93,7 @@ class TestTTSGooglePlatform:
config = {
tts.DOMAIN: {
'platform': 'google',
'platform': 'google_translate',
'language': 'de',
}
}
@@ -101,7 +101,7 @@ class TestTTSGooglePlatform:
with assert_setup_component(1, tts.DOMAIN):
setup_component(self.hass, tts.DOMAIN, config)
self.hass.services.call(tts.DOMAIN, 'google_say', {
self.hass.services.call(tts.DOMAIN, 'google_translate_say', {
tts.ATTR_MESSAGE: "90% of I person is on front of your door.",
})
self.hass.block_till_done()
@@ -121,7 +121,8 @@ class TestTTSGooglePlatform:
config = {
tts.DOMAIN: {
'platform': 'google',
'platform': 'google_translate',
'service_name': 'google_say',
}
}
@@ -148,14 +149,14 @@ class TestTTSGooglePlatform:
config = {
tts.DOMAIN: {
'platform': 'google',
'platform': 'google_translate',
}
}
with assert_setup_component(1, tts.DOMAIN):
setup_component(self.hass, tts.DOMAIN, config)
self.hass.services.call(tts.DOMAIN, 'google_say', {
self.hass.services.call(tts.DOMAIN, 'google_translate_say', {
tts.ATTR_MESSAGE: "90% of I person is on front of your door.",
})
self.hass.block_till_done()
@@ -174,14 +175,14 @@ class TestTTSGooglePlatform:
config = {
tts.DOMAIN: {
'platform': 'google',
'platform': 'google_translate',
}
}
with assert_setup_component(1, tts.DOMAIN):
setup_component(self.hass, tts.DOMAIN, config)
self.hass.services.call(tts.DOMAIN, 'google_say', {
self.hass.services.call(tts.DOMAIN, 'google_translate_say', {
tts.ATTR_MESSAGE: "90% of I person is on front of your door.",
})
self.hass.block_till_done()
@@ -205,7 +206,8 @@ class TestTTSGooglePlatform:
config = {
tts.DOMAIN: {
'platform': 'google',
'platform': 'google_translate',
'service_name': 'google_say',
}
}
+7 -2
View File
@@ -315,7 +315,7 @@ class TestConfig(unittest.TestCase):
def test_process_config_upgrade(self):
"""Test update of version on upgrade."""
ha_version = '0.8.0'
ha_version = '0.92.0'
mock_open = mock.mock_open()
with mock.patch('homeassistant.config.open', mock_open, create=True):
@@ -342,10 +342,13 @@ class TestConfig(unittest.TestCase):
assert opened_file.write.call_count == 0
@mock.patch('homeassistant.config.find_config_file', mock.Mock())
def test_config_upgrade_no_file(self):
"""Test update of version on upgrade, with no version file."""
mock_open = mock.mock_open()
mock_open.side_effect = [FileNotFoundError(), mock.DEFAULT]
mock_open.side_effect = [FileNotFoundError(),
mock.DEFAULT,
mock.DEFAULT]
with mock.patch('homeassistant.config.open', mock_open, create=True):
opened_file = mock_open.return_value
# pylint: disable=no-member
@@ -355,6 +358,7 @@ class TestConfig(unittest.TestCase):
@mock.patch('homeassistant.config.shutil')
@mock.patch('homeassistant.config.os')
@mock.patch('homeassistant.config.find_config_file', mock.Mock())
def test_migrate_file_on_upgrade(self, mock_os, mock_shutil):
"""Test migrate of config files on upgrade."""
ha_version = '0.7.0'
@@ -381,6 +385,7 @@ class TestConfig(unittest.TestCase):
@mock.patch('homeassistant.config.shutil')
@mock.patch('homeassistant.config.os')
@mock.patch('homeassistant.config.find_config_file', mock.Mock())
def test_migrate_no_file_on_upgrade(self, mock_os, mock_shutil):
"""Test not migrating config files on upgrade."""
ha_version = '0.7.0'