mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Support reloading Tasmota config entries (#42097)
This commit is contained in:
@@ -27,40 +27,41 @@ async def test_valid_discovery_message(hass, mqtt_mock, caplog):
|
||||
config = copy.deepcopy(DEFAULT_CONFIG)
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.tasmota.discovery.tasmota_has_entities_with_platform"
|
||||
) as mock_tasmota_has_entities:
|
||||
"homeassistant.components.tasmota.discovery.tasmota_get_device_config",
|
||||
return_value={},
|
||||
) as mock_tasmota_get_device_config:
|
||||
await setup_tasmota_helper(hass)
|
||||
|
||||
async_fire_mqtt_message(
|
||||
hass, f"{DEFAULT_PREFIX}/00000049A3BC/config", json.dumps(config)
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert mock_tasmota_has_entities.called
|
||||
assert mock_tasmota_get_device_config.called
|
||||
|
||||
|
||||
async def test_invalid_topic(hass, mqtt_mock):
|
||||
"""Test receiving discovery message on wrong topic."""
|
||||
with patch(
|
||||
"homeassistant.components.tasmota.discovery.tasmota_has_entities_with_platform"
|
||||
) as mock_tasmota_has_entities:
|
||||
"homeassistant.components.tasmota.discovery.tasmota_get_device_config"
|
||||
) as mock_tasmota_get_device_config:
|
||||
await setup_tasmota_helper(hass)
|
||||
|
||||
async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/123456/configuration", "{}")
|
||||
await hass.async_block_till_done()
|
||||
assert not mock_tasmota_has_entities.called
|
||||
assert not mock_tasmota_get_device_config.called
|
||||
|
||||
|
||||
async def test_invalid_message(hass, mqtt_mock, caplog):
|
||||
"""Test receiving an invalid message."""
|
||||
with patch(
|
||||
"homeassistant.components.tasmota.discovery.tasmota_has_entities_with_platform"
|
||||
) as mock_tasmota_has_entities:
|
||||
"homeassistant.components.tasmota.discovery.tasmota_get_device_config"
|
||||
) as mock_tasmota_get_device_config:
|
||||
await setup_tasmota_helper(hass)
|
||||
|
||||
async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/123456/config", "asd")
|
||||
await hass.async_block_till_done()
|
||||
assert "Invalid discovery message" in caplog.text
|
||||
assert not mock_tasmota_has_entities.called
|
||||
assert not mock_tasmota_get_device_config.called
|
||||
|
||||
|
||||
async def test_invalid_mac(hass, mqtt_mock, caplog):
|
||||
@@ -68,8 +69,8 @@ async def test_invalid_mac(hass, mqtt_mock, caplog):
|
||||
config = copy.deepcopy(DEFAULT_CONFIG)
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.tasmota.discovery.tasmota_has_entities_with_platform"
|
||||
) as mock_tasmota_has_entities:
|
||||
"homeassistant.components.tasmota.discovery.tasmota_get_device_config"
|
||||
) as mock_tasmota_get_device_config:
|
||||
await setup_tasmota_helper(hass)
|
||||
|
||||
async_fire_mqtt_message(
|
||||
@@ -77,7 +78,7 @@ async def test_invalid_mac(hass, mqtt_mock, caplog):
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert "MAC mismatch" in caplog.text
|
||||
assert not mock_tasmota_has_entities.called
|
||||
assert not mock_tasmota_get_device_config.called
|
||||
|
||||
|
||||
async def test_correct_config_discovery(
|
||||
|
||||
Reference in New Issue
Block a user