Files
Nathan Esquenazi 7b35133605 test(model-resolver): add regression tests for PR #2473 cross-provider custom model switch
PR #2473 modifies `resolve_model_provider()` — a high-stakes routing
function with 60+ existing regression tests — without adding any tests
of its own. This file pins the new branch's behavior:

  1. The reported failure mode: active=deepseek (which has base_url) +
     model-id with custom-provider prefix routes to the custom provider,
     not the deepseek base_url branch.
  2. Custom entry with no base_url still routes to the custom slug
     (base_url=None).
  3. Unknown slash prefix falls through to existing behavior.
  4. Active provider IS the custom provider (canonicalized via
     _resolve_configured_provider_id to custom:<slug>) — new branch
     fires because prefix != canonical_provider, but routes to the
     same provider correctly.
  5. OpenRouter active provider unaffected (returns at line 1744-1745
     before the new branch).
  6. Portal providers (Nous/OpenCode/NVIDIA) unaffected (returns at
     line 1754-1756 before the new branch).

Plus source-level coverage of the new aliases extraction added to
get_available_models():

  - 'aliases' key present in the return dict
  - aliases read from cfg.model.aliases
  - empty keys/values filtered (`if k and v` guard)
  - malformed (non-dict) aliases handled via try/except + isinstance

These tests use source-string assertions for the get_available_models()
side because the function's caching + config-mtime-reload semantics
are awkward to isolate inside a full-suite run; a behavioral test
that mutates cfg in-memory triggers reload_config() which wipes the
mutation. Source-shape check is sufficient to catch a maintainer
accidentally dropping the aliases key.

Verified:
- tests/test_pr2473_cross_provider_custom_model_switch.py: 10/10 pass
- Full suite: 5748 passed, 0 failed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-17 16:04:12 -07:00
..
2026-05-05 01:51:05 +00:00
2026-04-29 17:42:32 -07:00
2026-04-29 21:34:27 -07:00