mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-03 02:22:24 +00:00
test(mcp): carry conformance coverage into stdio peers
This commit is contained in:
parent
4003899c53
commit
7e68b248f8
2 changed files with 30 additions and 1 deletions
|
|
@ -58,7 +58,16 @@ class McpPeer:
|
|||
|
||||
def registration(self) -> dict[str, object]:
|
||||
if self.transport == "stdio":
|
||||
return {"transport": "stdio", "command": self.command, "args": list(self.args)}
|
||||
return {
|
||||
"transport": "stdio",
|
||||
"command": self.command,
|
||||
"args": list(self.args),
|
||||
**(
|
||||
{"env": {"COVERAGE_PROCESS_CONFIG": os.environ["COVERAGE_PROCESS_CONFIG"]}}
|
||||
if os.environ.get("COVERAGE_PROCESS_CONFIG")
|
||||
else {}
|
||||
),
|
||||
}
|
||||
if self.spec_path is not None:
|
||||
return {"transport": "http", "url": self.url, "spec_path": str(self.spec_path)}
|
||||
return {"transport": self.transport, "url": self.url}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,26 @@ async def test_negotiation_records_preserve_the_peer_call_contract(monkeypatch:
|
|||
assert records[0]["negotiation"] == {"requested": "2025-03-26", "returned": "2025-03-26"}
|
||||
|
||||
|
||||
@pytest.mark.parametrize("covered", (False, True))
|
||||
def test_stdio_registration_forwards_only_explicit_coverage(
|
||||
tmp_path: Path, monkeypatch: pytest.MonkeyPatch, covered: bool
|
||||
) -> None:
|
||||
monkeypatch.syspath_prepend(str(Path(__file__).resolve().parents[2]))
|
||||
from integration._support.mcp import stdio_peer
|
||||
|
||||
monkeypatch.delenv("COVERAGE_PROCESS_CONFIG", raising=False)
|
||||
monkeypatch.setenv("OPENAI_API_KEY", "must-not-reach-peer")
|
||||
if covered:
|
||||
monkeypatch.setenv("COVERAGE_PROCESS_CONFIG", "coverage-config")
|
||||
with stdio_peer(tmp_path) as peer:
|
||||
assert peer.registration() == {
|
||||
"transport": "stdio",
|
||||
"command": peer.command,
|
||||
"args": list(peer.args),
|
||||
**({"env": {"COVERAGE_PROCESS_CONFIG": "coverage-config"}} if covered else {}),
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.parametrize("file_backed", (False, True))
|
||||
def test_peer_drain_preserves_received_requests(
|
||||
tmp_path: Path, file_backed: bool, monkeypatch: pytest.MonkeyPatch
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue