File size: 3,125 Bytes
61d29fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
95
96
97
"""
Test suite for the Oral Health Policy Pulse system.
"""
import pytest
from datetime import datetime
from agents.base import AgentRole, MessageType, AgentStatus
from agents.orchestrator import OrchestratorAgent
from agents.scraper import ScraperAgent, MeetingDocument
from agents.classifier import ClassifierAgent, PolicyTopic


class TestAgentBase:
    """Test base agent functionality."""
    
    def test_agent_initialization(self):
        """Test that agents initialize correctly."""
        agent = ScraperAgent()
        assert agent.role == AgentRole.SCRAPER
        assert agent.state.status == AgentStatus.IDLE
    
    def test_agent_status_update(self):
        """Test agent status updates."""
        agent = ScraperAgent()
        agent.update_status(AgentStatus.PROCESSING, "Test task")
        
        assert agent.state.status == AgentStatus.PROCESSING
        assert agent.state.current_task == "Test task"


class TestMeetingDocument:
    """Test meeting document model."""
    
    def test_document_creation(self):
        """Test document creation."""
        doc = MeetingDocument(
            document_id="test-001",
            source_url="https://example.com",
            municipality="Test City",
            state="CA",
            meeting_date=datetime.utcnow(),
            meeting_type="City Council",
            title="Test Meeting",
            content="Test content"
        )
        
        assert doc["document_id"] == "test-001"
        assert doc["municipality"] == "Test City"
        assert "scraped_at" in doc


class TestClassifier:
    """Test classifier agent."""
    
    def test_keyword_classification(self):
        """Test keyword-based classification."""
        classifier = ClassifierAgent()
        
        doc = {
            "document_id": "test-001",
            "raw_title": "Discussion on Water Fluoridation",
            "full_text": "The city council discussed water fluoridation and its benefits.",
            "agenda_items": [],
            "discussion_sections": []
        }
        
        # This would be async in real usage
        # result = await classifier._classify_document(doc)
        
        # For now, just test that the method exists
        assert hasattr(classifier, '_classify_document')
        assert hasattr(classifier, 'topic_keywords')
        assert PolicyTopic.WATER_FLUORIDATION in classifier.topic_keywords


class TestOrchestrator:
    """Test orchestrator agent."""
    
    def test_orchestrator_initialization(self):
        """Test orchestrator initialization."""
        orchestrator = OrchestratorAgent()
        assert orchestrator.role == AgentRole.ORCHESTRATOR
        assert len(orchestrator.agents) == 0
    
    def test_agent_registration(self):
        """Test agent registration."""
        orchestrator = OrchestratorAgent()
        scraper = ScraperAgent()
        
        orchestrator.register_agent(scraper)
        
        assert AgentRole.SCRAPER in orchestrator.agents
        assert orchestrator.agents[AgentRole.SCRAPER] == scraper


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