SurfSense/surfsense_mcp/tests/test_note_ingestion.py
CREDO23 116291a3b6 refactor(mcp): flatten to mcp_server package, drop src layout
Rename the import package surfsense_mcp -> mcp_server and remove the
src/ layer so the project mirrors the backend's shape (project folder
!= package name, e.g. surfsense_backend/app). Kills the redundant
surfsense_mcp/src/surfsense_mcp nesting.

Distribution name and console command (surfsense-mcp) are unchanged;
only python -m and internal import paths move to mcp_server. Dockerfile
CMD updated; no PYTHONPATH added since the editable install already
makes the package importable.
2026-07-07 20:24:53 +02:00

31 lines
1.1 KiB
Python

"""The note-to-document envelope mapping."""
from __future__ import annotations
from mcp_server.features.knowledge_base.note_ingestion import build_note_document
def test_builds_extension_document_with_content():
doc = build_note_document(
workspace_id=3, title="Meeting notes", content="body", source_url=None
)
assert doc["document_type"] == "EXTENSION"
assert doc["workspace_id"] == 3
entry = doc["content"][0]
assert entry["pageContent"] == "body"
assert entry["metadata"]["VisitedWebPageTitle"] == "Meeting notes"
def test_synthesizes_url_when_none_given():
doc = build_note_document(
workspace_id=1, title="Q3 Plan!", content="x", source_url=None
)
url = doc["content"][0]["metadata"]["VisitedWebPageURL"]
assert url.startswith("https://surfsense.local/mcp-note/q3-plan-")
def test_keeps_provided_source_url():
doc = build_note_document(
workspace_id=1, title="t", content="x", source_url="https://example.com/a"
)
assert doc["content"][0]["metadata"]["VisitedWebPageURL"] == "https://example.com/a"