-
Notifications
You must be signed in to change notification settings - Fork 1.9k
test:Add Integration tests for account delete functions #6108
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import unittest | ||
| from app import current_app as app | ||
| from tests.all.integration.auth_helper import create_user | ||
| from app.api.helpers.user import modify_email_for_user_to_be_deleted, \ | ||
| modify_email_for_user_to_be_restored | ||
| from app.api.helpers.db import save_to_db | ||
| from app.api.helpers.exceptions import ForbiddenException | ||
|
|
||
| from tests.all.integration.utils import OpenEventTestCase | ||
| from tests.all.integration.setup_database import Setup | ||
|
|
||
|
|
||
| class TestUserUtilitiesHelper(OpenEventTestCase): | ||
iamareebjamal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| def setUp(self): | ||
| self.app = Setup.create_app() | ||
|
|
||
| def test_modify_email_for_user_to_be_deleted(self): | ||
| """Method to test modification of email for user to be deleted""" | ||
|
|
||
| with app.test_request_context(): | ||
iamareebjamal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| user = create_user(email="[email protected]", password="testpass") | ||
| save_to_db(user) | ||
| modified_user = modify_email_for_user_to_be_deleted(user) | ||
| self.assertEqual("[email protected]", modified_user.email) | ||
|
|
||
| def test_modify_email_for_user_to_be_restored(self): | ||
iamareebjamal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| """Method to test modification of email for user to be restored""" | ||
|
|
||
| with app.test_request_context(): | ||
| user = create_user(email="[email protected]", password="testpass") | ||
| save_to_db(user) | ||
| modified_user = modify_email_for_user_to_be_restored(user) | ||
| self.assertEqual("[email protected]", modified_user.email) | ||
|
|
||
| user1 = create_user(email="[email protected]", password="testpass") | ||
| save_to_db(user1) | ||
| user2 = create_user(email="[email protected]", password="testpass") | ||
| save_to_db(user2) | ||
| self.assertRaises(ForbiddenException, modify_email_for_user_to_be_restored, user2) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The tests LGTM 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @shreyanshdwivedi yes, that's how There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool. Approving |
||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| unittest.main() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. undefined name 'unittest' |
||
Uh oh!
There was an error while loading. Please reload this page.