7a0da7932b
Backwards Compatibility / Verify Encryption Constants (push) Waiting to run
Backwards Compatibility / PyPI Version Compatibility (push) Waiting to run
Backwards Compatibility / Database Migration Tests (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
CodeQL Advanced / Analyze (python) (push) Waiting to run
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-form] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-metrics] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-workflow] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-core] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-pages] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [history-news] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [library] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [link-analytics] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [mobile] (push) Blocked by required conditions
Docker Tests (Consolidated) / detect-changes (push) Waiting to run
Docker Tests (Consolidated) / Build Test Image (push) Waiting to run
Docker Tests (Consolidated) / All Pytest Tests + Coverage (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [accessibility] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [api-crud] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-login] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-pages] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-register] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-core] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-lifecycle] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [error-benchmark] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) (push) Blocked by required conditions
Docker Tests (Consolidated) / Accessibility Tests (push) Blocked by required conditions
Docker Tests (Consolidated) / LLM Unit Tests (push) Blocked by required conditions
Docker Tests (Consolidated) / LLM Example Tests (push) Blocked by required conditions
Docker Tests (Consolidated) / Production Image Smoke Test (push) Blocked by required conditions
Docker Tests (Consolidated) / Infrastructure Tests (push) Blocked by required conditions
OSSF Scorecard / OSSF Security Scorecard Analysis (push) Waiting to run
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
47 lines
1.7 KiB
Python
47 lines
1.7 KiB
Python
"""Contract tests for the programmatic SDK report entry point (#3665).
|
|
|
|
Mirrors the MCP ``generate_report`` contract test: the SDK
|
|
``generate_report`` returns the in-memory report generator's assembled
|
|
``content`` verbatim — including the ``## Sources`` block — without a DB
|
|
read or any stripping. Pins the SDK-keeps-assembled-shape invariant the
|
|
audit confirmed.
|
|
"""
|
|
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
import local_deep_research.api.research_functions as rf
|
|
|
|
|
|
def test_generate_report_content_includes_sources():
|
|
assembled = (
|
|
"# Research Report\n\n## Introduction\n\nBody text.\n\n"
|
|
"## Sources\n\n[1] https://src.example\n\n"
|
|
"## Research Metrics\n\nSearch Iterations: 2\n"
|
|
)
|
|
|
|
fake_system = MagicMock()
|
|
fake_system.analyze_topic.return_value = {"findings": "x"}
|
|
|
|
fake_generator = MagicMock()
|
|
fake_generator.generate_report.return_value = {
|
|
"content": assembled,
|
|
"metadata": {"query": "q"},
|
|
}
|
|
|
|
# Mock the research pipeline so no real search/LLM work runs; the SDK must
|
|
# pass the generator's assembled content straight through.
|
|
with (
|
|
patch.object(rf, "_init_search_system", return_value=fake_system),
|
|
patch.object(
|
|
rf, "IntegratedReportGenerator", return_value=fake_generator
|
|
),
|
|
patch.object(rf, "_close_system"),
|
|
):
|
|
result = rf.generate_report(query="q", settings_snapshot={})
|
|
|
|
assert "content" in result
|
|
# Verbatim passthrough: the SDK returns the generator's assembled content
|
|
# unmodified. Full equality catches truncation/stripping, not just the
|
|
# absence of the ## Sources header.
|
|
assert result["content"] == assembled
|