-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_real_integration.py
More file actions
94 lines (73 loc) · 3.36 KB
/
Copy pathtest_real_integration.py
File metadata and controls
94 lines (73 loc) · 3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env python3
"""
Test the real ReqDefender integration
"""
import asyncio
import sys
import os
from pathlib import Path
# Add project root to path
project_root = Path(__file__).parent
sys.path.append(str(project_root))
async def test_real_components():
"""Test that all real components work together"""
print("🧪 Testing Real ReqDefender Integration")
print("=" * 50)
try:
# Test 1: Search Pipeline
print("1️⃣ Testing Search Pipeline...")
from research.searcher_working import WorkingResearchPipeline
pipeline = WorkingResearchPipeline()
results = await pipeline.search_evidence("implement OAuth authentication", "neutral")
print(f" ✅ Search: Found {len(results)} results")
# Test 2: Evidence System
print("2️⃣ Testing Evidence System...")
# Import directly to avoid arena __init__ dependencies
sys.path.append(os.path.join(project_root, 'arena'))
from evidence_system import EvidenceGatherer, EvidenceScorer
gatherer = EvidenceGatherer()
evidence = await gatherer.gather_evidence("implement OAuth authentication", "neutral", max_sources=3)
print(f" ✅ Evidence: Gathered {len(evidence)} evidence objects")
if evidence:
scorer = EvidenceScorer()
collection_score = scorer.score_evidence_collection(evidence)
print(f" 📊 Collection score: {collection_score:.3f}")
# Test 3: Integration Flow
print("3️⃣ Testing Integration Flow...")
# Simulate the flow from streamlit app
requirement = "add two-factor authentication"
# Search for PRO evidence
pro_results = await pipeline.search_evidence(requirement, "support")
print(f" 💚 PRO evidence: {len(pro_results)} sources")
# Search for CON evidence
con_results = await pipeline.search_evidence(requirement, "oppose")
print(f" ❤️ CON evidence: {len(con_results)} sources")
total_sources = len(pro_results) + len(con_results)
print(f" 📊 Total evidence sources: {total_sources}")
# Test 4: Mock Verdict Generation
print("4️⃣ Testing Verdict Logic...")
pro_score = len(pro_results) * 10 + 15 # Arguments
con_score = len(con_results) * 10 + 15
if pro_score > con_score * 1.2:
verdict = "APPROVED"
elif con_score > pro_score * 1.2:
verdict = "REJECTED"
else:
verdict = "NEEDS_RESEARCH"
confidence = min(95, 60 + abs(pro_score - con_score))
print(f" ⚖️ Verdict: {verdict} (confidence: {confidence:.1f}%)")
print(f" 📊 Scores: PRO {pro_score} vs CON {con_score}")
print("\n🎉 Integration Test Complete!")
print("=" * 50)
print("✅ All core components working")
print("✅ Evidence gathering operational")
print("✅ Search integration functional")
print("✅ Scoring system active")
print("✅ Ready for real debates!")
except Exception as e:
print(f"❌ Integration test failed: {e}")
import traceback
traceback.print_exc()
if __name__ == "__main__":
asyncio.run(test_real_components())
#built with love