mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-10 22:32:16 +02:00
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.
40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
"""Unset query params must be omitted, not sent as empty strings."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import asyncio
|
|
|
|
import httpx
|
|
|
|
from mcp_server.core.client import SurfSenseClient
|
|
|
|
|
|
def _capture(client: SurfSenseClient) -> dict:
|
|
"""Swap in a mock transport that records the request it receives."""
|
|
seen: dict = {}
|
|
|
|
async def handler(request: httpx.Request) -> httpx.Response:
|
|
seen["url"] = str(request.url)
|
|
seen["params"] = dict(request.url.params)
|
|
return httpx.Response(200, json={"ok": True})
|
|
|
|
client._http = httpx.AsyncClient(
|
|
base_url="http://test/api/v1", transport=httpx.MockTransport(handler)
|
|
)
|
|
return seen
|
|
|
|
|
|
def test_none_params_are_dropped():
|
|
client = SurfSenseClient(
|
|
api_base="http://test/api/v1", timeout=5, fallback_api_key="ss_pat_x"
|
|
)
|
|
seen = _capture(client)
|
|
asyncio.run(
|
|
client.request(
|
|
"GET",
|
|
"/documents",
|
|
params={"workspace_id": 1, "document_types": None, "folder_id": None},
|
|
)
|
|
)
|
|
assert seen["params"] == {"workspace_id": "1"}
|
|
assert "folder_id" not in seen["url"]
|