Skip to content

test: cover report helpers _parse_dedupe_response and litellm routing predicates#597

Open
Rome-1 wants to merge 1 commit into
usestrix:mainfrom
Rome-1:test/report-helpers-coverage
Open

test: cover report helpers _parse_dedupe_response and litellm routing predicates#597
Rome-1 wants to merge 1 commit into
usestrix:mainfrom
Rome-1:test/report-helpers-coverage

Conversation

@Rome-1

@Rome-1 Rome-1 commented Jun 26, 2026

Copy link
Copy Markdown

Adds focused unit tests for three previously-uncovered pure helpers in strix/report/, locking in their string-parsing and routing behavior so future refactors can't silently regress them. tests/test_dedupe_parsing.py exercises strix.report.dedupe._parse_dedupe_response: plain-JSON round-trip, json fenced-block unwrapping, the ValueError("No JSON object found") path when no object is present, duplicate_id truncation to 64 chars, and the non-numeric / null confidence -> 0.0 fallback. tests/test_usage_helpers.py parametrizes strix.report.usage._litellm_model_name (None / "" / whitespace -> None, plain passthrough, litellm/ any-llm/ openai/ prefix stripping, deepseek/ preserved) and _is_litellm_routed (None / plain / openai/ -> False; deepseek/ litellm/ any-llm/ -> True). The tests are pure and offline — no network, no API keys, no Docker, and litellm is never imported (the helpers operate on strings only). These behaviors had zero direct coverage on main.

Testing

  • pytest tests/test_dedupe_parsing.py tests/test_usage_helpers.py -v -> 19 passed in <2s (no network / LLM / Docker).
  • Verified meaningfulness by temporarily mutating the source ([:64] -> [:32] in dedupe; dropping the openai/ special-case in usage): exactly the corresponding assertions failed, and all 19 passed again once the source was restored.
  • ruff check clean; bandit -c pyproject.toml clean; pyupgrade --py310-plus no changes. Note: the repo's pinned pre-commit mypy hook crashes with an internal error on the bundled openai SDK on main as well, so mypy was not run as a gate here; these test files add no new typing surface.

@greptile-apps

greptile-apps Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds 19 focused offline unit tests for three previously-uncovered pure helpers in strix/report/: _parse_dedupe_response in dedupe.py and _litellm_model_name / _is_litellm_routed in usage.py. No application logic is changed.

  • tests/test_dedupe_parsing.py covers plain-JSON round-trip, fenced-block unwrapping, the ValueError path when no JSON object is present, duplicate_id truncation to 64 chars, and non-numeric/null confidence defaulting to 0.0 — each assertion matches the source implementation exactly.
  • tests/test_usage_helpers.py parametrizes both routing helpers across all recognized provider prefixes (litellm/, any-llm/, openai/, deepseek/) as well as None, empty, and whitespace-only inputs, correctly reflecting the asymmetric treatment of openai/.

Confidence Score: 5/5

Pure test addition with no changes to application code — safe to merge.

Both test files are correct against the current source implementations: every parametrized case and assertion was traced through the actual source logic and produces the expected output. No flaky assumptions, no network calls, no mocking gaps.

No files require special attention.

Important Files Changed

Filename Overview
tests/test_dedupe_parsing.py Adds 5 focused unit tests for _parse_dedupe_response covering plain-JSON, fenced-block unwrapping, missing-JSON ValueError, duplicate_id truncation, and non-numeric/null confidence fallback — all assertions verified correct against the source implementation.
tests/test_usage_helpers.py Adds parametrized tests for _litellm_model_name (8 cases) and _is_litellm_routed (6 cases), including None/empty/whitespace inputs and all recognized provider prefixes — all cases verified correct against source logic.

Reviews (1): Last reviewed commit: "test: cover report helpers _parse_dedupe..." | Re-trigger Greptile

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.

1 participant