This commit is contained in:
52
tests/test_agent_api.py
Normal file
52
tests/test_agent_api.py
Normal file
@@ -0,0 +1,52 @@
|
||||
"""Starlette REST API integration tests using TestClient."""
|
||||
|
||||
import pytest
|
||||
from starlette.testclient import TestClient
|
||||
from app.agent import app
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
return TestClient(app)
|
||||
|
||||
|
||||
def test_health_endpoint(client):
|
||||
"""GET /health returns healthy status."""
|
||||
response = client.get("/health")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["status"] == "healthy"
|
||||
assert "gcp_solution_architecture_agent" in data["agent"]
|
||||
|
||||
|
||||
def test_card_endpoint(client):
|
||||
"""GET /card returns agent capability card."""
|
||||
response = client.get("/card")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["name"] == "gcp_solution_architecture_agent"
|
||||
assert "discover" in data["capabilities"]["phases"]
|
||||
|
||||
|
||||
def test_generate_endpoint(client):
|
||||
"""POST /generate executes full agent workflow."""
|
||||
payload = {
|
||||
"request": "Build an event-driven regional ingestion service",
|
||||
"target_dir": ".",
|
||||
}
|
||||
response = client.post("/generate", json=payload)
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["status"] == "success"
|
||||
assert data["validation_passed"] is True
|
||||
assert "artifacts" in data
|
||||
assert "solution_guide" in data["artifacts"]
|
||||
|
||||
|
||||
def test_validate_endpoint(client):
|
||||
"""POST /validate executes pre-deployment validation checks."""
|
||||
payload = {"target_dir": "."}
|
||||
response = client.post("/validate", json=payload)
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["valid"] is True
|
||||
Reference in New Issue
Block a user