From 30ac4ae9ca73be8aa41c0f67b768aba5b5a210de Mon Sep 17 00:00:00 2001 From: cloudix_mcp_server Date: Fri, 12 Jun 2026 08:25:52 -0400 Subject: [PATCH] fix: correct integration test assertions for semantic search - test_search_by_content: format_search_result() does not include body_text, so check for the expected message_id instead. - test_search_no_results: vector cosine similarity always returns nearest neighbors; use a date filter far in the future to guarantee zero results instead. --- tests/test_integration.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/tests/test_integration.py b/tests/test_integration.py index 43bb19a..dd53c7f 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -132,11 +132,17 @@ def qdrant_setup(): class TestSearchEmails: def test_search_by_content(self, qdrant_setup): - """Search for emails about Python/programming.""" + """Semantic search returns the most relevant email first. + + Searching for 'Python programming' should match email 001 + which discusses Python and vector databases. + """ result = search_emails(query="Python programming") assert result["count"] >= 1 assert "results" in result - assert any("Python" in r.get("body_text", "") for r in result["results"]) + # The top result should be email 001 (most semantically relevant) + messages = [r["message_id"] for r in result["results"]] + assert "" in messages def test_search_with_participant_filter(self, qdrant_setup): """Search emails sent by alice.""" @@ -153,9 +159,17 @@ class TestSearchEmails: date = r.get("date", "") assert date >= "2026-02-01" - def test_search_no_results(self, qdrant_setup): - """Search for something that doesn't exist.""" - result = search_emails(query="gobbledygookxyz123") + def test_search_no_results_by_date(self, qdrant_setup): + """Search with a filter that matches no emails returns empty results. + + With semantic (vector) search, any text query always has nearest + neighbors, so we use a date filter that matches nothing instead. + """ + result = search_emails( + query="anything", + start_date="2099-01-01", + end_date="2099-12-31", + ) assert result["count"] == 0 assert result["results"] == []