-
Notifications
You must be signed in to change notification settings - Fork 823
WIP: Add test for cleartokens management command. #1084
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1084 +/- ##
==========================================
+ Coverage 96.64% 96.99% +0.34%
==========================================
Files 31 31
Lines 1761 1761
==========================================
+ Hits 1702 1708 +6
+ Misses 59 53 -6
Continue to review full report at Codecov.
|
| application=app, | ||
| expires=later, | ||
| redirect_uri="https://localhost/redirect", | ||
| ) |
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.
lint not running?
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.
It's what black appears to want. I always run tox -e flake8 before committing. Also the pre-commit hooks do that as well I believe.
Also, what specifically did you see there that caused you to ask?
| new = AccesstokenModel.objects.create(token="current access token {}".format(i), expires=later) | ||
| # make half of these Access Tokens have related Refresh Tokens, which prevent their deletion. | ||
| if i % 2: | ||
| RefreshtokenModel.objects.create( |
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.
Use bulk_create. Use list comprehensions with RefreshtokenModel(...) and run RefreshtokenModel.objects.bulk_create The order in id increment should remain the same.
tests/test_commands.py
Outdated
|
|
||
| Application = get_application_model() | ||
| AccesstokenModel = get_access_token_model() | ||
| RefreshtokenModel = get_refresh_token_model() |
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.
| RefreshtokenModel = get_refresh_token_model() | |
| RefreshTokenModel = get_refresh_token_model() |
camel case
tests/test_commands.py
Outdated
|
|
||
|
|
||
| Application = get_application_model() | ||
| AccesstokenModel = get_access_token_model() |
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.
| AccesstokenModel = get_access_token_model() | |
| AccessTokenModel = get_access_token_model() |
camel case
| self.assertEqual(RefreshtokenModel.objects.count(), 100) | ||
| self.assertEqual(GrantModel.objects.count(), 200) | ||
| call_command( | ||
| "cleartokens", |
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.
lint?
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 blame black although this was me:-)
|
On second thought clear_tokens is already tested in test_models so maybe just Might want to enhance the tests there though.... |
Co-authored-by: Andrew Chen Wang <60190294+Andrew-Chen-Wang@users.noreply.github.com>
Co-authored-by: Andrew Chen Wang <60190294+Andrew-Chen-Wang@users.noreply.github.com>
|
@auvipy please stop pushing commits |
|
Closing in lieu of the simpler approach mentioned above. |
Fixes #1065
Description of the Change
Add test for cleartokens command
Checklist
CHANGELOG.mdupdated (only for user relevant changes)AUTHORS