From c22cdbffa50ac634f7fecf080f3c3b5662e67131 Mon Sep 17 00:00:00 2001 From: batsumaru <> Date: Thu, 17 Sep 2026 11:07:06 +0900 Subject: Added importance --- tests/test_memory_tools.py | 82 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) (limited to 'tests/test_memory_tools.py') diff --git a/tests/test_memory_tools.py b/tests/test_memory_tools.py index 9e0fcb0..89a3e93 100644 --- a/tests/test_memory_tools.py +++ b/tests/test_memory_tools.py @@ -23,6 +23,7 @@ def test_save_tool_persists_memory(tmp_path): { "content": "User prefers Rust for systems programming.", "category": "semantic", + "importance": 2, } ) @@ -31,6 +32,7 @@ def test_save_tool_persists_memory(tmp_path): assert len(memories) == 1 assert memories[0].content == "User prefers Rust for systems programming." assert memories[0].category is MemoryCategory.SEMANTIC + assert memories[0].importance == 2 assert str(memories[0].id) in result.content @@ -55,6 +57,7 @@ def test_save_tool_rejects_invalid_category(tmp_path): { "content": "Something", "category": "invalid", + "importance": 2, } ) except ToolError as error: @@ -72,12 +75,14 @@ def test_search_tool_returns_matching_memories(tmp_path): { "content": "User prefers Rust for systems programming.", "category": "semantic", + "importance": 2, } ) save_tool.execute( { "content": "User visited Tokyo last year.", "category": "episodic", + "importance": 2, } ) @@ -96,12 +101,14 @@ def test_search_tool_can_filter_category(tmp_path): { "content": "User likes Rust.", "category": "semantic", + "importance": 2, } ) save_tool.execute( { "content": "User worked on a Rust project last summer.", "category": "episodic", + "importance": 2, } ) @@ -109,6 +116,7 @@ def test_search_tool_can_filter_category(tmp_path): { "query": "Rust", "category": "episodic", + "importance": 2, } ) @@ -146,6 +154,7 @@ def test_delete_tool_removes_memory(tmp_path): { "content": "User likes Rust.", "category": "semantic", + "importance": 2, } ) @@ -167,3 +176,76 @@ def test_delete_tool_rejects_invalid_id(tmp_path): assert str(error) == "id must be a valid UUID" else: raise AssertionError("Expected ToolError") + + +def test_save_tool_persists_importance(tmp_path): + store = create_store(tmp_path) + tool = LongTermMemorySaveTool(store) + + tool.execute( + { + "content": "Especially important user preference.", + "category": "semantic", + "importance": 3, + } + ) + + memories = store.list() + + assert len(memories) == 1 + assert memories[0].importance == 3 + + +def test_save_tool_rejects_invalid_importance(tmp_path): + store = create_store(tmp_path) + tool = LongTermMemorySaveTool(store) + + for importance in (0, 4): + try: + tool.execute( + { + "content": "Invalid importance.", + "category": "semantic", + "importance": importance, + } + ) + except ToolError as error: + assert str(error) == "importance must be between 1 and 3" + else: + raise AssertionError("Expected ToolError") + + +def test_save_tool_rejects_non_integer_importance(tmp_path): + store = create_store(tmp_path) + tool = LongTermMemorySaveTool(store) + + try: + tool.execute( + { + "content": "Invalid importance.", + "category": "semantic", + "importance": "3", + } + ) + except ToolError as error: + assert str(error) == "importance must be an integer" + else: + raise AssertionError("Expected ToolError") + + +def test_save_tool_rejects_boolean_importance(tmp_path): + store = create_store(tmp_path) + tool = LongTermMemorySaveTool(store) + + try: + tool.execute( + { + "content": "Invalid importance.", + "category": "semantic", + "importance": True, + } + ) + except ToolError as error: + assert str(error) == "importance must be an integer" + else: + raise AssertionError("Expected ToolError") -- cgit v1.3