Files
sama/tests/test_memory/test_conversation.py
Celes Renata 57619860d5 feat: implement DCOS source tree, tests, and build configuration
Complete implementation of the DCOS package including:
- 40+ Python source files across agents, communication, core, learning, memory, protocols, utils
- pyproject.toml build configuration
- 102 unit tests across all subsystems
- Fixed flake.nix (Python 3.12, proper dependencies, pyproject build)
- Fixed .woodpecker.yml (correct paths, removed silent-fail flags)
- Added .gitignore
- Cleared stale pytest cache
2026-08-02 03:29:55 -07:00

36 lines
1.1 KiB
Python

"""
Tests for ConversationMemory.
"""
import pytest
from dcos.memory.conversation import ConversationMemory
class TestConversationMemory:
def test_create_conversation(self):
mem = ConversationMemory()
conv = mem.create("conv_1", ["agent_a", "agent_b"])
assert conv.conversation_id == "conv_1"
assert len(conv.participants) == 2
def test_add_turn(self):
mem = ConversationMemory()
mem.create("conv_1", ["alice", "bob"])
turn = mem.add_turn("conv_1", "alice", "Hello Bob!")
assert turn is not None
assert turn.content == "Hello Bob!"
def test_get_history(self):
mem = ConversationMemory()
mem.create("conv_1", ["a", "b"])
mem.add_turn("conv_1", "a", "msg1")
mem.add_turn("conv_1", "b", "msg2")
history = mem.get_history("conv_1")
assert history is not None
assert len(history) == 2
def test_missing_conversation(self):
mem = ConversationMemory()
assert mem.add_turn("nonexistent", "a", "msg") is None
assert mem.get_history("nonexistent") is None