File size: 3,237 Bytes
bd73133
 
e7b4937
bd73133
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
98
99
100
101
102
103
104
"""
Basic Tests for GAIA Agent - Stage 1 Validation
Author: @mangubee
Date: 2026-01-01

Tests for Stage 1: Foundation Setup
- Agent initialization
- StateGraph compilation
- Basic question processing
"""

import pytest
from src.agent import GAIAAgent
from src.config import Settings


class TestAgentInitialization:
    """Test agent initialization and configuration."""

    def test_agent_init(self):
        """Test that agent can be initialized without errors."""
        agent = GAIAAgent()
        assert agent is not None
        assert agent.graph is not None
        print("✓ Agent initialization successful")

    def test_settings_load(self):
        """Test that settings can be loaded."""
        settings = Settings()
        assert settings is not None
        assert settings.max_retries == 3
        assert settings.question_timeout == 1020
        print("✓ Settings loaded successfully")


class TestBasicExecution:
    """Test basic agent execution with placeholder logic."""

    def test_simple_question(self):
        """Test agent with simple question."""
        agent = GAIAAgent()
        answer = agent("What is 2+2?")
        assert isinstance(answer, str)
        assert len(answer) > 0
        print(f"✓ Agent returned answer: {answer}")

    def test_long_question(self):
        """Test agent with longer question."""
        agent = GAIAAgent()
        long_question = "Explain the significance of the French Revolution in European history and its impact on modern democracy."
        answer = agent(long_question)
        assert isinstance(answer, str)
        assert len(answer) > 0
        print(f"✓ Agent handled long question, returned: {answer[:50]}...")

    def test_multiple_calls(self):
        """Test that agent can handle multiple sequential calls."""
        agent = GAIAAgent()
        questions = [
            "What is the capital of France?",
            "Who wrote Romeo and Juliet?",
            "What is 10 * 5?"
        ]
        for q in questions:
            answer = agent(q)
            assert isinstance(answer, str)
            assert len(answer) > 0
        print(f"✓ Agent successfully processed {len(questions)} questions")


class TestStateGraphStructure:
    """Test StateGraph structure and nodes."""

    def test_graph_has_nodes(self):
        """Test that compiled graph has expected nodes."""
        agent = GAIAAgent()
        # LangGraph compiled graphs don't expose node list directly in Stage 1
        # Just verify graph exists and compiles
        assert agent.graph is not None
        print("✓ StateGraph compiled with expected structure")


if __name__ == "__main__":
    print("\n" + "="*70)
    print("GAIA Agent - Stage 1 Basic Tests")
    print("="*70 + "\n")

    # Run tests manually for quick validation
    test_init = TestAgentInitialization()
    test_init.test_agent_init()
    test_init.test_settings_load()

    test_exec = TestBasicExecution()
    test_exec.test_simple_question()
    test_exec.test_long_question()
    test_exec.test_multiple_calls()

    test_graph = TestStateGraphStructure()
    test_graph.test_graph_has_nodes()

    print("\n" + "="*70)
    print("✓ All Stage 1 tests passed!")
    print("="*70 + "\n")