45 lines
1.2 KiB
Python
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
|