import pytest from httpx import AsyncClient @pytest.mark.asyncio async def test_tool_definition_crud(auth_client: AsyncClient) -> None: resp = await auth_client.post( "/api/v1/tool-definitions", json={ "key": "opencode", "name": "OpenCode", "image": "ghcr.io/opencode-ai/opencode:latest", }, ) assert resp.status_code == 201 td_id = resp.json()["id"] resp = await auth_client.get("/api/v1/tool-definitions") assert resp.status_code == 200 assert len(resp.json()) >= 1 resp = await auth_client.get(f"/api/v1/tool-definitions/{td_id}") assert resp.status_code == 200 resp = await auth_client.put(f"/api/v1/tool-definitions/{td_id}", json={"name": "OpenCodeV2"}) assert resp.status_code == 200 assert resp.json()["name"] == "OpenCodeV2" resp = await auth_client.delete(f"/api/v1/tool-definitions/{td_id}") assert resp.status_code == 204