unity-mcp/Server/tests/integration/test_debug_request_context_...

30 lines
813 B
Python
Raw Normal View History

Payload-safe paging for hierarchy/components + safer asset search + docs (#490) * Fix test teardown to avoid dropping MCP bridge CodexConfigHelperTests was calling MCPServiceLocator.Reset() in TearDown, which disposes the active bridge/transport during MCP-driven test runs. Replace with restoring only the mutated service (IPlatformService). * Avoid leaking PlatformService in CodexConfigHelperTests Capture the original IPlatformService before this fixture runs and restore it in TearDown. This preserves the MCP connection safety fix (no MCPServiceLocator.Reset()) while avoiding global state leakage to subsequent tests. * Fix SO MCP tooling: validate folder roots, normalize paths, expand tests; remove vestigial SO tools * Remove UnityMCPTests stress artifacts and ignore Assets/Temp * Ignore UnityMCPTests Assets/Temp only * Clarify array_resize fallback logic comments * Refactor: simplify action set and reuse slash sanitization * Enhance: preserve GUID on overwrite & support Vector/Color types in ScriptableObject tools * Fix: ensure asset name matches filename to suppress Unity warnings * Fix: resolve Unity warnings by ensuring asset name match and removing redundant import * Refactor: Validate assetName, strict object parsing for vectors, remove broken SO logic from ManageAsset * Hardening: reject Windows drive paths; clarify supported asset types * Delete FixscriptableobjecPlan.md * Paginate get_hierarchy and get_components to prevent large payload crashes * dev: add uvx dev-mode refresh + safer HTTP stop; fix server typing eval * Payload-safe paging defaults + docs; harden asset search; stabilize Codex tests * chore: align uvx args + coercion helpers; tighten safety guidance * chore: minor cleanup + stabilize EditMode SO tests
2025-12-29 12:57:57 +08:00
import pytest
def test_debug_request_context_includes_server_diagnostics(monkeypatch):
# Import inside test so stubs in conftest are applied.
import services.tools.debug_request_context as mod
class DummyCtx:
# minimal surface for debug_request_context
request_context = None
session_id = None
client_id = None
def get_state(self, _k):
return None
# Ensure get_package_version is stable for assertion
monkeypatch.setattr(mod, "get_package_version", lambda: "9.9.9-test")
res = mod.debug_request_context(DummyCtx())
assert res.get("success") is True
data = res.get("data") or {}
server = data.get("server") or {}
assert server.get("version") == "9.9.9-test"
assert "cwd" in server
assert "argv" in server