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
1 changed files with 17 additions and 0 deletions
|
@ -862,3 +862,20 @@ async def test_integration_reload(
|
|||
async_fire_time_changed(hass)
|
||||
await hass.async_block_till_done()
|
||||
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…
Add table
Add a link
Reference in a new issue