kin: auto-commit after pipeline
This commit is contained in:
parent
17d7806838
commit
eab9e951ab
12 changed files with 1696 additions and 5 deletions
|
|
@ -757,3 +757,76 @@ def test_test_command_can_be_set(conn):
|
|||
models.create_project(conn, "prj_tc2", "TC Project 2", "/tmp/tc2")
|
||||
updated = models.update_project(conn, "prj_tc2", test_command="pytest -v --tb=short")
|
||||
assert updated["test_command"] == "pytest -v --tb=short"
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# KIN-084: write_log() и get_pipeline_logs()
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@pytest.fixture
|
||||
def pipeline_conn(conn):
|
||||
"""Возвращает (conn, pipeline_id) для тестов write_log / get_pipeline_logs."""
|
||||
models.create_project(conn, "plog_proj", "Log Project", "/tmp/plog")
|
||||
models.create_task(conn, "PLOG-001", "plog_proj", "Log Task")
|
||||
pipe = models.create_pipeline(conn, "PLOG-001", "plog_proj", "feature", [{"role": "dev"}])
|
||||
return conn, pipe["id"]
|
||||
|
||||
|
||||
def test_write_log_returns_dict(pipeline_conn):
|
||||
"""KIN-084: write_log возвращает dict с id, pipeline_id, message, level."""
|
||||
db, pid = pipeline_conn
|
||||
entry = models.write_log(db, pid, "Pipeline started")
|
||||
assert isinstance(entry, dict)
|
||||
assert entry["id"] is not None
|
||||
assert entry["pipeline_id"] == pid
|
||||
assert entry["message"] == "Pipeline started"
|
||||
assert entry["level"] == "INFO"
|
||||
assert entry["ts"] is not None
|
||||
|
||||
|
||||
def test_write_log_extra_none_gives_null(pipeline_conn):
|
||||
"""KIN-084: write_log без extra → extra_json=None."""
|
||||
db, pid = pipeline_conn
|
||||
entry = models.write_log(db, pid, "No extra", extra=None)
|
||||
assert entry["extra_json"] is None
|
||||
|
||||
|
||||
def test_write_log_extra_dict_decoded(pipeline_conn):
|
||||
"""KIN-084: write_log с extra=dict → extra_json декодируется в dict."""
|
||||
db, pid = pipeline_conn
|
||||
entry = models.write_log(db, pid, "With extra", extra={"role": "dev", "model": "sonnet"})
|
||||
assert isinstance(entry["extra_json"], dict)
|
||||
assert entry["extra_json"]["role"] == "dev"
|
||||
assert entry["extra_json"]["model"] == "sonnet"
|
||||
|
||||
|
||||
def test_get_pipeline_logs_since_id_zero_returns_all(pipeline_conn):
|
||||
"""KIN-084: get_pipeline_logs(since_id=0) возвращает все записи."""
|
||||
db, pid = pipeline_conn
|
||||
models.write_log(db, pid, "Entry 1")
|
||||
models.write_log(db, pid, "Entry 2")
|
||||
models.write_log(db, pid, "Entry 3")
|
||||
logs = models.get_pipeline_logs(db, pid, since_id=0)
|
||||
assert len(logs) == 3
|
||||
|
||||
|
||||
def test_get_pipeline_logs_since_id_filters(pipeline_conn):
|
||||
"""KIN-084: get_pipeline_logs(since_id=N) возвращает только id > N."""
|
||||
db, pid = pipeline_conn
|
||||
e1 = models.write_log(db, pid, "Entry 1")
|
||||
models.write_log(db, pid, "Entry 2")
|
||||
models.write_log(db, pid, "Entry 3")
|
||||
logs = models.get_pipeline_logs(db, pid, since_id=e1["id"])
|
||||
assert len(logs) == 2
|
||||
assert all(log["id"] > e1["id"] for log in logs)
|
||||
|
||||
|
||||
def test_get_pipeline_logs_ordered_asc(pipeline_conn):
|
||||
"""KIN-084: get_pipeline_logs возвращает записи в хронологическом порядке."""
|
||||
db, pid = pipeline_conn
|
||||
models.write_log(db, pid, "First")
|
||||
models.write_log(db, pid, "Second")
|
||||
models.write_log(db, pid, "Third")
|
||||
logs = models.get_pipeline_logs(db, pid)
|
||||
ids = [log["id"] for log in logs]
|
||||
assert ids == sorted(ids)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue