Improve testing#688
Merged
Andrew-Chen-Wang merged 15 commits intojazzband:masterfrom Jun 21, 2023
Merged
Conversation
for more information, see https://pre-commit.ci
kiraware
commented
Mar 18, 2023
| serializer = TokenVerifySerializer(data={"token": str(refresh_token)}) | ||
| self.assertFalse(serializer.is_valid()) | ||
|
|
||
| @override_api_settings(BLACKLIST_AFTER_ROTATION=False) |
Member
Author
There was a problem hiding this comment.
Is this really needed since BLACKLIST_AFTER_ROTATION is default to False, maybe for explicitly sake.
Member
Author
|
Ready for review from maintainer! |
kiraware
commented
Mar 18, 2023
| def test_update_last_login_updated(self): | ||
| # verify last_login is updated | ||
| with override_api_settings(UPDATE_LAST_LOGIN=True): | ||
| reload(serializers) |
Member
Author
There was a problem hiding this comment.
Not sure if reload(serializers) really needed.
| self.assertIsNotNone(user.last_login) | ||
| self.assertGreaterEqual(timezone.now(), user.last_login) | ||
|
|
||
| reload(serializers) |
Member
Author
There was a problem hiding this comment.
Not sure if reload(serializers) really needed.
Member
Author
|
@abczzz13 @Andrew-Chen-Wang need your review sir. |
Member
Author
|
@Andrew-Chen-Wang Could you please review and merge this PR. Thanks in advance! |
Andrew-Chen-Wang
approved these changes
Jun 21, 2023
Member
Andrew-Chen-Wang
left a comment
There was a problem hiding this comment.
Thanks again for this; this makes things cleaner for sure
mahdirahimi1999
pushed a commit
to mahdirahimi1999/djangorestframework-simplejwt
that referenced
this pull request
Jun 26, 2023
* Support `override_api_settings` as decorator * Update test_authentication * black formatting test_authentication * Use drf status instead of literal status * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update test_integration * Update test_serializers * Update test_integration * Update test_token_blacklist * Update test_tokens * Update test_views * add `setUpTestData` to `TestToken` * fix typo `self` should be `cls` --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
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.
Overview
override_api_settingsso that it support decorator in pythonwith override_api_settingsand use@override_api_settingsinsteadUpdate
override_api_settingsso that it support decorator in pythonThis is done by add
tryandfinallyblock to existingoverride_api_settingsso that it makes it clearer where is theyieldhence support decoratorBreaks down the tests to be more specific
test_authenticationtest_get_headertest_get_headertest_get_header_x_access_tokentest_get_raw_tokentest_get_raw_tokentest_get_raw_token_incorrect_header_keywordtest_get_raw_token_multi_header_keywordtest_get_validated_tokentest_get_validated_tokentest_get_validated_token_reject_unknown_tokentest_get_validated_token_accept_known_tokentest_tokenstest_for_usertest_for_usertest_for_user_with_usernametest_viewsTestTokenObtainPairView.test_update_last_logintest_update_last_logintest_update_last_login_updatedTestTokenRefreshView.test_update_last_logintest_update_last_logintest_update_last_login_updatedEliminate the use of
with override_api_settingsand use@override_api_settingsinsteadMulti-test with
@override_api_settingsdecorator Instead of one-test with multiplewith override_api_settingscontext managerUse rest_framework.status instead of literal
Use
HTTP_200_OKinstead of200andHTTP_401_UNAUTHORIZEDinstead of401in test_integration