Improve mqtt test (#42490)

This commit is contained in:
Paulus Schoutsen 2020-10-27 23:22:59 +01:00 committed by GitHub
parent f0b676607d
commit d4efa938dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 3 deletions

View file

@ -1502,6 +1502,7 @@ async def test_debug_info_qos_retain(hass, mqtt_mock):
async def test_publish_json_from_template(hass, mqtt_mock):
"""Test the publishing of call to services."""
test_str = "{'valid': 'python', 'invalid': 'json'}"
test_str_tpl = "{'valid': '{{ \"python\" }}', 'invalid': 'json'}"
await async_setup_component(
hass,
@ -1511,13 +1512,16 @@ async def test_publish_json_from_template(hass, mqtt_mock):
"test_script_payload": {
"sequence": {
"service": "mqtt.publish",
"data": {"topic": "test-topic", "payload": test_str},
"data": {"topic": "test-topic", "payload": test_str_tpl},
}
},
"test_script_payload_template": {
"sequence": {
"service": "mqtt.publish",
"data": {"topic": "test-topic", "payload_template": test_str},
"data": {
"topic": "test-topic",
"payload_template": test_str_tpl,
},
}
},
}