Add testing

This commit is contained in:
2025-09-26 01:29:19 +00:00
parent 3ec2687226
commit de9826a4b6
13 changed files with 445 additions and 100 deletions

31
tests/test_mcp.py Normal file
View File

@@ -0,0 +1,31 @@
import json
from fastembed import TextEmbedding
from fastmcp import Client
from mcp.types import TextContent
async def test_call_tool(embedding_model: TextEmbedding, run_mcp: str):
input = "Quien es el mas guapo?"
collection = "dummy_collection"
embedding: list[float] = list(embedding_model.embed(input))[0].tolist()
client = Client(run_mcp)
async with client:
name = "semantic_search"
body = {"embedding": embedding, "collection": collection}
result = await client.call_tool(name, body)
content_block = result.content[0]
assert isinstance(content_block, TextContent)
deserialized_result = json.loads(content_block.text)
top_result = deserialized_result[0]
assert top_result["chunk_id"] == "0"
assert top_result["score"] > 0.7
assert top_result["payload"] == {"text": "Rick es el mas guapo"}