Files
hkuds--deeptutor/tests/cli/test_init_wizard_probe.py
wehub-resource-sync e4dcfc49aa
Tests / Lint and Format (push) Waiting to run
Tests / Web Node Tests (push) Waiting to run
Tests / Import Check (Python 3.11) (push) Waiting to run
Tests / Import Check (Python 3.12) (push) Waiting to run
Tests / Import Check (Python 3.13) (push) Waiting to run
Tests / Import Check (Python 3.14) (push) Waiting to run
Tests / Python Tests (Python 3.11) (push) Blocked by required conditions
Tests / Python Tests (Python 3.12) (push) Blocked by required conditions
Tests / Python Tests (Python 3.13) (push) Blocked by required conditions
Tests / Python Tests (Python 3.14) (push) Blocked by required conditions
Tests / Test Summary (push) Blocked by required conditions
chore: import upstream snapshot with attribution
2026-07-13 13:00:43 +08:00

77 lines
2.0 KiB
Python

from __future__ import annotations
from types import SimpleNamespace
class _FakeClient:
captured: list[dict] = []
def __init__(self, *, timeout: float):
self.timeout = timeout
def __enter__(self):
return self
def __exit__(self, *_args):
return None
def post(self, url: str, *, headers: dict, json: dict):
self.captured.append({"url": url, "headers": headers, "json": json})
return SimpleNamespace(status_code=200, text="")
def test_probe_llm_uses_max_completion_tokens_for_gpt5(monkeypatch) -> None:
from deeptutor_cli import init_wizard
_FakeClient.captured = []
monkeypatch.setattr(init_wizard.httpx, "Client", _FakeClient)
ok, _elapsed_ms, error = init_wizard.probe_llm(
base_url="https://example.test/v1",
api_key="sk-test",
binding="openai",
model="gpt-5-mini",
)
assert ok is True
assert error == ""
body = _FakeClient.captured[0]["json"]
assert body["max_completion_tokens"] == 1
assert "max_tokens" not in body
def test_probe_llm_keeps_max_tokens_for_legacy_chat_models(monkeypatch) -> None:
from deeptutor_cli import init_wizard
_FakeClient.captured = []
monkeypatch.setattr(init_wizard.httpx, "Client", _FakeClient)
init_wizard.probe_llm(
base_url="https://example.test/v1",
api_key="sk-test",
binding="openai",
model="gpt-3.5-turbo",
)
body = _FakeClient.captured[0]["json"]
assert body["max_tokens"] == 1
assert "max_completion_tokens" not in body
def test_probe_llm_keeps_anthropic_native_max_tokens(monkeypatch) -> None:
from deeptutor_cli import init_wizard
_FakeClient.captured = []
monkeypatch.setattr(init_wizard.httpx, "Client", _FakeClient)
init_wizard.probe_llm(
base_url="https://api.anthropic.test/v1",
api_key="sk-test",
binding="anthropic",
model="claude-sonnet-4",
)
body = _FakeClient.captured[0]["json"]
assert body["max_tokens"] == 1
assert "max_completion_tokens" not in body