Don't fail on systemd disable failure

This commit is contained in:
Kivi Kaitaniemi
2026-01-07 00:03:57 +02:00
parent a5ec25693e
commit 8ca2ca8a06
2 changed files with 13 additions and 68 deletions
@@ -220,20 +220,6 @@ def test_enable_units_success(monkeypatch, store, systemd):
assert store["systemd_units"] == {"old.service", "new.service"}
def test_enable_units_failure_does_not_update_store(monkeypatch, store, systemd):
store["systemd_units"] = {"old.service"}
def fake_run(cmd, **kwargs):
return 1, "error"
monkeypatch.setattr(systemd_mod.command, "run", fake_run)
with pytest.raises(systemd_mod.errors.CommandFailedError):
systemd.enable_units(store, {"new.service"})
# unchanged
assert store["systemd_units"] == {"old.service"}
def test_disable_units_success(monkeypatch, store, systemd):
store["systemd_units"] = {"old.service", "new.service"}
@@ -249,19 +235,6 @@ def test_disable_units_success(monkeypatch, store, systemd):
assert store["systemd_units"] == {"old.service"}
def test_disable_units_failure_does_not_update_store(monkeypatch, store, systemd):
store["systemd_units"] = {"old.service", "new.service"}
def fake_run(cmd, **kwargs):
return 1, "error"
monkeypatch.setattr(systemd_mod.command, "run", fake_run)
with pytest.raises(systemd_mod.errors.CommandFailedError):
systemd.disable_units(store, {"new.service"})
assert store["systemd_units"] == {"old.service", "new.service"}
def test_enable_user_units_success(monkeypatch, store, systemd):
store["systemd_user_units"] = {"alice": {"olduser.service"}}
@@ -281,19 +254,6 @@ def test_enable_user_units_success(monkeypatch, store, systemd):
}
def test_enable_user_units_failure_does_not_update_store(monkeypatch, store, systemd):
store["systemd_user_units"] = {"alice": {"olduser.service"}}
def fake_run(cmd, **kwargs):
return 1, "error"
monkeypatch.setattr(systemd_mod.command, "run", fake_run)
with pytest.raises(systemd_mod.errors.CommandFailedError):
systemd.enable_user_units(store, {"newuser.service"}, "alice")
assert store["systemd_user_units"]["alice"] == {"olduser.service"}
def test_disable_user_units_success(monkeypatch, store, systemd):
store["systemd_user_units"] = {"alice": {"olduser.service", "newuser.service"}}
@@ -310,23 +270,6 @@ def test_disable_user_units_success(monkeypatch, store, systemd):
assert store["systemd_user_units"]["alice"] == {"olduser.service"}
def test_disable_user_units_failure_does_not_update_store(monkeypatch, store, systemd):
store["systemd_user_units"] = {"alice": {"olduser.service", "newuser.service"}}
def fake_run(cmd, **kwargs):
return 1, "error"
monkeypatch.setattr(systemd_mod.command, "run", fake_run)
with pytest.raises(systemd_mod.errors.CommandFailedError):
systemd.disable_user_units(store, {"newuser.service"}, "alice")
assert store["systemd_user_units"]["alice"] == {
"olduser.service",
"newuser.service",
}
def test_reload_daemon_uses_command_run(monkeypatch, systemd):
called = {}