Skip to content

test(router): cover configured mode lookup - #39634

Merged
moe-berri merged 1 commit into
litellm_internal_stagingfrom
litellm_fix_router_mode_coverage
Sep 3, 2026
Merged

moe-berri merged 1 commit into
litellm_internal_stagingfrom
litellm_fix_router_mode_coverage

Conversation

@moe-berri

@moe-berri moe-berri commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

How it solves it:

  • Adds direct coverage for configured mode lookup
  • Covers missing, malformed, and wildcard cases

User Flow

Before: a LiteLLM contributor sees the Router coverage check fail after merging #39619

  1. They open the code-quality check for litellm_internal_staging
  2. The Router coverage step fails and names get_configured_mode as untested

After: the same Router coverage check recognizes direct tests and passes

  1. They open the code-quality check for this pull request
  2. The Router coverage step reports untested_perc: 0.0

Relevant issues

Follow-up to #39619

Linear ticket

Pre-Submission checklist

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*, make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to re-request a review after pushing changes)

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Screenshots / Proof of Fix

Before (828d561)

  1. Run .venv/bin/python tests/code_coverage_tests/router_code_coverage.py
  2. It raises Exception: 0.29% of functions in router.py are not tested: ['get_configured_mode']

After (a264c62)

  1. Run .venv/bin/python tests/code_coverage_tests/router_code_coverage.py
  2. It exits successfully with untested_perc: 0.0

Type

✅ Test

Caveats (if any)

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

Note

Low Risk
Test-only changes with no production code modifications.

Overview
Adds direct unit tests for Router.get_configured_mode in test_router.py, addressing Router coverage CI that flagged the method as untested after #39619.

The new cases assert it returns deployment model_info.mode for a concrete model name, returns None for missing deployments or unset mode, does not invoke wildcard pattern routing (patched pattern_router.route), and treats non-string or blank/malformed mode values as absent.

Reviewed by Cursor Bugbot for commit a264c62. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps

greptile-apps Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds direct unit coverage for configured Router mode lookup.

  • Verifies configured, missing, unknown, malformed, and wildcard model cases.
  • Confirms wildcard entries do not invoke pattern routing.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
tests/test_litellm/test_router.py Adds isolated configured-mode lookup tests without introducing a new actionable issue.

Reviews (2): Last reviewed commit: "test(router): cover configured mode look..." | Re-trigger Greptile

Comment thread tests/test_litellm/test_router.py
@codecov

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@moe-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit a264c62. Configure here.

@mateo-berri mateo-berri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@moe-berri
moe-berri merged commit 321636e into litellm_internal_staging Sep 3, 2026
79 of 80 checks passed
@moe-berri
moe-berri deleted the litellm_fix_router_mode_coverage branch September 3, 2026 21:52
pull Bot pushed a commit to chizee/litellm that referenced this pull request Sep 3, 2026
PRs BerriAI#39630 and BerriAI#39634 both added test_get_configured_mode_reads_deployment_model_info
to tests/test_litellm/test_router.py, so the staging tip defines it twice and the
required lint check fails with F811 on every PR synced past 321636e.

Keep the four tests from BerriAI#39634 (mode read, None for unset or unknown, no wildcard
pattern routing, malformed values treated as absent), which subsume the BerriAI#39630 pair,
and delete that pair. Five hand-applied mutations of Router.get_configured_mode are
all still killed by the surviving tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants