-
Notifications
You must be signed in to change notification settings - Fork 678
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
Improve testing #688
Improve testing #688
Conversation
for more information, see https://pre-commit.ci
|
||
@override_api_settings(BLACKLIST_AFTER_ROTATION=False) |
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.
Is this really needed since BLACKLIST_AFTER_ROTATION
is default to False
, maybe for explicitly sake.
Ready for review from maintainer! |
# verify last_login is updated | ||
with override_api_settings(UPDATE_LAST_LOGIN=True): | ||
reload(serializers) |
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.
Not sure if reload(serializers)
really needed.
self.assertIsNotNone(user.last_login) | ||
self.assertGreaterEqual(timezone.now(), user.last_login) | ||
|
||
reload(serializers) |
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.
Not sure if reload(serializers)
really needed.
@abczzz13 @Andrew-Chen-Wang need your review sir. |
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.
lgtm
@Andrew-Chen-Wang Could you please review and merge this PR. Thanks in advance! |
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.
Thanks again for this; this makes things cleaner for sure
* 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>
Overview
override_api_settings
so that it support decorator in pythonwith override_api_settings
and use@override_api_settings
insteadUpdate
override_api_settings
so that it support decorator in pythonThis is done by add
try
andfinally
block to existingoverride_api_settings
so that it makes it clearer where is theyield
hence support decoratorBreaks down the tests to be more specific
test_authentication
test_get_header
test_get_header
test_get_header_x_access_token
test_get_raw_token
test_get_raw_token
test_get_raw_token_incorrect_header_keyword
test_get_raw_token_multi_header_keyword
test_get_validated_token
test_get_validated_token
test_get_validated_token_reject_unknown_token
test_get_validated_token_accept_known_token
test_tokens
test_for_user
test_for_user
test_for_user_with_username
test_views
TestTokenObtainPairView.test_update_last_login
test_update_last_login
test_update_last_login_updated
TestTokenRefreshView.test_update_last_login
test_update_last_login
test_update_last_login_updated
Eliminate the use of
with override_api_settings
and use@override_api_settings
insteadMulti-test with
@override_api_settings
decorator Instead of one-test with multiplewith override_api_settings
context managerUse rest_framework.status instead of literal
Use
HTTP_200_OK
instead of200
andHTTP_401_UNAUTHORIZED
instead of401
in test_integration