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

213 lines
6.3 KiB
Python

"""
Fixtures for MCP server tests.
"""
import pytest
from unittest.mock import patch
@pytest.fixture
def mock_quick_summary():
"""Mock the quick_summary function."""
mock_result = {
"summary": "This is a test summary about quantum computing.",
"findings": [
{
"phase": "Iteration 1",
"content": "Quantum computing uses qubits instead of classical bits.",
}
],
"iterations": 1,
"questions": {0: ["What is quantum computing?"]},
"formatted_findings": "## Findings\n\nQuantum computing uses qubits.",
"sources": [
{
"title": "Wikipedia - Quantum Computing",
"link": "https://en.wikipedia.org/wiki/Quantum_computing",
}
],
}
with patch(
"local_deep_research.mcp.server.ldr_quick_summary",
return_value=mock_result,
) as mock:
yield mock
@pytest.fixture
def mock_detailed_research():
"""Mock the detailed_research function."""
mock_result = {
"query": "quantum computing applications",
"research_id": "test-research-123",
"summary": "Detailed analysis of quantum computing applications.",
"findings": [
{
"phase": "Iteration 1",
"content": "Quantum computing has applications in cryptography.",
},
{
"phase": "Iteration 2",
"content": "Drug discovery is another major application.",
},
],
"iterations": 2,
"questions": {
0: ["What are quantum computing applications?"],
1: ["How is it used in cryptography?"],
},
"formatted_findings": "## Detailed Findings\n\nCryptography and drug discovery.",
"sources": [
{
"title": "Nature - Quantum Applications",
"link": "https://nature.com/quantum",
},
],
"metadata": {
"timestamp": "2024-01-15T10:30:00Z",
"search_tool": "wikipedia",
"strategy": "source-based",
},
}
with patch(
"local_deep_research.mcp.server.ldr_detailed_research",
return_value=mock_result,
) as mock:
yield mock
@pytest.fixture
def mock_generate_report():
"""Mock the generate_report function."""
mock_result = {
"content": "# Research Report\n\n## Introduction\n\nThis report covers...",
"metadata": {
"generated_at": "2024-01-15T10:30:00Z",
"query": "quantum computing",
},
}
with patch(
"local_deep_research.mcp.server.ldr_generate_report",
return_value=mock_result,
) as mock:
yield mock
@pytest.fixture
def mock_analyze_documents():
"""Mock the analyze_documents function."""
mock_result = {
"summary": "Analysis of documents in the test collection.",
"documents": [
{
"title": "Test Document 1",
"content": "Content of test document 1.",
"link": "/path/to/doc1.pdf",
},
],
"collection": "test_collection",
"document_count": 1,
}
with patch(
"local_deep_research.mcp.server.ldr_analyze_documents",
return_value=mock_result,
) as mock:
yield mock
@pytest.fixture
def mock_settings_snapshot():
"""Mock settings snapshot for configuration tests."""
mock_settings = {
"llm.provider": {"value": "openai"},
"llm.model": {"value": "gpt-4"},
"llm.temperature": {"value": 0.7},
"search.tool": {"value": "searxng"},
"search.search_strategy": {"value": "source-based"},
"search.iterations": {"value": 2},
"search.questions_per_iteration": {"value": 3},
"search.max_results": {"value": 10},
}
with patch(
"local_deep_research.mcp.server.create_settings_snapshot",
return_value=mock_settings,
) as mock:
yield mock
# =============================================================================
# Additional fixtures for edge case and integration tests
# =============================================================================
@pytest.fixture
def sample_long_query():
"""Generate a very long query string (10000+ chars)."""
return (
"What is quantum computing and how does it work? " * 250
) # ~12500 chars
@pytest.fixture
def sample_special_chars_query():
"""Query with unicode, emojis, special characters."""
return "What is 量子计算? 🔬 Test with émojis & spëcial <chars> \"quotes\" 'apostrophes'"
@pytest.fixture
def mock_api_empty_response():
"""Mock API response with missing fields."""
return {}
@pytest.fixture
def mock_api_minimal_response():
"""Mock API response with only required fields."""
return {
"summary": "Minimal response",
}
@pytest.fixture
def mock_api_with_nulls():
"""Mock API response with None values."""
return {
"summary": None,
"findings": None,
"sources": None,
"iterations": None,
}
@pytest.fixture
def mock_comprehensive_research_result():
"""Comprehensive mock research result for integration tests."""
return {
"query": "test query",
"research_id": "integration-test-123",
"summary": "This is a comprehensive test summary with multiple findings.",
"findings": [
{"phase": "Iteration 1", "content": "First finding content"},
{"phase": "Iteration 2", "content": "Second finding content"},
{"phase": "Iteration 3", "content": "Third finding content"},
],
"iterations": 3,
"questions": {
0: ["Question 1?", "Question 2?"],
1: ["Follow-up 1?"],
2: ["Final question?"],
},
"formatted_findings": "## Research Findings\n\n- Finding 1\n- Finding 2\n- Finding 3",
"sources": [
{"title": "Source 1", "link": "https://example.com/1"},
{"title": "Source 2", "link": "https://example.com/2"},
{"title": "Source 3", "link": "https://example.com/3"},
],
"metadata": {
"timestamp": "2024-01-15T12:00:00Z",
"search_tool": "searxng",
"strategy": "source-based",
"duration_seconds": 120,
},
}