Repository navigation
test: cover product pricing, discounts and the buyers count display - #35
Merged
Merged
Conversation
Product's computed properties had no tests. The new store/tests/test_product_pricing.py covers the peso conversion (1 USD = 59.41 PHP) with its thousands separator, rounding to two decimals half up for both the peso price and the discounted price, products with no discount, a 20% and a 100% discount, and the plain, K and M forms of buyers_count_display. Closes nemsu-dev-org#24
Member
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.

Closes #24
Adds
src/store/tests/test_product_pricing.pywith tests for the computed properties ofProduct:price_in_peso_valueand the formattedprice_in_peso, including the thousands separator (₱5,941.00).is_on_saleis false and the discounted price equals the peso price), 20% off, and 100% off.buyers_count_display: plain counts (0, 1, 999), thousands (1.0K,1.5K,25.3K) and millions (1.0M,2.5M).Every expected value is worked out from the rate and the rounding rule, not copied from the output.
How I tested it
python manage.py testfromsrc/, with the same dummy keys as the CI workflow: 19 tests pass (the 10 new ones plus the existing 9).models.pytemporarily (and restored it): a rate of 59.40 fails 4 tests, and rounding down instead of half up fails a test for the peso price and another for the discounted price.Only the test file is added; no application code changes.