mirror of
https://github.com/home-assistant/core.git
synced 2025-11-08 18:39:30 +00:00
Move MqttServiceInfo to init.py (#60905)
Co-authored-by: epenet <epenet@users.noreply.github.com> Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
@@ -1812,3 +1812,27 @@ async def test_publish_json_from_template(hass, mqtt_mock):
|
||||
|
||||
assert mqtt_mock.async_publish.called
|
||||
assert mqtt_mock.async_publish.call_args[0][1] == test_str
|
||||
|
||||
|
||||
async def test_service_info_compatibility(hass, caplog):
|
||||
"""Test compatibility with old-style dict.
|
||||
|
||||
To be removed in 2022.6
|
||||
"""
|
||||
discovery_info = mqtt.MqttServiceInfo(
|
||||
topic="tasmota/discovery/DC4F220848A2/config",
|
||||
payload="",
|
||||
qos=0,
|
||||
retain=False,
|
||||
subscribed_topic="tasmota/discovery/#",
|
||||
timestamp=None,
|
||||
)
|
||||
|
||||
# Ensure first call get logged
|
||||
assert discovery_info["topic"] == "tasmota/discovery/DC4F220848A2/config"
|
||||
assert "Detected code that accessed discovery_info['topic']" in caplog.text
|
||||
|
||||
# Ensure second call doesn't get logged
|
||||
caplog.clear()
|
||||
assert discovery_info["topic"] == "tasmota/discovery/DC4F220848A2/config"
|
||||
assert "Detected code that accessed discovery_info['topic']" not in caplog.text
|
||||
|
||||
Reference in New Issue
Block a user