- Add complete agent harness structure with 8 roles (leader, triager, architect, implementer, reviewer, security, qa, documenter) - Implement strict workflow with 9 stages and mandatory gates - Add comprehensive verification script and runtime status tracking - Create artifact-based evidence system with contracts and schemas - Add agent policy matrix with permissions and anti-cheat rules - Include test suite (44 tests passing) and CI-ready structure - Add documentation: README, HOWTO, CHECKPOINTS, templates - Configure model routing policies and token-aware task assignment - Add BDD/SDD specification guides and feature templates - Include starter pack for quick project onboarding All verification checks pass. Framework ready for production use.
93 lines
2.5 KiB
Python
93 lines
2.5 KiB
Python
"""Test script for the API."""
|
|
import sys
|
|
import time
|
|
import subprocess
|
|
import requests
|
|
from threading import Thread
|
|
|
|
SERVER_URL = "http://127.0.0.1:8000"
|
|
|
|
def start_server():
|
|
"""Start the uvicorn server."""
|
|
subprocess.run([
|
|
"python3", "-m", "uvicorn",
|
|
"src.main:app",
|
|
"--host", "127.0.0.1",
|
|
"--port", "8000"
|
|
])
|
|
|
|
def wait_for_server(timeout=10):
|
|
"""Wait for server to be ready."""
|
|
start = time.time()
|
|
while time.time() - start < timeout:
|
|
try:
|
|
response = requests.get(f"{SERVER_URL}/health", timeout=1)
|
|
if response.status_code == 200:
|
|
return True
|
|
except:
|
|
pass
|
|
time.sleep(0.5)
|
|
return False
|
|
|
|
def test_health():
|
|
"""Test health endpoint."""
|
|
response = requests.get(f"{SERVER_URL}/health")
|
|
assert response.status_code == 200
|
|
assert response.json()["status"] == "healthy"
|
|
print("✅ Health check passed")
|
|
|
|
def test_login():
|
|
"""Test login endpoint."""
|
|
response = requests.post(
|
|
f"{SERVER_URL}/api/v1/auth/login",
|
|
json={"email": "alice@example.com", "password": "SecurePass123!"}
|
|
)
|
|
assert response.status_code == 200
|
|
data = response.json()
|
|
assert data["success"] == True
|
|
assert "access_token" in data["data"]
|
|
print("✅ Login endpoint passed")
|
|
return data["data"]["access_token"]
|
|
|
|
def test_login_invalid():
|
|
"""Test login with invalid credentials."""
|
|
response = requests.post(
|
|
f"{SERVER_URL}/api/v1/auth/login",
|
|
json={"email": "alice@example.com", "password": "WrongPassword!"}
|
|
)
|
|
assert response.status_code == 401
|
|
print("✅ Invalid login returns 401")
|
|
|
|
def test_profile():
|
|
"""Test profile endpoint."""
|
|
response = requests.get(f"{SERVER_URL}/api/v1/profile/me")
|
|
assert response.status_code == 200
|
|
print("✅ Profile endpoint passed")
|
|
|
|
def run_tests():
|
|
"""Run all tests."""
|
|
print("🔧 Starting server...")
|
|
server_thread = Thread(target=start_server, daemon=True)
|
|
server_thread.start()
|
|
|
|
print("⏳ Waiting for server...")
|
|
if not wait_for_server():
|
|
print("❌ Server failed to start")
|
|
return False
|
|
|
|
print("✅ Server is ready!\n")
|
|
|
|
try:
|
|
test_health()
|
|
test_login()
|
|
test_login_invalid()
|
|
test_profile()
|
|
print("\n🎉 All tests passed!")
|
|
return True
|
|
except Exception as e:
|
|
print(f"\n❌ Test failed: {e}")
|
|
return False
|
|
|
|
if __name__ == "__main__":
|
|
success = run_tests()
|
|
sys.exit(0 if success else 1) |