""" Unit tests for agent.py module Tests the proxy module that re-exports Agent classes. """ import pytest import sys import importlib class TestAgentModule: """Test suite for the agent module.""" def test_agent_module_imports(self): """Test that agent module imports are accessible.""" # Force reload to ensure coverage tracks imports if 'cleveragents.agent' in sys.modules: del sys.modules['cleveragents.agent'] # Import the module to trigger coverage import cleveragents.agent as agent # Verify Agent is importable assert hasattr(agent, 'Agent') assert hasattr(agent, 'AgentWithMemory') def test_agent_class_available(self): """Test that Agent class is available from agent module.""" # Force reload to track imports if 'cleveragents.agent' in sys.modules: importlib.reload(sys.modules['cleveragents.agent']) from cleveragents.agent import Agent assert Agent is not None # Verify it's a class assert isinstance(Agent, type) def test_agent_with_memory_class_available(self): """Test that AgentWithMemory class is available from agent module.""" # Force reload to track imports if 'cleveragents.agent' in sys.modules: importlib.reload(sys.modules['cleveragents.agent']) from cleveragents.agent import AgentWithMemory assert AgentWithMemory is not None # Verify it's a class assert isinstance(AgentWithMemory, type) def test_module_source_code_execution(self): """Test by executing the module source directly.""" import cleveragents.agent from pathlib import Path # Read and execute the source to ensure coverage source_file = Path(cleveragents.agent.__file__) with open(source_file, 'r') as f: source_code = f.read() # Create a namespace and execute namespace = {} exec(source_code, namespace) # Verify the expected exports are in namespace assert 'Agent' in namespace assert 'AgentWithMemory' in namespace assert '__all__' in namespace def test_module_all_attribute(self): """Test that __all__ is properly defined.""" from cleveragents import agent assert hasattr(agent, '__all__') assert 'Agent' in agent.__all__ assert 'AgentWithMemory' in agent.__all__ assert len(agent.__all__) == 2 def test_agent_import_from_module(self): """Test importing Agent from the agent module.""" from cleveragents.agent import Agent from cleveragents.agents.base import Agent as BaseAgent # Verify they're the same class assert Agent is BaseAgent def test_agent_with_memory_import_from_module(self): """Test importing AgentWithMemory from the agent module.""" from cleveragents.agent import AgentWithMemory from cleveragents.agents.base import AgentWithMemory as BaseAgentWithMemory # Verify they're the same class assert AgentWithMemory is BaseAgentWithMemory def test_module_docstring(self): """Test that the module has a docstring.""" from cleveragents import agent assert agent.__doc__ is not None assert "proxy" in agent.__doc__.lower() if __name__ == "__main__": pytest.main([__file__, "-v"])