This commit was merged in pull request #223.
This commit is contained in:
@@ -5,7 +5,7 @@ from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from timmy.semantic_memory import (
|
||||
from timmy.memory_system import (
|
||||
MemoryChunk,
|
||||
MemorySearcher,
|
||||
SemanticMemory,
|
||||
@@ -201,6 +201,11 @@ class TestSemanticMemory:
|
||||
return sm
|
||||
|
||||
def test_init_creates_db(self, mem):
|
||||
# After consolidation, _init_db ensures schema is ready
|
||||
# The DB file is created lazily; verify by checking we can get a connection
|
||||
|
||||
mem._init_db()
|
||||
# If we get here without error, the DB is initialized
|
||||
assert mem.db_path.exists()
|
||||
|
||||
def test_split_into_chunks_short(self, mem):
|
||||
@@ -283,8 +288,12 @@ class TestSemanticMemory:
|
||||
mem.index_file(md_file)
|
||||
|
||||
# Check DB directly - tiny chunks should NOT be stored
|
||||
# After consolidation: chunks are stored in 'memories' table with memory_type='vault_chunk'
|
||||
conn = sqlite3.connect(str(mem.db_path))
|
||||
cursor = conn.execute("SELECT COUNT(*) FROM chunks WHERE source = ?", (str(md_file),))
|
||||
cursor = conn.execute(
|
||||
"SELECT COUNT(*) FROM memories WHERE source = ? AND memory_type = 'vault_chunk'",
|
||||
(str(md_file),)
|
||||
)
|
||||
stored_count = cursor.fetchone()[0]
|
||||
conn.close()
|
||||
|
||||
@@ -316,13 +325,16 @@ class TestSemanticMemory:
|
||||
import sqlite3
|
||||
|
||||
conn = sqlite3.connect(str(mem.db_path))
|
||||
conn.execute("DELETE FROM chunks")
|
||||
# After consolidation: chunks are stored in 'memories' table with memory_type='vault_chunk'
|
||||
conn.execute("DELETE FROM memories WHERE memory_type = 'vault_chunk'")
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
mem.index_vault()
|
||||
conn = sqlite3.connect(str(mem.db_path))
|
||||
rows = conn.execute("SELECT DISTINCT source FROM chunks").fetchall()
|
||||
rows = conn.execute(
|
||||
"SELECT DISTINCT source FROM memories WHERE memory_type = 'vault_chunk'"
|
||||
).fetchall()
|
||||
conn.close()
|
||||
sources = [r[0] for r in rows]
|
||||
# Only the real file should be indexed, not the handoff
|
||||
@@ -517,8 +529,8 @@ class TestMemoryWrite:
|
||||
"""Mock vector_store functions for memory_write tests."""
|
||||
# Patch where it's imported from, not where it's used
|
||||
with (
|
||||
patch("timmy.memory.vector_store.search_memories") as mock_search,
|
||||
patch("timmy.memory.vector_store.store_memory") as mock_store,
|
||||
patch("timmy.memory_system.search_memories") as mock_search,
|
||||
patch("timmy.memory_system.store_memory") as mock_store,
|
||||
):
|
||||
# Default: no existing memories (no duplicates)
|
||||
mock_search.return_value = []
|
||||
@@ -610,8 +622,8 @@ class TestMemoryForget:
|
||||
"""Mock vector_store functions for memory_forget tests."""
|
||||
# Patch where it's imported from, not where it's used
|
||||
with (
|
||||
patch("timmy.memory.vector_store.search_memories") as mock_search,
|
||||
patch("timmy.memory.vector_store.delete_memory") as mock_delete,
|
||||
patch("timmy.memory_system.search_memories") as mock_search,
|
||||
patch("timmy.memory_system.delete_memory") as mock_delete,
|
||||
):
|
||||
# Default: no results
|
||||
mock_search.return_value = []
|
||||
|
||||
Reference in New Issue
Block a user