kin: auto-commit after pipeline
This commit is contained in:
parent
17d7806838
commit
eab9e951ab
12 changed files with 1696 additions and 5 deletions
|
|
@ -2199,3 +2199,69 @@ def test_patch_project_test_command_null_returns_400(client):
|
|||
r = client.patch("/api/projects/p1", json={"test_command": None})
|
||||
assert r.status_code == 400
|
||||
assert "Nothing to update" in r.json()["detail"]
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# KIN-084: GET /api/pipelines/{pipeline_id}/logs
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def _seed_pipeline(db_path, project_id="p1", task_id="P1-001") -> int:
|
||||
"""Создаёт pipeline в БД и возвращает его id."""
|
||||
from core.db import init_db
|
||||
from core import models
|
||||
conn = init_db(db_path)
|
||||
pipe = models.create_pipeline(conn, task_id, project_id, "feature", [{"role": "dev"}])
|
||||
conn.close()
|
||||
return pipe["id"]
|
||||
|
||||
|
||||
def test_get_pipeline_logs_returns_200_empty(client):
|
||||
"""KIN-084: GET /api/pipelines/{id}/logs → 200 с пустым списком если логов нет."""
|
||||
pid = _seed_pipeline(api_module.DB_PATH)
|
||||
r = client.get(f"/api/pipelines/{pid}/logs")
|
||||
assert r.status_code == 200
|
||||
assert r.json() == []
|
||||
|
||||
|
||||
def test_get_pipeline_logs_returns_entries(client):
|
||||
"""KIN-084: GET /api/pipelines/{id}/logs → список записей с нужными полями."""
|
||||
from core.db import init_db
|
||||
from core import models
|
||||
pid = _seed_pipeline(api_module.DB_PATH)
|
||||
conn = init_db(api_module.DB_PATH)
|
||||
models.write_log(conn, pid, "Pipeline started", extra={"steps_count": 3})
|
||||
models.write_log(conn, pid, "Step 1 done")
|
||||
conn.close()
|
||||
|
||||
r = client.get(f"/api/pipelines/{pid}/logs")
|
||||
assert r.status_code == 200
|
||||
logs = r.json()
|
||||
assert len(logs) == 2
|
||||
assert logs[0]["message"] == "Pipeline started"
|
||||
assert isinstance(logs[0]["extra_json"], dict)
|
||||
assert logs[0]["extra_json"]["steps_count"] == 3
|
||||
assert logs[1]["message"] == "Step 1 done"
|
||||
|
||||
|
||||
def test_get_pipeline_logs_since_id_filters(client):
|
||||
"""KIN-084: ?since_id=N возвращает только id > N."""
|
||||
from core.db import init_db
|
||||
from core import models
|
||||
pid = _seed_pipeline(api_module.DB_PATH, task_id="P1-001")
|
||||
conn = init_db(api_module.DB_PATH)
|
||||
e1 = models.write_log(conn, pid, "Entry 1")
|
||||
models.write_log(conn, pid, "Entry 2")
|
||||
models.write_log(conn, pid, "Entry 3")
|
||||
conn.close()
|
||||
|
||||
r = client.get(f"/api/pipelines/{pid}/logs?since_id={e1['id']}")
|
||||
assert r.status_code == 200
|
||||
logs = r.json()
|
||||
assert len(logs) == 2
|
||||
assert all(log["id"] > e1["id"] for log in logs)
|
||||
|
||||
|
||||
def test_get_pipeline_logs_not_found(client):
|
||||
"""KIN-084: GET /api/pipelines/9999/logs → 404."""
|
||||
r = client.get("/api/pipelines/9999/logs")
|
||||
assert r.status_code == 404
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue