isolated-sandbox / verify_functionality.py
Likho User
Fix test and add functionality verification script
c2fe03b
#!/usr/bin/env python3
"""Quick functionality verification script"""
from fastapi.testclient import TestClient
from app import app
def main():
print("=" * 60)
print("FUNCTIONALITY VERIFICATION")
print("=" * 60)
print()
client = TestClient(app)
results = []
# Test root endpoint
print("1. Testing Root Endpoint (/):")
r = client.get("/")
data = r.json()
success = r.status_code == 200 and data["name"] == "isolated-sandbox"
status = "[PASS]" if success else "[FAIL]"
print(f" {status} - Status: {r.status_code}, Name: {data['name']}")
results.append(("Root Endpoint", success))
print()
# Test health endpoint
print("2. Testing Health Endpoint (/health):")
r = client.get("/health")
h = r.json()
success = r.status_code == 200 and h["status"] == "healthy"
status = "[PASS]" if success else "[FAIL]"
print(f" {status} - Status: {r.status_code}, Docker: {h['docker']}")
results.append(("Health Endpoint", success))
print()
# Test languages endpoint
print("3. Testing Languages Endpoint (/languages):")
r = client.get("/languages")
data = r.json()
success = r.status_code == 200 and "languages" in data
status = "[PASS]" if success else "[FAIL]"
print(f" {status} - Status: {r.status_code}, Languages: {len(data.get('languages', []))}")
results.append(("Languages Endpoint", success))
print()
# Test UI rules endpoint
print("4. Testing UI Rules Endpoint (/ui-rules):")
r = client.get("/ui-rules")
success = r.status_code == 200 and "text/html" in r.headers.get("content-type", "")
status = "[PASS]" if success else "[FAIL]"
print(f" {status} - Status: {r.status_code}, Content-Type: {r.headers.get('content-type', 'unknown')}")
print(f" Content Size: {len(r.text)} bytes")
results.append(("UI Rules Endpoint", success))
print()
# Test docs endpoint (should redirect or return OpenAPI schema)
print("5. Testing Docs Endpoint (/docs):")
r = client.get("/docs")
success = r.status_code in [200, 307] # 200 for HTML or 307 for redirect
status = "[PASS]" if success else "[FAIL]"
print(f" {status} - Status: {r.status_code}")
results.append(("Docs Endpoint", success))
print()
# Test OpenAPI schema
print("6. Testing OpenAPI Schema (/openapi.json):")
r = client.get("/openapi.json")
data = r.json() if r.status_code == 200 else {}
success = r.status_code == 200 and data.get("info", {}).get("title") == "isolated-sandbox"
status = "[PASS]" if success else "[FAIL]"
print(f" {status} - Status: {r.status_code}, Title: {data.get('info', {}).get('title', 'N/A')}")
results.append(("OpenAPI Schema", success))
print()
# Summary
print("=" * 60)
print("VERIFICATION SUMMARY")
print("=" * 60)
passed = sum(1 for _, s in results if s)
total = len(results)
for name, success in results:
status = "[PASS]" if success else "[FAIL]"
print(f"{status} - {name}")
print()
print(f"Results: {passed}/{total} endpoints verified")
if passed == total:
print("[SUCCESS] All functionality verified successfully!")
return 0
else:
print("[FAILED] Some endpoints failed verification")
return 1
if __name__ == "__main__":
exit(main())