chore: add unit tests for pure functions + CI test job #11

Merged
jcabillot merged 7 commits from chore/add-tests into main 2026-06-12 08:50:32 -04:00
Showing only changes of commit 30ac4ae9ca - Show all commits
+19 -5
View File
@@ -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 "<test-001@example.com>" 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"] == []