test: fix runit missing-script fixture

This commit is contained in:
xavierk
2026-09-29 03:51:20 +05:30
parent 511905f519
commit 87c5dcdac6
+10 -2
View File
@@ -685,11 +685,19 @@ class TestEdgeCases:
def test_runit_collect_missing_script(self):
"""Runit collect exits when fenris-collect script not found."""
with patch("fenris.init_system.Path") as mock_path:
mock_path.return_value.exists.return_value = False
with patch("fenris.init_system.subprocess") as mock_sub, \
patch("fenris.init_system.Path") as mock_path:
missing = MagicMock()
missing.exists.return_value = False
# Fallback path is built via Path(...).parent... / "src" / ...
missing.parent = missing
missing.__truediv__.return_value = missing
mock_path.return_value = missing
mock_sub.run.return_value = MagicMock(returncode=1)
with pytest.raises(SystemExit) as exc_info:
_runit_collect()
assert exc_info.value.code == 1
mock_sub.run.assert_not_called()
def test_systemd_query_state_timeout(self):
"""Systemd query state handles subprocess timeout."""