mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-01 02:02:20 +00:00
fix(mcp): isolate helper coverage from test proxy startup
This commit is contained in:
parent
cc71b56d1d
commit
6c46f8f651
3 changed files with 31 additions and 1 deletions
|
|
@ -103,6 +103,8 @@ def owned_proxy_process(
|
|||
"LITELLM_MASTER_KEY": gateway.key,
|
||||
"LITELLM_SALT_KEY": os.environ.get("LITELLM_SALT_KEY", "sk-integration-salt"),
|
||||
"STORE_MODEL_IN_DB": "True",
|
||||
"COVERAGE_PROCESS_CONFIG": "",
|
||||
"COVERAGE_PROCESS_START": "",
|
||||
**overrides,
|
||||
}
|
||||
output: Final = Path(os.environ.get("INTEGRATION_RESULTS_DIR", str(directory)))
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ branch = true
|
|||
parallel = true
|
||||
relative_files = true
|
||||
patch = ["subprocess"]
|
||||
include = ["tests/integration/_support/conformance.py"]
|
||||
include = ["tests/integration/_support/conformance.py", "tests/integration/_support/process.py"]
|
||||
|
||||
[tool.coverage.report]
|
||||
show_missing = true
|
||||
|
|
|
|||
|
|
@ -1,13 +1,41 @@
|
|||
import hashlib
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
from typing import Final
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
import pytest
|
||||
from tests.integration._support.conformance import read_checks, verify_archive, prefixed_request
|
||||
from pydantic import ValidationError
|
||||
|
||||
|
||||
@pytest.mark.parametrize("explicit", (False, True))
|
||||
def test_owned_proxy_isolates_automatic_coverage_unless_requested(
|
||||
tmp_path: Path, monkeypatch: pytest.MonkeyPatch, explicit: bool
|
||||
) -> None:
|
||||
from integration._support.client import Gateway
|
||||
from integration._support.process import owned_proxy_process
|
||||
|
||||
monkeypatch.setenv("COVERAGE_PROCESS_CONFIG", "parent-config")
|
||||
monkeypatch.setenv("COVERAGE_PROCESS_START", "parent.toml")
|
||||
overrides: Final = {"COVERAGE_PROCESS_CONFIG": "child-config"} if explicit else {}
|
||||
gateway: Final = Gateway(Mock(), "owner-key", "http://upstream")
|
||||
with (
|
||||
patch("integration._support.process.subprocess.Popen") as spawn,
|
||||
patch("integration._support.process.httpx.Client") as client,
|
||||
patch("integration._support.process.group_members", return_value=()),
|
||||
):
|
||||
spawn.return_value.poll.return_value = None
|
||||
client.return_value.__enter__.return_value.get.return_value.status_code = 200
|
||||
with owned_proxy_process(gateway, tmp_path, overrides):
|
||||
child: Final = spawn.call_args.kwargs["env"]
|
||||
assert child["COVERAGE_PROCESS_CONFIG"] == ("child-config" if explicit else "")
|
||||
assert child["COVERAGE_PROCESS_START"] == ""
|
||||
assert child["LITELLM_MASTER_KEY"] == gateway.key
|
||||
assert os.environ["COVERAGE_PROCESS_CONFIG"] == "parent-config"
|
||||
|
||||
|
||||
def test_changed_archive_is_rejected(tmp_path: Path) -> None:
|
||||
archive: Final = tmp_path / "reference.tar.gz"
|
||||
archive.write_bytes(b"changed reference")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue