arch-design-agent-skill-das.../backend/tests/test_api_project.py
openclaw 50db453ec9 feat(project): add REST API — CRUD endpoints with FastAPI
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 16:06:58 +00:00

45 lines
1.2 KiB
Python

import pytest
def test_health(client):
r = client.get("/api/health")
assert r.status_code == 200
assert r.json()["status"] == "ok"
def test_list_projects_empty(client):
r = client.get("/api/projects")
assert r.status_code == 200
assert r.json() == []
def test_create_and_get_project(client, design_dir):
r = client.post("/api/projects", json={"name": "test", "design_dir": str(design_dir)})
assert r.status_code == 201
pid = r.json()["id"]
r = client.get(f"/api/projects/{pid}")
assert r.status_code == 200
assert r.json()["name"] == "test"
def test_create_project_invalid_dir(client):
r = client.post("/api/projects", json={"name": "test", "design_dir": "/nonexistent"})
assert r.status_code == 400
def test_delete_project(client, design_dir):
r = client.post("/api/projects", json={"name": "test", "design_dir": str(design_dir)})
pid = r.json()["id"]
r = client.delete(f"/api/projects/{pid}")
assert r.status_code == 204
r = client.get(f"/api/projects/{pid}")
assert r.status_code == 404
def test_get_nonexistent_project(client):
r = client.get("/api/projects/nonexistent")
assert r.status_code == 404