Files
sama/tests/test_memory/test_working.py
T
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

43 lines
1.0 KiB
Python

"""
Tests for WorkingMemory.
"""
import pytest
from dcos.memory.working import WorkingMemory
class TestWorkingMemory:
def test_store_and_recall(self):
mem = WorkingMemory()
mem.store("key1", "value1")
assert mem.recall("key1") == "value1"
def test_overwrite(self):
mem = WorkingMemory()
mem.store("k", "v1")
mem.store("k", "v2")
assert mem.recall("k") == "v2"
def test_missing_key(self):
mem = WorkingMemory()
assert mem.recall("nonexistent") is None
def test_contains(self):
mem = WorkingMemory()
mem.store("present", "data")
assert mem.contains("present") is True
assert mem.contains("absent") is False
def test_clear(self):
mem = WorkingMemory()
mem.store("a", 1)
mem.store("b", 2)
mem.clear()
assert mem.size() == 0
def test_capacity(self):
mem = WorkingMemory(capacity=5)
for i in range(10):
mem.store(f"key{i}", i)
assert mem.size() <= 5