🚧 WIP
This commit is contained in:
@@ -224,6 +224,27 @@ def client(db_session, monkeypatch):
|
||||
# The PKI client-cert endpoint validates the dynsec client exists.
|
||||
monkeypatch.setattr(pki_router, "dynsec_client", fake)
|
||||
|
||||
# The control sidecar is not running in tests: fake its responses so
|
||||
# deploy/system endpoints can be exercised (broker_alive always true).
|
||||
from app.routers import broker as broker_router
|
||||
from app.routers import system as system_router
|
||||
|
||||
def _fake_call_control(path, *, method="POST", json_body=None):
|
||||
if path == "/deploy":
|
||||
return {
|
||||
"status": "deployed",
|
||||
"broker_healthy": True,
|
||||
"validation": {"valid": True},
|
||||
}
|
||||
if path == "/restart":
|
||||
return {"status": "restarting"}
|
||||
if path == "/status":
|
||||
return {"broker_pid_alive": True, "config_file": "/mosquitto/config/mosquitto.conf"}
|
||||
raise AssertionError(f"unexpected control path in tests: {path}")
|
||||
|
||||
monkeypatch.setattr(broker_router, "_call_control", _fake_call_control)
|
||||
monkeypatch.setattr(system_router, "_call_control", _fake_call_control)
|
||||
|
||||
with TestClient(main_module.app) as test_client:
|
||||
yield test_client
|
||||
|
||||
|
||||
Reference in New Issue
Block a user