diff --git a/homeassistant/components/tts/__init__.py b/homeassistant/components/tts/__init__.py index d0faa60684f..32cbbaa265b 100644 --- a/homeassistant/components/tts/__init__.py +++ b/homeassistant/components/tts/__init__.py @@ -157,7 +157,8 @@ def async_setup(hass, config): hass.services.async_register( DOMAIN, SERVICE_CLEAR_CACHE, async_clear_cache_handle, - descriptions.get(SERVICE_CLEAR_CACHE), schema=SERVICE_CLEAR_CACHE) + descriptions.get(SERVICE_CLEAR_CACHE), + schema=SCHEMA_SERVICE_CLEAR_CACHE) return True @@ -170,9 +171,9 @@ class SpeechManager(object): self.hass = hass self.providers = {} - self.use_cache = True - self.cache_dir = None - self.time_memory = None + self.use_cache = DEFAULT_CACHE + self.cache_dir = DEFAULT_CACHE_DIR + self.time_memory = DEFAULT_TIME_MEMORY self.file_cache = {} self.mem_cache = {} @@ -229,7 +230,7 @@ class SpeechManager(object): """Remove files from filesystem.""" for _, filename in self.file_cache.items(): try: - os.remove(os.path.join(self.cache_dir), filename) + os.remove(os.path.join(self.cache_dir, filename)) except OSError: pass diff --git a/tests/components/tts/test_init.py b/tests/components/tts/test_init.py index fbdbddb8db5..fccd9d66bd7 100644 --- a/tests/components/tts/test_init.py +++ b/tests/components/tts/test_init.py @@ -88,35 +88,35 @@ class TestTTS(object): self.default_tts_cache, "265944c108cbb00b2a621be5930513e03a0bb2cd_demo.mp3")) - def test_setup_component_and_test_service_clear_cache(self): - """Setup the demo platform and call service clear cache.""" - calls = mock_service(self.hass, DOMAIN_MP, SERVICE_PLAY_MEDIA) + def test_setup_component_and_test_service_clear_cache(self): + """Setup the demo platform and call service clear cache.""" + calls = mock_service(self.hass, DOMAIN_MP, SERVICE_PLAY_MEDIA) - config = { - tts.DOMAIN: { - 'platform': 'demo', - } + config = { + tts.DOMAIN: { + 'platform': 'demo', } + } - with assert_setup_component(1, tts.DOMAIN): - setup_component(self.hass, tts.DOMAIN, config) + with assert_setup_component(1, tts.DOMAIN): + setup_component(self.hass, tts.DOMAIN, config) - self.hass.services.call(tts.DOMAIN, 'demo_say', { - tts.ATTR_MESSAGE: "I person is on front of your door.", - }) - self.hass.block_till_done() + self.hass.services.call(tts.DOMAIN, 'demo_say', { + tts.ATTR_MESSAGE: "I person is on front of your door.", + }) + self.hass.block_till_done() - assert len(calls) == 1 - assert os.path.isfile(os.path.join( - self.default_tts_cache, - "265944c108cbb00b2a621be5930513e03a0bb2cd_demo.mp3")) + assert len(calls) == 1 + assert os.path.isfile(os.path.join( + self.default_tts_cache, + "265944c108cbb00b2a621be5930513e03a0bb2cd_demo.mp3")) - self.hass.services.call(tts.DOMAIN, tts.SERVICE_CLEAR_CACHE, {}) - self.hass.block_till_done() + self.hass.services.call(tts.DOMAIN, tts.SERVICE_CLEAR_CACHE, {}) + self.hass.block_till_done() - assert not os.path.isfile(os.path.join( - self.default_tts_cache, - "265944c108cbb00b2a621be5930513e03a0bb2cd_demo.mp3")) + assert not os.path.isfile(os.path.join( + self.default_tts_cache, + "265944c108cbb00b2a621be5930513e03a0bb2cd_demo.mp3")) def test_setup_component_and_test_service_with_receive_voice(self): """Setup the demo platform and call service and receive voice."""