File size: 1,999 Bytes
905e3b7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Unit tests for agent orchestration."""
import pytest
from app.agents.orchestrator import DocumentAgent
from app.agents.state import AgentState

class TestAgents:
    
    def test_agent_init(self):
        """Test agent initialization."""
        agent = DocumentAgent()
        assert agent is not None
        assert agent.workflow is not None
    
    def test_query_processing(self):
        """Test query processing."""
        agent = DocumentAgent()
        
        result = agent.process_query("What is the termination clause?")
        
        assert result is not None
        assert "response" in result
        assert "confidence" in result
        assert "intent" in result
    
    def test_intent_classification(self):
        """Test intent classification."""
        agent = DocumentAgent()
        
        # Test different intents
        queries = [
            ("Summarize this document", "summary"),
            ("Draft an email", "email"),
            ("Extract all dates", "extract"),
            ("What are the key points?", "qa")
        ]
        
        for query, expected_intent in queries:
            result = agent.process_query(query)
            assert result["intent"] in ["qa", "summary", "email", "extract"]
    
    def test_agent_state(self):
        """Test agent state management."""
        state = AgentState(
            query="test",
            intent="qa",
            documents=[],
            response="",
            confidence=0.0,
            validated=False,
            actions=[],
            error=None
        )
        
        assert state["query"] == "test"
        assert state["intent"] == "qa"
    
    def test_validation_flow(self):
        """Test validation flow."""
        agent = DocumentAgent()
        
        result = agent.process_query("What is the liability limit?")
        
        assert "confidence" in result
        assert 0 <= result["confidence"] <= 1

if __name__ == "__main__":
    pytest.main([__file__])