-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: fixed basket deletion issue #3102
Merged
+86
−85
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
22da2d2
fix: fixed basket deletion issue
Anas12091101 1db7b54
refactor: some changes to code
Anas12091101 3fcb933
fix: formatting issues
Anas12091101 56e61f7
refactor: expired basket test
Anas12091101 653b552
fix: tests
Anas12091101 4d7efc2
fix: test
Anas12091101 6e67f59
fix: some code suggestions
Anas12091101 8e3d534
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,13 @@ | ||
"""Ecommerce Tasks Tests""" | ||
|
||
import datetime | ||
|
||
from django.conf import settings | ||
|
||
from ecommerce import tasks | ||
|
||
|
||
def test_delete_expired_baskets(mocker, user, basket_and_coupons): | ||
def test_delete_expired_baskets(mocker): | ||
"""Test that the expired baskets are deleted on task run""" | ||
patched_clear_and_delete_baskets = mocker.patch( | ||
"ecommerce.tasks.clear_and_delete_baskets" | ||
) | ||
|
||
basket_and_coupons.basket.user = user | ||
basket_and_coupons.basket.save() | ||
|
||
now_in_utc = mocker.patch("ecommerce.tasks.now_in_utc") | ||
now_in_utc.return_value = datetime.datetime.now( | ||
tz=datetime.timezone.utc | ||
) + datetime.timedelta(days=settings.BASKET_EXPIRY_DAYS) | ||
|
||
tasks.delete_expired_baskets.delay() | ||
|
||
patched_clear_and_delete_baskets.assert_called_once_with(mocker.ANY) | ||
assert ( | ||
patched_clear_and_delete_baskets.call_args[0][0][0] == basket_and_coupons.basket | ||
) | ||
|
||
|
||
def test_active_baskets_are_not_deleted(mocker, user, basket_and_coupons): | ||
"""Test that the active baskets are not deleted on task run""" | ||
patched_clear_and_delete_baskets = mocker.patch( | ||
"ecommerce.tasks.clear_and_delete_baskets" | ||
) | ||
|
||
basket_and_coupons.basket.user = user | ||
basket_and_coupons.basket.save() | ||
|
||
mocker.patch("django.conf.settings.BASKET_EXPIRY_DAYS", 15) | ||
|
||
tasks.delete_expired_baskets.delay() | ||
patched_clear_and_delete_baskets.assert_not_called() | ||
patched_clear_and_delete_baskets.assert_called_once_with() |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made some tweaks to this method for you. These changes should make it simpler. You should be able to replace this whole method with