chore: enforce ruff lint and format standards across backend

This commit is contained in:
Jonas Miederer 2026-09-14 08:10:14 +02:00
parent a8e312a4f8
commit a6cc585dd0
39 changed files with 459 additions and 559 deletions

View file

@ -13,6 +13,7 @@ import os
import subprocess
import sys
import tempfile
import time
import urllib.request
from pathlib import Path
@ -58,9 +59,7 @@ def main() -> None:
tmp = Path(tempfile.mkdtemp(prefix="kirche-smoke-"))
flow_dir = Path("/tmp/smoke-e2e-flows")
flow_dir.mkdir(exist_ok=True)
(flow_dir / "seed.json").write_text(
(FIXTURES / "simple_rule.json").read_text()
)
(flow_dir / "seed.json").write_text((FIXTURES / "simple_rule.json").read_text())
# Migrate a throwaway SQLite schema to head before starting the API.
from alembic import command as alembic_command
from alembic.config import Config
@ -83,14 +82,26 @@ def main() -> None:
"CALLBACK_BASE_URL": f"http://127.0.0.1:{API_PORT}",
}
lfx = subprocess.Popen(
[str(VENV_BIN / "lfx"), "serve", "--host", "127.0.0.1",
"--port", str(LFX_PORT), "--flow-dir", str(flow_dir), str(flow_dir)],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, env=env,
[
str(VENV_BIN / "lfx"),
"serve",
"--host",
"127.0.0.1",
"--port",
str(LFX_PORT),
"--flow-dir",
str(flow_dir),
str(flow_dir),
],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
env=env,
)
uvicorn = subprocess.Popen(
[str(VENV_BIN / "uvicorn"), "app.main:app", "--host", "127.0.0.1",
"--port", str(API_PORT)],
cwd=str(BACKEND), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
[str(VENV_BIN / "uvicorn"), "app.main:app", "--host", "127.0.0.1", "--port", str(API_PORT)],
cwd=str(BACKEND),
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
env=env,
)
try:
@ -106,7 +117,8 @@ def main() -> None:
fx = json.loads((FIXTURES / "simple_rule.json").read_text())
s, ver = api(
"POST", f"/api/flows/{fid}/versions",
"POST",
f"/api/flows/{fid}/versions",
{"langflow_json": fx, "author": "smoke"},
)
check("create version", s == 201, f"v{ver.get('version_no')}")
@ -115,17 +127,25 @@ def main() -> None:
check("deploy", s == 200 and dep.get("lfx_flow_id"), json.dumps(dep)[:160])
s, run = api(
"POST", f"/api/flows/{fid}/run",
"POST",
f"/api/flows/{fid}/run",
{"input": {"betrag": 120000, "schwelle": 200000}},
)
check("run standard", s == 200 and run.get("status") == "completed",
json.dumps(run.get("output"))[:120])
check(
"run standard",
s == 200 and run.get("status") == "completed",
json.dumps(run.get("output"))[:120],
)
s, run2 = api(
"POST", f"/api/flows/{fid}/run",
"POST",
f"/api/flows/{fid}/run",
{"input": {"betrag": 999000, "schwelle": 200000}},
)
check("run sonderfall", s == 200 and "Sonderfall" in (run2.get("output") or {}).get("result", ""))
check(
"run sonderfall",
s == 200 and "Sonderfall" in (run2.get("output") or {}).get("result", ""),
)
s, tasks = api("GET", "/api/approvals")
check("approvals empty (no callback flow)", s == 200 and tasks == [])