PTHMINT-78: Avoid duplicate taxes when checkout options is autogenerated#29
Merged
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #29 +/- ##
=======================================
Coverage 90.48% 90.48%
=======================================
Files 107 107
Lines 2322 2323 +1
=======================================
+ Hits 2101 2102 +1
Misses 221 221 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…nts/test_integration_orders_components_checkout_options.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…nts/test_integration_orders_components_checkout_options.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull Request Overview
This pull request fixes duplicate tax generation in the generate_from_shopping_cart method by deduplicating tax table selectors and updates tests to ensure proper validation of this behavior.
- Introduced deduplication logic using a set to ensure unique tax table selectors
- Modified existing test to sort tax rules for consistent comparison
- Added new test case to validate duplicate tax table selector handling
Reviewed Changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/multisafepay/api/paths/orders/request/components/checkout_options.py |
Implemented deduplication logic using set comprehension to avoid duplicate tax rules |
tests/multisafepay/integration/api/path/orders/request/components/test_integration_orders_components_checkout_options.py |
Updated existing test with sorting logic and added new test for duplicate tax table selector scenario |
Comments suppressed due to low confidence (1)
tests/multisafepay/integration/api/path/orders/request/components/test_integration_orders_components_checkout_options.py:174
- The test uses identical CartItem objects which may not adequately test the deduplication logic. Consider using different items with the same tax_table_selector to better validate that deduplication works across different products.
name="Geometric Candle Holders",
danielcivit
approved these changes
Jul 24, 2025
danielcivit
approved these changes
Jul 24, 2025
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.
This pull request refines the
generate_from_shopping_cartmethod to handle unique tax table selectors more effectively and updates the corresponding test cases to ensure correctness. The key changes include introducing logic for deduplication of tax table selectors, updating tests to reflect this change, and adding a new test case for scenarios with duplicate tax table selectors.Enhancements to
generate_from_shopping_cart:src/multisafepay/api/paths/orders/request/components/checkout_options.py, src/multisafepay/api/paths/orders/request/components/checkout_options.pyR113-R124).Updates to test cases:
test_generate_from_shopping_cartto sort both the generated and expected tax rules before comparison, ensuring consistent test results regardless of the order of processing (tests/multisafepay/integration/api/path/orders/request/components/test_integration_orders_components_checkout_options.py, tests/multisafepay/integration/api/path/orders/request/components/test_integration_orders_components_checkout_options.pyR63-R79).test_generate_from_shopping_cart_with_items_with_same_tax_table_selector, to validate that duplicate tax table selectors in the shopping cart are correctly handled and result in a single tax rule (tests/multisafepay/integration/api/path/orders/request/components/test_integration_orders_components_checkout_options.py, tests/multisafepay/integration/api/path/orders/request/components/test_integration_orders_components_checkout_options.pyR153-R199).