Files
wehub-resource-sync 7a0da7932b
OSV-Scanner (Scheduled) / scan-scheduled (push) Failing after 0s
Create Release / test-gate (push) Has been cancelled
Create Release / release-gate (push) Has been cancelled
Create Release / ci-gate (push) Has been cancelled
Create Release / version-check (push) Has been cancelled
Create Release / e2e-test-gate (push) Has been cancelled
Create Release / responsive-test-gate (push) Has been cancelled
Create Release / compat-test-gate (push) Has been cancelled
Create Release / compose-integration-gate (push) Has been cancelled
Create Release / vulture-gate (push) Has been cancelled
Create Release / build (push) Has been cancelled
Create Release / provenance (push) Has been cancelled
Create Release / prerelease-docker (push) Has been cancelled
Create Release / publish-docker (push) Has been cancelled
Create Release / create-release (push) Has been cancelled
Create Release / cleanup-changelog (push) Has been cancelled
Create Release / trigger-pypi (push) Has been cancelled
Create Release / monitor-pypi (push) Has been cancelled
Create Release / Clean up orphan prerelease tags and signatures (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-form] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-metrics] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-workflow] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-core] (push) Has been cancelled
CodeQL Advanced / Analyze (javascript-typescript) (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [history-news] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [library] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [link-analytics] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-core] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-lifecycle] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [error-benchmark] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-pages] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) (push) Has been cancelled
Docker Tests (Consolidated) / Accessibility Tests (push) Has been cancelled
Docker Tests (Consolidated) / LLM Unit Tests (push) Has been cancelled
Docker Tests (Consolidated) / LLM Example Tests (push) Has been cancelled
Docker Tests (Consolidated) / Production Image Smoke Test (push) Has been cancelled
Docker Tests (Consolidated) / Infrastructure Tests (push) Has been cancelled
OSSF Scorecard / OSSF Security Scorecard Analysis (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [mobile] (push) Has been cancelled
Backwards Compatibility / Verify Encryption Constants (push) Has been cancelled
Backwards Compatibility / PyPI Version Compatibility (push) Has been cancelled
Backwards Compatibility / Database Migration Tests (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Docker Tests (Consolidated) / detect-changes (push) Has been cancelled
Docker Tests (Consolidated) / Build Test Image (push) Has been cancelled
Docker Tests (Consolidated) / All Pytest Tests + Coverage (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [accessibility] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [api-crud] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-login] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-pages] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-register] (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:08:55 +08:00

93 lines
2.5 KiB
Python

"""Pytest configuration for retriever integration tests."""
from unittest.mock import Mock
import pytest
from langchain_core.retrievers import BaseRetriever, Document
@pytest.fixture
def mock_retriever():
"""Create a mock retriever for testing."""
class MockRetriever(BaseRetriever):
def __init__(self):
self.queries = []
self.documents = [
Document(
page_content="Test document content",
metadata={"title": "Test Doc", "source": "test"},
)
]
def get_relevant_documents(self, query: str):
self.queries.append(query)
return self.documents
async def aget_relevant_documents(self, query: str):
return self.get_relevant_documents(query)
return MockRetriever()
@pytest.fixture
def multiple_retrievers():
"""Create multiple mock retrievers."""
retrievers = {}
for i in range(3):
class NamedRetriever(BaseRetriever):
def __init__(self, name):
self.name = name
self.queries = []
def get_relevant_documents(self, query: str):
self.queries.append(query)
return [
Document(
page_content=f"Content from {self.name}",
metadata={
"title": f"{self.name} Doc",
"source": self.name,
},
)
]
async def aget_relevant_documents(self, query: str):
return self.get_relevant_documents(query)
retrievers[f"retriever_{i}"] = NamedRetriever(f"retriever_{i}")
return retrievers
@pytest.fixture(autouse=True)
def cleanup_registry():
"""Clean up retriever registry before and after each test."""
from local_deep_research.web_search_engines.retriever_registry import (
retriever_registry,
)
# Clear before test
retriever_registry.clear()
yield
# Clear after test
retriever_registry.clear()
@pytest.fixture
def mock_search_system():
"""Mock the search system for API tests."""
mock = Mock()
mock.analyze_topic.return_value = {
"current_knowledge": "Test summary",
"findings": ["Finding 1", "Finding 2"],
"iterations": 1,
"questions": {},
"formatted_findings": "Formatted findings",
"all_links_of_system": ["source1", "source2"],
}
return mock