import asyncio import os import shutil from app.agents.orchestrator import orchestrator async def test_integrated_auto_reporting(): print("Starting Integrated Auto-Reporting Test...") # 1. Clean up old test reports test_session_id = "INTEGRATION-TEST-AUTO-REPORT" report_path = f"reports/sessions/{test_session_id}" if os.path.exists(report_path): shutil.rmtree(report_path) # 2. Initialize orchestrator (if needed) if not orchestrator.initialized: await orchestrator.initialize() # 3. Simulate a HIGH-RISK scam message # Most banking scams are high risk. # Auto-report triggers if risk_score >= 0.7 (as per orchestrator.py) scam_msg = "URGENT: Your bank account will be blocked in 2 hours. Update KYC at http://bank-kyc-scam.com . UPI: fraud@bank" print(f"\n[+] Processing fake scam message for session: {test_session_id}") result = await orchestrator.process_message( message=scam_msg, conversation_id=test_session_id, auto_report=True # MANDATORY for this test ) # 4. Verify Results print(f"\n[+] Analysis Results:") print(f" - Risk Score: {result.get('risk_score')}") print(f" - Is Scam: {result.get('is_scam')}") # 5. Check if files were created dossier_file = f"{report_path}/dossier_{test_session_id}.md" export_file = f"{report_path}/official_exports_{test_session_id}.json" print(f"\n[+] Verifying file creation in: {report_path}") dossier_exists = os.path.exists(dossier_file) export_exists = os.path.exists(export_file) if dossier_exists: print(f"COMPLETED: Dossier found: {dossier_file}") else: print(f"FAILED: Dossier NOT found at {dossier_file}") if export_exists: print(f"COMPLETED: Official Exports found: {export_file}") else: print(f"FAILED: Exports NOT found at {export_file}") # Final Verdict if dossier_exists and export_exists and result.get('risk_score', 0) >= 0.7: print(f"\nSUCCESS! Orchestrator successfully auto-reported and saved files.") else: print(f"\nWARNING: Integration check failed or risk score was too low.") if __name__ == "__main__": asyncio.run(test_integrated_auto_reporting())