Mobile App: Support rendering multiple templates at once (#21851)
* Support rendering multiple templates at once * Only catch TemplateError and dont log the error
This commit is contained in:
1 parent
acc44aaf6c
commit
5ef602bc2e
5 files changed
+29
-26
No files matched your search
@@ -49,7 +49,9 @@ REGISTER_CLEARTEXT = {
|
||||
RENDER_TEMPLATE = {
|
||||
'type': 'render_template',
|
||||
'data': {
|
||||
'template': 'Hello world'
|
||||
'one': {
|
||||
'template': 'Hello world'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import pytest
|
||||
from homeassistant.components.mobile_app.const import CONF_SECRET
|
||||
from homeassistant.const import CONF_WEBHOOK_ID
|
||||
|
||||
from .const import REGISTER
|
||||
from .const import REGISTER, RENDER_TEMPLATE
|
||||
from . import authed_api_client # noqa: F401
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ async def test_registration(hass_client, authed_api_client): # noqa: F811
|
||||
key = key[:keylen]
|
||||
key = key.ljust(keylen, b'\0')
|
||||
|
||||
payload = json.dumps({'template': 'Hello world'}).encode("utf-8")
|
||||
payload = json.dumps(RENDER_TEMPLATE['data']).encode("utf-8")
|
||||
|
||||
data = SecretBox(key).encrypt(payload,
|
||||
encoder=Base64Encoder).decode("utf-8")
|
||||
@@ -62,7 +62,7 @@ async def test_registration(hass_client, authed_api_client): # noqa: F811
|
||||
encoder=Base64Encoder)
|
||||
decrypted_data = decrypted_data.decode("utf-8")
|
||||
|
||||
assert json.loads(decrypted_data) == {'rendered': 'Hello world'}
|
||||
assert json.loads(decrypted_data) == {'one': 'Hello world'}
|
||||
|
||||
|
||||
async def test_register_invalid_component(authed_api_client): # noqa: F811
|
||||
|
||||
@@ -24,7 +24,7 @@ async def test_webhook_handle_render_template(webhook_client): # noqa: F811
|
||||
assert resp.status == 200
|
||||
|
||||
json = await resp.json()
|
||||
assert json == {'rendered': 'Hello world'}
|
||||
assert json == {'one': 'Hello world'}
|
||||
|
||||
|
||||
async def test_webhook_handle_call_services(hass, webhook_client): # noqa: E501 F811
|
||||
@@ -123,7 +123,7 @@ async def test_webhook_handle_decryption(webhook_client): # noqa: F811
|
||||
key = key[:keylen]
|
||||
key = key.ljust(keylen, b'\0')
|
||||
|
||||
payload = json.dumps({'template': 'Hello world'}).encode("utf-8")
|
||||
payload = json.dumps(RENDER_TEMPLATE['data']).encode("utf-8")
|
||||
|
||||
data = SecretBox(key).encrypt(payload,
|
||||
encoder=Base64Encoder).decode("utf-8")
|
||||
@@ -148,7 +148,7 @@ async def test_webhook_handle_decryption(webhook_client): # noqa: F811
|
||||
encoder=Base64Encoder)
|
||||
decrypted_data = decrypted_data.decode("utf-8")
|
||||
|
||||
assert json.loads(decrypted_data) == {'rendered': 'Hello world'}
|
||||
assert json.loads(decrypted_data) == {'one': 'Hello world'}
|
||||
|
||||
|
||||
async def test_webhook_requires_encryption(webhook_client): # noqa: F811
|
||||
|
||||
Reference in new issue
Block a user