mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 16:27:08 +00:00
Bring modbus back to 100% test coverage (#85972)
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
This commit is contained in:
parent
bcef0d66ac
commit
ee85a23d19
@ -862,3 +862,20 @@ async def test_integration_reload(
|
|||||||
async_fire_time_changed(hass)
|
async_fire_time_changed(hass)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert "Modbus reloading" in caplog.text
|
assert "Modbus reloading" in caplog.text
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("do_config", [{}])
|
||||||
|
async def test_integration_reload_failed(hass, caplog, mock_modbus) -> None:
|
||||||
|
"""Run test for integration connect failure on reload."""
|
||||||
|
caplog.set_level(logging.INFO)
|
||||||
|
caplog.clear()
|
||||||
|
|
||||||
|
yaml_path = get_fixture_path("configuration.yaml", "modbus")
|
||||||
|
with mock.patch.object(
|
||||||
|
hass_config, "YAML_CONFIG_FILE", yaml_path
|
||||||
|
), mock.patch.object(mock_modbus, "connect", side_effect=ModbusException("error")):
|
||||||
|
await hass.services.async_call(DOMAIN, SERVICE_RELOAD, blocking=True)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
assert "Modbus reloading" in caplog.text
|
||||||
|
assert "connect failed, retry in pymodbus" in caplog.text
|
||||||
|
Loading…
x
Reference in New Issue
Block a user