fix: tests — add setup_db fixture for init_db in test env

This commit is contained in:
Dev Agent
2026-05-19 15:58:37 +03:00
parent 8859c38a2a
commit 95072e000f
16 changed files with 35 additions and 2 deletions

1
.venv/bin/python Symbolic link
View File

@@ -0,0 +1 @@
python3

1
.venv/bin/python3 Symbolic link
View File

@@ -0,0 +1 @@
/usr/bin/python3

1
.venv/bin/python3.10 Symbolic link
View File

@@ -0,0 +1 @@
python3

1
.venv/lib64 Symbolic link
View File

@@ -0,0 +1 @@
lib

3
.venv/pyvenv.cfg Normal file
View File

@@ -0,0 +1,3 @@
home = /usr/bin
include-system-site-packages = false
version = 3.10.12

BIN
data/orchestrator.db Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,12 +1,27 @@
import pytest
from fastapi.testclient import TestClient
import os
import tempfile
# Override DB path before importing app
os.environ["ORCH_DB_PATH"] = os.path.join(tempfile.gettempdir(), "test_orchestrator.db")
_test_db = os.path.join(tempfile.gettempdir(), "test_orchestrator.db")
os.environ["ORCH_DB_PATH"] = _test_db
from fastapi.testclient import TestClient
from src.main import app
from src.db import init_db
@pytest.fixture(autouse=True)
def setup_db():
"""Ensure DB tables exist before each test."""
# Remove old test db if exists
if os.path.exists(_test_db):
os.unlink(_test_db)
init_db()
yield
if os.path.exists(_test_db):
os.unlink(_test_db)
client = TestClient(app)
@@ -63,3 +78,14 @@ def test_status_endpoint():
resp = client.get("/status")
assert resp.status_code == 200
assert "active_tasks" in resp.json()
def test_plane_webhook_creates_task():
"""Verify that work_item.created actually inserts a task."""
client.post("/webhook/plane", json={
"event": "work_item.created",
"data": {"id": "task-456", "name": "New feature", "project": "proj-2"}
})
resp = client.get("/status")
tasks = resp.json()["active_tasks"]
assert any(t["plane_id"] == "task-456" for t in tasks)