mirror of
https://github.com/home-assistant/core.git
synced 2025-06-25 09:31:51 +02:00
Improve bootstrap file logging test (#146670)
This commit is contained in:
@ -85,6 +85,17 @@ async def test_async_enable_logging(
|
|||||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test to ensure logging is migrated to the queue handlers."""
|
"""Test to ensure logging is migrated to the queue handlers."""
|
||||||
|
config_log_file_pattern = get_test_config_dir("home-assistant.log*")
|
||||||
|
arg_log_file_pattern = "test.log*"
|
||||||
|
|
||||||
|
# Ensure we start with a clean slate
|
||||||
|
for f in glob.glob(arg_log_file_pattern):
|
||||||
|
os.remove(f)
|
||||||
|
for f in glob.glob(config_log_file_pattern):
|
||||||
|
os.remove(f)
|
||||||
|
assert len(glob.glob(config_log_file_pattern)) == 0
|
||||||
|
assert len(glob.glob(arg_log_file_pattern)) == 0
|
||||||
|
|
||||||
with (
|
with (
|
||||||
patch("logging.getLogger"),
|
patch("logging.getLogger"),
|
||||||
patch(
|
patch(
|
||||||
@ -97,6 +108,8 @@ async def test_async_enable_logging(
|
|||||||
):
|
):
|
||||||
await bootstrap.async_enable_logging(hass)
|
await bootstrap.async_enable_logging(hass)
|
||||||
mock_async_activate_log_queue_handler.assert_called_once()
|
mock_async_activate_log_queue_handler.assert_called_once()
|
||||||
|
assert len(glob.glob(config_log_file_pattern)) > 0
|
||||||
|
|
||||||
mock_async_activate_log_queue_handler.reset_mock()
|
mock_async_activate_log_queue_handler.reset_mock()
|
||||||
await bootstrap.async_enable_logging(
|
await bootstrap.async_enable_logging(
|
||||||
hass,
|
hass,
|
||||||
@ -104,13 +117,15 @@ async def test_async_enable_logging(
|
|||||||
log_file="test.log",
|
log_file="test.log",
|
||||||
)
|
)
|
||||||
mock_async_activate_log_queue_handler.assert_called_once()
|
mock_async_activate_log_queue_handler.assert_called_once()
|
||||||
for f in glob.glob("test.log*"):
|
assert len(glob.glob(arg_log_file_pattern)) > 0
|
||||||
os.remove(f)
|
|
||||||
for f in glob.glob("testing_config/home-assistant.log*"):
|
|
||||||
os.remove(f)
|
|
||||||
|
|
||||||
assert "Error rolling over log file" in caplog.text
|
assert "Error rolling over log file" in caplog.text
|
||||||
|
|
||||||
|
for f in glob.glob(arg_log_file_pattern):
|
||||||
|
os.remove(f)
|
||||||
|
for f in glob.glob(config_log_file_pattern):
|
||||||
|
os.remove(f)
|
||||||
|
|
||||||
|
|
||||||
async def test_load_hassio(hass: HomeAssistant) -> None:
|
async def test_load_hassio(hass: HomeAssistant) -> None:
|
||||||
"""Test that we load the hassio integration when using Supervisor."""
|
"""Test that we load the hassio integration when using Supervisor."""
|
||||||
|
Reference in New Issue
Block a user