Spaces:
Runtime error
Runtime error
| import pytest | |
| from unittest.mock import MagicMock | |
| from src.core.orchestrator import VideoAgent | |
| from src.interfaces.base import PerceptionEngine, MemoryManager | |
| class TestVideoAgent: | |
| def test_agent_answers_from_memory(self): | |
| """If memory has the answer, it returns it without watching video.""" | |
| # Setup | |
| mock_perception = MagicMock(spec=PerceptionEngine) | |
| mock_memory = MagicMock(spec=MemoryManager) | |
| # Memory returns a hit | |
| mock_memory.query_knowledge.return_value = [ | |
| {"timestamp": "00:05", "description": "The dog is jumping."} | |
| ] | |
| agent = VideoAgent(perception=mock_perception, memory=mock_memory) | |
| # Act | |
| response = agent.ask("What is the dog doing?", video_id="test_vid") | |
| # Assert | |
| assert "jumping" in response | |
| # Should NOT call vision engine because memory had it | |
| mock_perception.analyze_video_segment.assert_not_called() | |
| def test_agent_uses_perception_if_memory_fails(self): | |
| """If memory is empty, it triggers vision lookups.""" | |
| # Setup | |
| mock_perception = MagicMock(spec=PerceptionEngine) | |
| mock_memory = MagicMock(spec=MemoryManager) | |
| # Memory miss | |
| mock_memory.query_knowledge.return_value = [] | |
| # Vision engine returns info | |
| mock_perception.analyze_video_segment.return_value = "The car is red." | |
| agent = VideoAgent(perception=mock_perception, memory=mock_memory) | |
| # Act | |
| response = agent.ask("What color is the car?", video_id="test_vid") | |
| # Assert | |
| # It should have tried to look at the video | |
| # (In a real implementation, we'd need logic to find *where* to look, | |
| # but for this MVP test, we assume it scans or we mock the 'plan' logic). | |
| # For simplicity in MVP, if memory fails, maybe it scans the beginning or a default segment? | |
| # Let's assume the agent defaults to scanning. | |
| pass # To be defined in logic | |