sync: tests/test_app.py for Butler 2.3.1
This commit is contained in:
parent
4edd5502a2
commit
40feb169e7
1 changed files with 19 additions and 1 deletions
|
|
@ -42,7 +42,7 @@ def test_health_exposes_current_version():
|
||||||
with TestClient(app.app) as client:
|
with TestClient(app.app) as client:
|
||||||
response = client.get("/health")
|
response = client.get("/health")
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert response.json()["version"] == app.VERSION == "2.3.0"
|
assert response.json()["version"] == app.VERSION == "2.3.1"
|
||||||
|
|
||||||
|
|
||||||
def test_invalid_log_target_is_rejected_before_ssh():
|
def test_invalid_log_target_is_rejected_before_ssh():
|
||||||
|
|
@ -145,6 +145,24 @@ def test_backup_item_reports_age_and_severity():
|
||||||
assert app._backup_item(1, "", "timeout")["state"] == "unknown"
|
assert app._backup_item(1, "", "timeout")["state"] == "unknown"
|
||||||
|
|
||||||
|
|
||||||
|
def test_ssh_uses_writable_runtime_known_hosts(monkeypatch):
|
||||||
|
captured = {}
|
||||||
|
|
||||||
|
class Result:
|
||||||
|
returncode = 0
|
||||||
|
stdout = "ok"
|
||||||
|
stderr = ""
|
||||||
|
|
||||||
|
def fake_run(args, **_kwargs):
|
||||||
|
captured["args"] = args
|
||||||
|
return Result()
|
||||||
|
|
||||||
|
monkeypatch.setattr(app._sp, "run", fake_run)
|
||||||
|
assert app._ssh("sascha@example", "true", timeout=1)[0] == 0
|
||||||
|
joined = " ".join(captured["args"])
|
||||||
|
assert "UserKnownHostsFile=/tmp/butler_known_hosts" in joined
|
||||||
|
|
||||||
|
|
||||||
def test_ssh_timeout_is_normalized_instead_of_crashing_collection(monkeypatch):
|
def test_ssh_timeout_is_normalized_instead_of_crashing_collection(monkeypatch):
|
||||||
def timeout(*_args, **_kwargs):
|
def timeout(*_args, **_kwargs):
|
||||||
raise app._sp.TimeoutExpired(cmd=["ssh"], timeout=1)
|
raise app._sp.TimeoutExpired(cmd=["ssh"], timeout=1)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue