test: pin null-required_env tolerance + drop unused MINIMAX env clear
Two self-review nits on the prior commit: - Add test_per_model_required_env_null_treated_as_empty_no_auth — pins parser tolerance for YAML 'required_env:' (deserializes to None). The 'or []' fallback handles it, but the behavior wasn't asserted, and a template author who writes 'required_env:' with no value (common YAML mistake) needs the no-auth path, not a confusing TypeError. - Drop the MINIMAX_API_KEY delenv from the explicit-empty test — there's no MINIMAX in any required_env list of that scenario, so the cleanup was dead noise. 78/78 tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
3e5955f04f
commit
fd4b4e0723
@ -428,7 +428,6 @@ def test_per_model_explicit_empty_required_env_means_no_auth(tmp_path, monkeypat
|
||||
without lying in the per-model list. Distinguished from the no-key
|
||||
case via `"required_env" in entry` (key presence, not truthiness)."""
|
||||
monkeypatch.delenv("CLAUDE_CODE_OAUTH_TOKEN", raising=False)
|
||||
monkeypatch.delenv("MINIMAX_API_KEY", raising=False)
|
||||
|
||||
config = make_config(
|
||||
runtime="claude-code",
|
||||
@ -450,6 +449,31 @@ def test_per_model_explicit_empty_required_env_means_no_auth(tmp_path, monkeypat
|
||||
assert not any(issue.title == "Required env" for issue in report.failures)
|
||||
|
||||
|
||||
def test_per_model_required_env_null_treated_as_empty_no_auth(tmp_path, monkeypatch):
|
||||
"""YAML `required_env: null` deserializes to None — the parser falls
|
||||
through to `entry.get("required_env") or []`, so null behaves the
|
||||
same as explicit `[]` (zero-auth). Pins the parser tolerance —
|
||||
template authors who write `required_env:` without a value (common
|
||||
YAML mistake) get the no-auth path, not a confusing TypeError."""
|
||||
monkeypatch.delenv("CLAUDE_CODE_OAUTH_TOKEN", raising=False)
|
||||
|
||||
config = make_config(
|
||||
runtime="claude-code",
|
||||
runtime_config=RuntimeConfig(
|
||||
model="local-llama",
|
||||
required_env=["CLAUDE_CODE_OAUTH_TOKEN"],
|
||||
models=[
|
||||
{"id": "local-llama", "required_env": None}, # null in YAML
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
report = run_preflight(config, str(tmp_path))
|
||||
|
||||
assert report.ok is True
|
||||
assert not any(issue.title == "Required env" for issue in report.failures)
|
||||
|
||||
|
||||
# ---------- Legacy auth_token_file backward compat ----------
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user