Skip to content

Building AI agents, atomically

test: add a failing test case for issue #145

Renaud81b5afc4b26a
diff --git a/atomic-agents/tests/lib/components/test_agent_memory.py b/atomic-agents/tests/lib/components/test_agent_memory.py
index e0d95da..f8d8d92 100644
--- a/atomic-agents/tests/lib/components/test_agent_memory.py
+++ b/atomic-agents/tests/lib/components/test_agent_memory.py
@@ -1,3 +1,5 @@
+from enum import Enum
+
import pytest
import json
from typing import List, Dict
@@ -52,6 +54,16 @@ class TestMultimodalSchema(BaseIOSchema):
audio: instructor.multimodal.Audio = Field(..., description="The Audio to analyze")
+class ColorEnum(str, Enum):
+ BLUE = "blue"
+ RED = "red"
+
+
+class TestEnumSchema(BaseIOSchema):
+ """Test Input Schema with Enum."""
+ color: ColorEnum = Field(..., description="Some color.")
+
+
@pytest.fixture
def memory():
return AgentMemory(max_messages=5)
@@ -192,6 +204,25 @@ def test_dump_and_load_multimodal_data(memory):
assert new_memory.history[0].content.audio == memory.history[0].content.audio
+def test_dump_and_load_with_enum(memory):
+ """Test that get_history works with Enum."""
+
+ memory.add_message(
+ "user",
+ TestEnumSchema(
+ color=ColorEnum.RED,
+ ),
+ )
+
+ dumped_data = memory.dump()
+ new_memory = AgentMemory()
+ new_memory.load(dumped_data)
+
+ assert new_memory.max_messages == memory.max_messages
+ assert new_memory.current_turn_id == memory.current_turn_id
+ assert len(new_memory.history) == len(memory.history)
+
+
def test_load_invalid_data(memory):
with pytest.raises(ValueError):
memory.load("invalid json")