This commit is contained in:
BIN
tests/__pycache__/__init__.cpython-312.pyc
Normal file
BIN
tests/__pycache__/__init__.cpython-312.pyc
Normal file
Binary file not shown.
BIN
tests/__pycache__/conftest.cpython-312-pytest-9.1.1.pyc
Normal file
BIN
tests/__pycache__/conftest.cpython-312-pytest-9.1.1.pyc
Normal file
Binary file not shown.
BIN
tests/__pycache__/test_agent_api.cpython-312-pytest-9.1.1.pyc
Normal file
BIN
tests/__pycache__/test_agent_api.cpython-312-pytest-9.1.1.pyc
Normal file
Binary file not shown.
BIN
tests/__pycache__/test_artifacts.cpython-312-pytest-9.1.1.pyc
Normal file
BIN
tests/__pycache__/test_artifacts.cpython-312-pytest-9.1.1.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
tests/__pycache__/test_package.cpython-312-pytest-9.1.1.pyc
Normal file
BIN
tests/__pycache__/test_package.cpython-312-pytest-9.1.1.pyc
Normal file
Binary file not shown.
BIN
tests/__pycache__/test_skill_loader.cpython-312-pytest-9.1.1.pyc
Normal file
BIN
tests/__pycache__/test_skill_loader.cpython-312-pytest-9.1.1.pyc
Normal file
Binary file not shown.
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
|
||||
32
tests/test_graph_workflow.py
Normal file
32
tests/test_graph_workflow.py
Normal file
@@ -0,0 +1,32 @@
|
||||
"""Integration tests for LangGraph StateGraph execution."""
|
||||
|
||||
import pytest
|
||||
from app.workflows.gcp_architecture_graph import create_agent
|
||||
from app.skills.loader import SkillLoader
|
||||
from app.config import get_settings
|
||||
|
||||
|
||||
def test_agent_graph_execution():
|
||||
"""Verify execution of the 4-phase LangGraph StateGraph."""
|
||||
settings = get_settings()
|
||||
loader = SkillLoader(settings.SKILLS_DIR)
|
||||
loader.load_skills()
|
||||
|
||||
agent = create_agent(loader)
|
||||
initial_state = {
|
||||
"workflow_request": "Event-driven regional HTTP application",
|
||||
"target_dir": ".",
|
||||
"active_skills": [],
|
||||
}
|
||||
|
||||
final_state = agent.invoke(initial_state)
|
||||
|
||||
assert final_state.get("current_phase") == "package"
|
||||
assert final_state.get("requirements_doc") is not None
|
||||
assert final_state.get("architecture_doc") is not None
|
||||
assert final_state.get("mermaid_diagram") is not None
|
||||
assert final_state.get("terraform_code") is not None
|
||||
assert final_state.get("validation_results") is not None
|
||||
assert final_state.get("solution_guide") is not None
|
||||
assert final_state.get("validation_passed") is True
|
||||
assert len(final_state.get("active_skills", [])) == 4
|
||||
45
tests/test_skill_loader.py
Normal file
45
tests/test_skill_loader.py
Normal file
@@ -0,0 +1,45 @@
|
||||
"""Unit tests for Local Dynamic Skill Loader."""
|
||||
|
||||
import pytest
|
||||
from pathlib import Path
|
||||
from app.skills.loader import SkillLoader, LocalSkill
|
||||
from app.config import get_settings
|
||||
|
||||
|
||||
def test_skill_loader_discovery():
|
||||
"""Verify SkillLoader discovers all 4 phase skills under app/skills/."""
|
||||
settings = get_settings()
|
||||
loader = SkillLoader(settings.SKILLS_DIR)
|
||||
skills = loader.load_skills()
|
||||
|
||||
assert len(skills) >= 4
|
||||
assert "requirements_discovery" in skills
|
||||
assert "architecture_design" in skills
|
||||
assert "validation_rules" in skills
|
||||
assert "packaging_guide" in skills
|
||||
|
||||
|
||||
def test_skill_loader_by_phase():
|
||||
"""Verify filtering skills by phase."""
|
||||
settings = get_settings()
|
||||
loader = SkillLoader(settings.SKILLS_DIR)
|
||||
loader.load_skills()
|
||||
|
||||
discover_skills = loader.get_skills_by_phase("discover")
|
||||
assert len(discover_skills) == 1
|
||||
assert discover_skills[0].name == "requirements_discovery"
|
||||
|
||||
design_skills = loader.get_skills_by_phase("design")
|
||||
assert len(design_skills) == 1
|
||||
assert design_skills[0].name == "architecture_design"
|
||||
|
||||
|
||||
def test_format_skills_for_prompt():
|
||||
"""Verify formatting skill content into prompt text."""
|
||||
settings = get_settings()
|
||||
loader = SkillLoader(settings.SKILLS_DIR)
|
||||
loader.load_skills()
|
||||
|
||||
prompt = loader.format_skills_for_prompt("discover")
|
||||
assert "## Injected Skill Instructions" in prompt
|
||||
assert "requirements_discovery" in prompt
|
||||
Reference in New Issue
Block a user