mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-11-10 03:19:37 +00:00
Mark system as unhealthy on OSError Bad message errors (#4750)
* Bad message error marks system as unhealthy * Finish adding test cases for changes * Rename test file for uniqueness * bad_message to oserror_bad_message * Omit some checks and check for network mounts
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
"""Test Homeassistant module."""
|
||||
|
||||
import asyncio
|
||||
import errno
|
||||
from pathlib import Path
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
from pytest import LogCaptureFixture
|
||||
|
||||
from supervisor.const import CoreState
|
||||
from supervisor.coresys import CoreSys
|
||||
from supervisor.docker.interface import DockerInterface
|
||||
@@ -44,3 +47,23 @@ async def test_get_users_none(coresys: CoreSys, ha_ws_client: AsyncMock):
|
||||
assert [] == await coresys.homeassistant.get_users.__wrapped__(
|
||||
coresys.homeassistant
|
||||
)
|
||||
|
||||
|
||||
def test_write_pulse_error(coresys: CoreSys, caplog: 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()
|
||||
|
||||
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()
|
||||
|
||||
assert "can't write pulse/client.config" in caplog.text
|
||||
assert coresys.core.healthy is False
|
||||
|
||||
Reference in New Issue
Block a user