From dffa882332ad018f955a7a7f5ad3ea3badff81c0 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Fri, 28 Feb 2025 12:19:30 +0100 Subject: [PATCH] Make advanced logs error test work in all test environments When developing/testing in a Supervised environment, the systemd-journal-gatewayd socket is actually available. Mock the socket Path file to make the test independent of the pytest environment. --- tests/api/test_host.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/api/test_host.py b/tests/api/test_host.py index 385c0309555..c9a7985442c 100644 --- a/tests/api/test_host.py +++ b/tests/api/test_host.py @@ -358,11 +358,13 @@ async def test_advanced_logs_formatters( async def test_advanced_logs_errors(api_client: TestClient): """Test advanced logging API errors.""" # coresys = coresys_logs_control - resp = await api_client.get("/host/logs") - assert resp.content_type == "text/plain" - assert resp.status == 400 - content = await resp.text() - assert content == "No systemd-journal-gatewayd Unix socket available" + with patch("supervisor.host.logs.SYSTEMD_JOURNAL_GATEWAYD_SOCKET") as socket: + socket.is_socket.return_value = False + resp = await api_client.get("/host/logs") + assert resp.content_type == "text/plain" + assert resp.status == 400 + content = await resp.text() + assert content == "No systemd-journal-gatewayd Unix socket available" headers = {"Accept": "application/json"} resp = await api_client.get("/host/logs", headers=headers)