mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
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:
@@ -33,6 +33,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,
|
||||
@@ -524,3 +525,37 @@ async def test_mqtt_payload_not_an_option_warning(hass, caplog, mqtt_mock):
|
||||
"Invalid option for select.test_select: 'öl' (valid options: ['milk', 'beer'])"
|
||||
in caplog.text
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"service,topic,parameters,payload,template",
|
||||
[
|
||||
(
|
||||
select.SERVICE_SELECT_OPTION,
|
||||
"command_topic",
|
||||
{"option": "beer"},
|
||||
"beer",
|
||||
"command_template",
|
||||
),
|
||||
],
|
||||
)
|
||||
async def test_publishing_with_custom_encoding(
|
||||
hass, mqtt_mock, caplog, service, topic, parameters, payload, template
|
||||
):
|
||||
"""Test publishing MQTT payload with different encoding."""
|
||||
domain = select.DOMAIN
|
||||
config = DEFAULT_CONFIG[domain]
|
||||
config["options"] = ["milk", "beer"]
|
||||
|
||||
await help_test_publishing_with_custom_encoding(
|
||||
hass,
|
||||
mqtt_mock,
|
||||
caplog,
|
||||
domain,
|
||||
config,
|
||||
service,
|
||||
topic,
|
||||
parameters,
|
||||
payload,
|
||||
template,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user