|
|
@@ -0,0 +1,41 @@
|
|
|
+"""Test d'integration live pour modx://resource/{id}."""
|
|
|
+
|
|
|
+from __future__ import annotations
|
|
|
+
|
|
|
+import os
|
|
|
+
|
|
|
+import pytest
|
|
|
+from mcp.client.session import ClientSession
|
|
|
+
|
|
|
+from src.server_mcp.resources import _GET_RESOURCE_WHITELIST
|
|
|
+from tests.conftest import read_resource_json
|
|
|
+
|
|
|
+# ID par defaut : Accueil (cf. .cursor/docs/architecture.md)
|
|
|
+DEFAULT_RESOURCE_ID = "10000"
|
|
|
+
|
|
|
+
|
|
|
+@pytest.mark.integration
|
|
|
+@pytest.mark.anyio
|
|
|
+async def test_get_resource_live_via_mcp_client_session(
|
|
|
+ live_mcp_session: ClientSession,
|
|
|
+) -> None:
|
|
|
+ """
|
|
|
+ Parcours complet : ClientSession MCP -> serveur FastMCP -> ClientRest -> API LWE.
|
|
|
+
|
|
|
+ Activation :
|
|
|
+ RUN_INTEGRATION_TESTS=1 uv run pytest tests/test_integration_get_resource.py -v --no-cov
|
|
|
+
|
|
|
+ Optionnel :
|
|
|
+ INTEGRATION_RESOURCE_ID=10000
|
|
|
+ """
|
|
|
+ resource_id = os.getenv("INTEGRATION_RESOURCE_ID", DEFAULT_RESOURCE_ID)
|
|
|
+
|
|
|
+ result = await read_resource_json(
|
|
|
+ live_mcp_session,
|
|
|
+ f"modx://resource/{resource_id}",
|
|
|
+ )
|
|
|
+
|
|
|
+ assert isinstance(result, dict)
|
|
|
+ assert result["id"] == int(resource_id)
|
|
|
+ assert set(result.keys()).issubset(_GET_RESOURCE_WHITELIST)
|
|
|
+ assert "pagetitle" in result or "alias" in result
|