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:
Mike Degatano
2023-12-21 12:05:29 -05:00
committed by GitHub
parent b7ddfba71d
commit 3cc6bd19ad
24 changed files with 481 additions and 28 deletions

View File

@@ -1,4 +1,5 @@
"""Test audio plugin."""
import errno
from pathlib import Path
from unittest.mock import AsyncMock, Mock, patch
@@ -56,3 +57,26 @@ async def test_config_write(
"debug": True,
},
)
async def test_load_error(
coresys: CoreSys, caplog: pytest.LogCaptureFixture, container
):
"""Test error reading config file during load."""
with patch(
"supervisor.plugins.audio.Path.read_text", side_effect=(err := OSError())
), patch("supervisor.plugins.audio.shutil.copy", side_effect=err):
err.errno = errno.EBUSY
await coresys.plugins.audio.load()
assert "Can't read pulse-client.tmpl" in caplog.text
assert "Can't create default asound" in caplog.text
assert coresys.core.healthy is True
caplog.clear()
err.errno = errno.EBADMSG
await coresys.plugins.audio.load()
assert "Can't read pulse-client.tmpl" in caplog.text
assert "Can't create default asound" in caplog.text
assert coresys.core.healthy is False