mirror of
https://github.com/basicmachines-co/basic-memory
synced 2026-06-21 13:47:35 +00:00
4791e19685
Signed-off-by: phernandez <paul@basicmachines.co> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
34 lines
887 B
Python
34 lines
887 B
Python
"""Telemetry coverage for MCP server lifecycle spans."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from contextlib import contextmanager
|
|
|
|
import pytest
|
|
|
|
from basic_memory.mcp.server import lifespan, mcp
|
|
import basic_memory.mcp.server as server_module
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_mcp_lifespan_wraps_startup_and_shutdown(config_manager) -> None:
|
|
operations: list[tuple[str, dict]] = []
|
|
|
|
@contextmanager
|
|
def fake_operation(name: str, **attrs):
|
|
operations.append((name, attrs))
|
|
yield
|
|
|
|
original_operation = server_module.telemetry.operation
|
|
server_module.telemetry.operation = fake_operation
|
|
try:
|
|
async with lifespan(mcp):
|
|
pass
|
|
finally:
|
|
server_module.telemetry.operation = original_operation
|
|
|
|
assert [name for name, _ in operations] == [
|
|
"mcp.lifecycle.startup",
|
|
"mcp.lifecycle.shutdown",
|
|
]
|