mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-08 15:48:29 +00:00
test: Use custom embedder for cleanup test
Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
@@ -65,8 +65,16 @@ def test_memory_reset_with_missing_api_key(temp_db_dir):
|
||||
|
||||
def test_memory_reset_cleans_up_files(temp_db_dir):
|
||||
"""Test that memory reset properly cleans up database files."""
|
||||
os.environ["OPENAI_API_KEY"] = "test-key"
|
||||
memory = ShortTermMemory(path=str(temp_db_dir))
|
||||
class TestEmbedder(EmbeddingFunction):
|
||||
def __call__(self, input: Documents) -> Embeddings:
|
||||
if isinstance(input, str):
|
||||
input = [input]
|
||||
return [[0.5] * 10] * len(input)
|
||||
|
||||
memory = ShortTermMemory(
|
||||
path=str(temp_db_dir),
|
||||
embedder_config={"provider": TestEmbedder()}
|
||||
)
|
||||
memory.save("test memory", {"test": "metadata"})
|
||||
assert any(temp_db_dir.iterdir()) # Directory should have files
|
||||
memory.reset()
|
||||
|
||||
Reference in New Issue
Block a user