Add mqtt encoding support for publishing (#62739)

* encoding support for mqtt publishing - todo tests

* signature allows None values for qos and retain

* common test for mqtt publishing encoding

* better test with command templates

* more tests

* fix tests alarm control panel+tests light basic

* tests light json and template

* add tests vacuum and fix tests light_template
This commit is contained in:
Jan Bouwhuis 2022-01-03 09:03:47 +01:00 committed by GitHub
parent 2cc4d9846b
commit d0c4f0fec4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 1283 additions and 27 deletions

View file

@ -32,6 +32,7 @@ from .test_common import (
help_test_entity_device_info_with_identifier,
help_test_entity_id_update_discovery_update,
help_test_entity_id_update_subscriptions,
help_test_publishing_with_custom_encoding,
help_test_setting_attribute_via_mqtt_json_message,
help_test_setting_attribute_with_template,
help_test_setting_blocked_attribute_via_mqtt_json_message,
@ -467,3 +468,50 @@ async def test_entity_debug_info_message(hass, mqtt_mock):
await help_test_entity_debug_info_message(
hass, mqtt_mock, switch.DOMAIN, DEFAULT_CONFIG
)
@pytest.mark.parametrize(
"service,topic,parameters,payload,template",
[
(
switch.SERVICE_TURN_ON,
"command_topic",
None,
"ON",
None,
),
(
switch.SERVICE_TURN_OFF,
"command_topic",
None,
"OFF",
None,
),
],
)
async def test_publishing_with_custom_encoding(
hass,
mqtt_mock,
caplog,
service,
topic,
parameters,
payload,
template,
):
"""Test publishing MQTT payload with different encoding."""
domain = switch.DOMAIN
config = DEFAULT_CONFIG[domain]
await help_test_publishing_with_custom_encoding(
hass,
mqtt_mock,
caplog,
domain,
config,
service,
topic,
parameters,
payload,
template,
)