Add main-passing regression tests#352
Merged
alexmojaki merged 5 commits intomainfrom May 4, 2026
Merged
Conversation
Merged
There was a problem hiding this comment.
Pull request overview
Adds a set of regression tests (extracted from #351) that are intended to already pass on main, covering pricing math parity, usage extraction/parity invariants, update-price JSON payload parsing, bundled JSON payload shape, and stable top-level public exports.
Changes:
- Add pricing calculation regression tests for
ModelPrice.calc_price(cache, audio overlap, request pricing). - Add usage extraction regression tests covering accumulation behavior, ignoring unknown extras, and contradiction handling.
- Add regressions for update-price fetch parsing (provider-array payload), bundled payload shape, and stable
genai_pricestop-level exports.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_update_prices.py | Adds a regression ensuring UpdatePrices.fetch() correctly parses a provider-array JSON payload. |
| tests/test_public_exports.py | Adds a stability test for genai_prices.__all__ and top-level symbol re-exports. |
| tests/test_price_regressions.py | Adds focused regression coverage for ModelPrice pricing decomposition and request pricing behavior. |
| tests/test_lifecycle.py | Adds a regression asserting bundled JSON payloads remain provider-array shaped. |
| tests/test_extract_usage.py | Expands extraction regressions for public parity, mapping accumulation, unknown extras, and contradiction storage until pricing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
alexmojaki
commented
May 4, 2026
| from genai_prices import Usage | ||
| from genai_prices.types import ModelPrice | ||
|
|
||
| pytestmark = pytest.mark.anyio |
| ).calc_price(Usage(input_tokens=1_000, cache_write_tokens=20, cache_read_tokens=30, output_tokens=100)) | ||
|
|
||
| assert price == { | ||
| 'input_price': Decimal('0.0019175'), |
Contributor
Author
There was a problem hiding this comment.
all these assertions need to make it clear where these numbers come from for this test to be readable and useful
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extracts the tests from #351 that are independent of the unit-registry implementation and already pass when run directly on
main.This PR is test-only. It keeps the behavior-changing assertions in #351, including the unpriced-descendant pricing regression and registry-specific export/update checks.
Included here:
Verification:
uv run pytest tests/test_price_regressions.py tests/test_extract_usage.py tests/test_lifecycle.py tests/test_update_prices.pymake testuv run basedpyright