mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-12 14:52:11 +02:00
Fixed tests
This commit is contained in:
parent
90c1c8cc2f
commit
22c77ebead
2 changed files with 16 additions and 10 deletions
|
|
@ -208,9 +208,12 @@ class TestQuery:
|
||||||
collection="test_collection"
|
collection="test_collection"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Verify result is list of fetched document content
|
# Verify result is tuple of (docs, chunk_ids)
|
||||||
assert "Document 1 content" in result
|
docs, chunk_ids = result
|
||||||
assert "Document 2 content" in result
|
assert "Document 1 content" in docs
|
||||||
|
assert "Document 2 content" in docs
|
||||||
|
assert "doc/c1" in chunk_ids
|
||||||
|
assert "doc/c2" in chunk_ids
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_document_rag_query_method(self, mock_fetch_chunk):
|
async def test_document_rag_query_method(self, mock_fetch_chunk):
|
||||||
|
|
@ -350,8 +353,10 @@ class TestQuery:
|
||||||
mock_embeddings_client.embed.assert_called_once_with(["verbose test"])
|
mock_embeddings_client.embed.assert_called_once_with(["verbose test"])
|
||||||
mock_doc_embeddings_client.query.assert_called_once()
|
mock_doc_embeddings_client.query.assert_called_once()
|
||||||
|
|
||||||
# Verify result contains fetched content
|
# Verify result is tuple of (docs, chunk_ids) with fetched content
|
||||||
assert "Verbose test doc" in result
|
docs, chunk_ids = result
|
||||||
|
assert "Verbose test doc" in docs
|
||||||
|
assert "doc/c6" in chunk_ids
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_document_rag_query_with_verbose(self, mock_fetch_chunk):
|
async def test_document_rag_query_with_verbose(self, mock_fetch_chunk):
|
||||||
|
|
@ -426,8 +431,8 @@ class TestQuery:
|
||||||
mock_embeddings_client.embed.assert_called_once_with(["query with no results"])
|
mock_embeddings_client.embed.assert_called_once_with(["query with no results"])
|
||||||
mock_doc_embeddings_client.query.assert_called_once()
|
mock_doc_embeddings_client.query.assert_called_once()
|
||||||
|
|
||||||
# Verify empty result is returned
|
# Verify empty result is returned (tuple of empty lists)
|
||||||
assert result == []
|
assert result == ([], [])
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_document_rag_query_with_empty_documents(self, mock_fetch_chunk):
|
async def test_document_rag_query_with_empty_documents(self, mock_fetch_chunk):
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ passed to the DocumentRag.query() method.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from unittest.mock import MagicMock, AsyncMock, patch
|
from unittest.mock import MagicMock, AsyncMock, patch, ANY
|
||||||
|
|
||||||
from trustgraph.retrieval.document_rag.rag import Processor
|
from trustgraph.retrieval.document_rag.rag import Processor
|
||||||
from trustgraph.schema import DocumentRagQuery, DocumentRagResponse
|
from trustgraph.schema import DocumentRagQuery, DocumentRagResponse
|
||||||
|
|
@ -66,7 +66,8 @@ class TestDocumentRagService:
|
||||||
"test query",
|
"test query",
|
||||||
user="my_user", # Must be from message, not hardcoded default
|
user="my_user", # Must be from message, not hardcoded default
|
||||||
collection="test_coll_1", # Must be from message, not hardcoded default
|
collection="test_coll_1", # Must be from message, not hardcoded default
|
||||||
doc_limit=5
|
doc_limit=5,
|
||||||
|
explain_callback=ANY, # Explainability callback is always passed
|
||||||
)
|
)
|
||||||
|
|
||||||
# Verify response was sent
|
# Verify response was sent
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue