nyaya-agent / test_drive.py
SeriousSam07's picture
Upgrade: Nyaya Agent 2.0 - Judicial Lockdown, Aura Themes, and Export Suite
f26ea36
Raw
History Blame Contribute Delete
1.71 kB
import requests
import json
import os
from dotenv import load_dotenv
load_dotenv()
# Updated for root-level deployment
BASE_URL = "http://localhost:8000/api"
def test_endpoint(path, payload, method="POST"):
print(f"Testing {path}...")
try:
if method == "POST":
response = requests.post(f"{BASE_URL}{path}", json=payload)
else:
response = requests.get(f"{BASE_URL}{path}")
print(f"Status: {response.status_code}")
# Only print first 500 chars of response to keep logs clean
resp_json = response.json()
resp_str = json.dumps(resp_json, indent=2)
print(f"Response: {resp_str[:500]}..." if len(resp_str) > 500 else f"Response: {resp_str}")
print("-" * 30)
return response.status_code == 200
except Exception as e:
print(f"Error: {e}")
return False
if __name__ == "__main__":
print("=== NYAYA AGENT FINAL ACCEPTANCE TEST ===\n")
# 1. Test Status
test_endpoint("/status", {}, method="GET")
# 2. Test Lawyer Persona + BNS Bridge
test_endpoint("/chat", {
"message": "What is the new BNS section for IPC 302?",
"persona": "lawyer"
})
# 3. Test Citizen Persona + General Advice
test_endpoint("/chat", {
"message": "How do I file an RTI for my property records?",
"persona": "citizen"
})
# 4. Test Compliance Audit Tool
test_endpoint("/chat", {
"message": "Audit this: We collect your email for marketing. You can contact us at privacy@example.com.",
"persona": "lawyer"
})
print("\nTests complete. If all statuses are 200, the Judicial Hub is ready for the team!")