Finish migrating read_text to executor (#5698)

* Move read_text to executor

* switch to async_capture_exception

* Finish moving read_text to executor

* Cover read_bytes and some write_text calls as well

* Fix await issues

* Fix format_message
This commit is contained in:
Mike Degatano
2025-03-04 05:45:44 -05:00
committed by GitHub
parent c01d788c4c
commit 582b128ad9
15 changed files with 104 additions and 69 deletions

View File

@@ -66,21 +66,21 @@ async def test_get_users_none(coresys: CoreSys, ha_ws_client: AsyncMock):
)
def test_write_pulse_error(coresys: CoreSys, caplog: pytest.LogCaptureFixture):
async def test_write_pulse_error(coresys: CoreSys, caplog: pytest.LogCaptureFixture):
"""Test errors writing pulse config."""
with patch(
"supervisor.homeassistant.module.Path.write_text",
side_effect=(err := OSError()),
):
err.errno = errno.EBUSY
coresys.homeassistant.write_pulse()
await coresys.homeassistant.write_pulse()
assert "can't write pulse/client.config" in caplog.text
assert coresys.core.healthy is True
caplog.clear()
err.errno = errno.EBADMSG
coresys.homeassistant.write_pulse()
await coresys.homeassistant.write_pulse()
assert "can't write pulse/client.config" in caplog.text
assert coresys.core.healthy is False