1 parent
ae9e3d83d7
commit
d1a621601d
42 files changed
+307
-473
No files matched your search
@@ -2,7 +2,6 @@
|
||||
import ctypes
|
||||
import os
|
||||
import shutil
|
||||
import json
|
||||
from unittest.mock import patch, PropertyMock
|
||||
|
||||
import pytest
|
||||
@@ -14,7 +13,7 @@ from homeassistant.components.tts.demo import DemoProvider
|
||||
from homeassistant.components.media_player import (
|
||||
SERVICE_PLAY_MEDIA, MEDIA_TYPE_MUSIC, ATTR_MEDIA_CONTENT_ID,
|
||||
ATTR_MEDIA_CONTENT_TYPE, DOMAIN as DOMAIN_MP)
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.setup import setup_component, async_setup_component
|
||||
|
||||
from tests.common import (
|
||||
get_test_home_assistant, get_test_instance_port, assert_setup_component,
|
||||
@@ -584,45 +583,45 @@ class TestTTS:
|
||||
assert req.status_code == 200
|
||||
assert req.content == demo_data
|
||||
|
||||
def test_setup_component_and_web_get_url(self):
|
||||
"""Set up the demo platform and receive wrong file from web."""
|
||||
config = {
|
||||
tts.DOMAIN: {
|
||||
'platform': 'demo',
|
||||
}
|
||||
|
||||
async def test_setup_component_and_web_get_url(hass, hass_client):
|
||||
"""Set up the demo platform and receive file from web."""
|
||||
config = {
|
||||
tts.DOMAIN: {
|
||||
'platform': 'demo',
|
||||
}
|
||||
}
|
||||
|
||||
with assert_setup_component(1, tts.DOMAIN):
|
||||
setup_component(self.hass, tts.DOMAIN, config)
|
||||
await async_setup_component(hass, tts.DOMAIN, config)
|
||||
|
||||
self.hass.start()
|
||||
client = await hass_client()
|
||||
|
||||
url = ("{}/api/tts_get_url").format(self.hass.config.api.base_url)
|
||||
data = {'platform': 'demo',
|
||||
'message': "I person is on front of your door."}
|
||||
url = "/api/tts_get_url"
|
||||
data = {'platform': 'demo',
|
||||
'message': "I person is on front of your door."}
|
||||
|
||||
req = requests.post(url, data=json.dumps(data))
|
||||
assert req.status_code == 200
|
||||
response = json.loads(req.text)
|
||||
assert response.get('url') == (("{}/api/tts_proxy/265944c108cbb00b2a62"
|
||||
"1be5930513e03a0bb2cd_en_-_demo.mp3")
|
||||
.format(self.hass.config.api.base_url))
|
||||
req = await client.post(url, json=data)
|
||||
assert req.status == 200
|
||||
response = await req.json()
|
||||
assert response.get('url') == \
|
||||
("{}/api/tts_proxy/265944c108cbb00b2a62"
|
||||
"1be5930513e03a0bb2cd_en_-_demo.mp3".format(hass.config.api.base_url))
|
||||
|
||||
def test_setup_component_and_web_get_url_bad_config(self):
|
||||
"""Set up the demo platform and receive wrong file from web."""
|
||||
config = {
|
||||
tts.DOMAIN: {
|
||||
'platform': 'demo',
|
||||
}
|
||||
|
||||
async def test_setup_component_and_web_get_url_bad_config(hass, hass_client):
|
||||
"""Set up the demo platform and receive wrong file from web."""
|
||||
config = {
|
||||
tts.DOMAIN: {
|
||||
'platform': 'demo',
|
||||
}
|
||||
}
|
||||
|
||||
with assert_setup_component(1, tts.DOMAIN):
|
||||
setup_component(self.hass, tts.DOMAIN, config)
|
||||
await async_setup_component(hass, tts.DOMAIN, config)
|
||||
|
||||
self.hass.start()
|
||||
client = await hass_client()
|
||||
|
||||
url = ("{}/api/tts_get_url").format(self.hass.config.api.base_url)
|
||||
data = {'message': "I person is on front of your door."}
|
||||
url = "/api/tts_get_url"
|
||||
data = {'message': "I person is on front of your door."}
|
||||
|
||||
req = requests.post(url, data=data)
|
||||
assert req.status_code == 400
|
||||
req = await client.post(url, json=data)
|
||||
assert req.status == 400
|
||||
Reference in new issue
Block a user