Add comprehensive unit tests for supermarket receipt functionality #16
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 PR addresses the need for adequate unit test coverage before refactoring by implementing a comprehensive test suite for the supermarket receipt kata Python implementation.
What was added
25 comprehensive test cases covering all existing functionality:
THREE_FOR_TWO,TEN_PERCENT_DISCOUNT,TWO_FOR_AMOUNT,FIVE_FOR_AMOUNTEACHvsKILO)Coverage improvements
Before: 53% overall coverage with only 1 test
After: 99% coverage (171/173 lines covered)
receipt_printer.pyshopping_cart.pymodel_objects.pyreceipt.pyteller.pyTest quality features
Files added
python/tests/test_supermarket.py- Main test suitepython/run_tests.py- Automated test runner with coverage reportingpython/tests/README.md- Complete test documentationUsage
Run tests with coverage:
cd python python run_tests.pyThe test suite now provides a solid safety net for future refactoring, ensuring that any changes maintain existing functionality while enabling confident code improvements.
Note: During testing, documented a potential calculation issue in
TWO_FOR_AMOUNTdiscount logic, but preserved current behavior as requested.Fixes #5.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/repos/sebastianbergmann/exporter/zipball/78c00df8f170e02473b682df15bfcdacc3d32d72/usr/bin/php8.3 -n -c /tmp/XUewwL /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/global-state/zipball/b6781316bdcd28260904e7cc18ec983d0d2ef4f6/usr/bin/php8.3 -n -c /tmp/XUewwL /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5c9eeac41b290a3712d88851518825ad78f45c71/usr/bin/php8.3 -n -c /tmp/XUewwL /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7/usr/bin/php8.3 -n -c /tmp/XUewwL /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/539c6691e0623af6dc6f9c20384c120f963465a0/usr/bin/php8.3 -n -c /tmp/CTp97h /usr/bin/composer install(http block)/usr/bin/php8.3 -n -c /tmp/XUewwL /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/05d5692a7993ecccd56a03e40cd7e5b09b1d404e/usr/bin/php8.3 -n -c /tmp/CTp97h /usr/bin/composer install(http block)/usr/bin/php8.3 -n -c /tmp/XUewwL /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/type/zipball/75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7/usr/bin/php8.3 -n -c /tmp/CTp97h /usr/bin/composer install(http block)/usr/bin/php8.3 -n -c /tmp/XUewwL /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c/usr/bin/php8.3 -n -c /tmp/XUewwL /usr/bin/composer install --no-interaction(http block)If you need me to access, download, or install something from one of these locations, you can either:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.