kin: KIN-UI-019-backend_dev
This commit is contained in:
parent
859d2ac0f6
commit
57c08db964
2 changed files with 11 additions and 28 deletions
|
|
@ -252,21 +252,14 @@ def test_list_tasks_parent_none_filter(proj):
|
||||||
# 8. API tests
|
# 8. API tests
|
||||||
# ===========================================================================
|
# ===========================================================================
|
||||||
|
|
||||||
def test_patch_task_revising_status(client, tmp_path):
|
def test_patch_task_revising_status(client):
|
||||||
"""PATCH /api/tasks/{id} status=done с открытым child → ответ содержит status='revising'."""
|
"""PATCH /api/tasks/{id} status=done с открытым child → ответ содержит status='revising'."""
|
||||||
import web.api as api_module
|
|
||||||
from core.db import init_db
|
|
||||||
from core import models as m
|
|
||||||
|
|
||||||
client.post("/api/projects", json={"id": "p1", "name": "P1", "path": "/p1"})
|
client.post("/api/projects", json={"id": "p1", "name": "P1", "path": "/p1"})
|
||||||
r = client.post("/api/tasks", json={"project_id": "p1", "title": "Parent Task"})
|
r = client.post("/api/tasks", json={"project_id": "p1", "title": "Parent Task"})
|
||||||
parent_id = r.json()["id"]
|
parent_id = r.json()["id"]
|
||||||
|
|
||||||
# Seed child directly via models (TaskCreate API has no parent_task_id field)
|
client.post("/api/tasks", json={"project_id": "p1", "title": "Child Task",
|
||||||
conn = init_db(api_module.DB_PATH)
|
"parent_task_id": parent_id})
|
||||||
m.create_task(conn, parent_id + "a", "p1", "Child Task",
|
|
||||||
parent_task_id=parent_id, status="pending")
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
r = client.patch(f"/api/tasks/{parent_id}", json={"status": "done"})
|
r = client.patch(f"/api/tasks/{parent_id}", json={"status": "done"})
|
||||||
|
|
||||||
|
|
@ -276,19 +269,14 @@ def test_patch_task_revising_status(client, tmp_path):
|
||||||
|
|
||||||
def test_get_children_endpoint(client):
|
def test_get_children_endpoint(client):
|
||||||
"""GET /api/tasks/{id}/children возвращает список прямых дочерних задач."""
|
"""GET /api/tasks/{id}/children возвращает список прямых дочерних задач."""
|
||||||
import web.api as api_module
|
|
||||||
from core.db import init_db
|
|
||||||
from core import models as m
|
|
||||||
|
|
||||||
client.post("/api/projects", json={"id": "p1", "name": "P1", "path": "/p1"})
|
client.post("/api/projects", json={"id": "p1", "name": "P1", "path": "/p1"})
|
||||||
r = client.post("/api/tasks", json={"project_id": "p1", "title": "Parent Task"})
|
r = client.post("/api/tasks", json={"project_id": "p1", "title": "Parent Task"})
|
||||||
parent_id = r.json()["id"]
|
parent_id = r.json()["id"]
|
||||||
|
|
||||||
# Seed children via models
|
client.post("/api/tasks", json={"project_id": "p1", "title": "Child A",
|
||||||
conn = init_db(api_module.DB_PATH)
|
"parent_task_id": parent_id})
|
||||||
m.create_task(conn, parent_id + "a", "p1", "Child A", parent_task_id=parent_id)
|
client.post("/api/tasks", json={"project_id": "p1", "title": "Child B",
|
||||||
m.create_task(conn, parent_id + "b", "p1", "Child B", parent_task_id=parent_id)
|
"parent_task_id": parent_id})
|
||||||
conn.close()
|
|
||||||
|
|
||||||
r = client.get(f"/api/tasks/{parent_id}/children")
|
r = client.get(f"/api/tasks/{parent_id}/children")
|
||||||
|
|
||||||
|
|
@ -307,19 +295,13 @@ def test_get_children_endpoint_not_found(client):
|
||||||
|
|
||||||
def test_list_tasks_parent_filter_api(client):
|
def test_list_tasks_parent_filter_api(client):
|
||||||
"""GET /api/tasks?parent_task_id={id} фильтрует задачи по родителю."""
|
"""GET /api/tasks?parent_task_id={id} фильтрует задачи по родителю."""
|
||||||
import web.api as api_module
|
|
||||||
from core.db import init_db
|
|
||||||
from core import models as m
|
|
||||||
|
|
||||||
client.post("/api/projects", json={"id": "p1", "name": "P1", "path": "/p1"})
|
client.post("/api/projects", json={"id": "p1", "name": "P1", "path": "/p1"})
|
||||||
r = client.post("/api/tasks", json={"project_id": "p1", "title": "Parent Task"})
|
r = client.post("/api/tasks", json={"project_id": "p1", "title": "Parent Task"})
|
||||||
parent_id = r.json()["id"]
|
parent_id = r.json()["id"]
|
||||||
client.post("/api/tasks", json={"project_id": "p1", "title": "Other Root Task"})
|
client.post("/api/tasks", json={"project_id": "p1", "title": "Other Root Task"})
|
||||||
|
|
||||||
# Seed child via models
|
client.post("/api/tasks", json={"project_id": "p1", "title": "Child Task",
|
||||||
conn = init_db(api_module.DB_PATH)
|
"parent_task_id": parent_id})
|
||||||
m.create_task(conn, parent_id + "a", "p1", "Child Task", parent_task_id=parent_id)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
r = client.get(f"/api/tasks?parent_task_id={parent_id}")
|
r = client.get(f"/api/tasks?parent_task_id={parent_id}")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1864,7 +1864,8 @@ def send_chat_message(project_id: str, body: ChatMessageIn):
|
||||||
|
|
||||||
DIST = Path(__file__).parent / "frontend" / "dist"
|
DIST = Path(__file__).parent / "frontend" / "dist"
|
||||||
|
|
||||||
app.mount("/assets", StaticFiles(directory=str(DIST / "assets")), name="assets")
|
if (DIST / "assets").exists():
|
||||||
|
app.mount("/assets", StaticFiles(directory=str(DIST / "assets")), name="assets")
|
||||||
|
|
||||||
|
|
||||||
@app.get("/{path:path}")
|
@app.get("/{path:path}")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue