36 lines
1.0 KiB
Python
36 lines
1.0 KiB
Python
import pytest
|
|
from httpx import AsyncClient
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_project_crud(auth_client: AsyncClient) -> None:
|
|
# Create
|
|
resp = await auth_client.post("/api/v1/projects", json={"name": "Test", "slug": "test"})
|
|
assert resp.status_code == 201
|
|
data = resp.json()
|
|
assert data["name"] == "Test"
|
|
project_id = data["id"]
|
|
|
|
# List
|
|
resp = await auth_client.get("/api/v1/projects")
|
|
assert resp.status_code == 200
|
|
assert len(resp.json()) == 1
|
|
|
|
# Get
|
|
resp = await auth_client.get(f"/api/v1/projects/{project_id}")
|
|
assert resp.status_code == 200
|
|
assert resp.json()["slug"] == "test"
|
|
|
|
# Update
|
|
resp = await auth_client.put(f"/api/v1/projects/{project_id}", json={"name": "Updated"})
|
|
assert resp.status_code == 200
|
|
assert resp.json()["name"] == "Updated"
|
|
|
|
# Delete
|
|
resp = await auth_client.delete(f"/api/v1/projects/{project_id}")
|
|
assert resp.status_code == 204
|
|
|
|
# Verify deletion
|
|
resp = await auth_client.get(f"/api/v1/projects/{project_id}")
|
|
assert resp.status_code == 404
|