Abstraction for Project in MemoryClient (#3067)

This commit is contained in:
Dev Khant
2025-07-08 11:33:20 +05:30
committed by GitHub
parent aae5989e78
commit 70d6f9231b
11 changed files with 1071 additions and 39 deletions

View File

@@ -38,14 +38,13 @@ def test_embed_returns_empty_list_if_none(mock_genai, config):
mock_genai.return_value = type('Response', (), {'embeddings': [type('Embedding', (), {'values': []})]})()
embedder = GoogleGenAIEmbedding(config)
result = embedder.embed("test")
assert result == []
mock_genai.assert_called_once()
with pytest.raises(IndexError): # This will raise IndexError when trying to access [0]
embedder.embed("test")
def test_embed_raises_on_error(mock_genai, config):
mock_genai.side_effect = RuntimeError("Embedding failed")
def test_embed_raises_on_error(mock_genai_client, config):
mock_genai_client.models.embed_content.side_effect = RuntimeError("Embedding failed")
embedder = GoogleGenAIEmbedding(config)

View File

@@ -72,6 +72,9 @@ def test_generate_response_with_tools(mock_gemini_client: Mock):
}
]
# Create a proper mock for the function call arguments
mock_args = {"data": "Today is a sunny day."}
mock_tool_call = Mock()
mock_tool_call.name = "add_memory"
mock_tool_call.args = {"data": "Today is a sunny day."}