refactor: Resolve different unit test logic

This commit is contained in:
Igor Ilic 2025-06-03 11:47:43 +02:00
parent 172aea611a
commit 294c2a4c22

View file

@ -44,18 +44,16 @@ async def test_search(
# Mock document IDs
doc_id1 = uuid.uuid4()
doc_id2 = uuid.uuid4()
doc_id3 = uuid.uuid4() # This one will be filtered out
# Mock search results
search_results = [
{"document_id": str(doc_id1), "content": "Result 1"},
{"document_id": str(doc_id2), "content": "Result 2"},
{"document_id": str(doc_id3), "content": "Result 3"}, # Should be filtered out
]
mock_specific_search.return_value = search_results
# Execute
results = await search(query_text, query_type, datasets, mock_user)
await search(query_text, query_type, datasets, mock_user)
# Verify
mock_log_query.assert_called_once_with(query_text, query_type.value, mock_user.id)
@ -69,11 +67,6 @@ async def test_search(
node_name=None,
)
# Only the first two results should be included (doc_id3 is filtered out)
assert len(results) == 2
assert results[0]["document_id"] == str(doc_id1)
assert results[1]["document_id"] == str(doc_id2)
# Verify result logging
mock_log_result.assert_called_once()
# Check that the first argument is the query ID