-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* use SQL's NOW() fct to log creation of a new user account (validated or not). * at -> on * add new col * adding a new page for admins to easily list all users not yet validated and offer means to delete those * flake8 * fix tests * move DB changes to patch * revert file * no change here * execute merge manually * moving data insertion to test_db_sql patch * account for additional test users
- Loading branch information
Showing
10 changed files
with
129 additions
and
10 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,7 +54,10 @@ def test_get(self): | |
{'email': '[email protected]', 'name': 'Shared'}, | ||
{'email': '[email protected]', 'name': 'Admin'}, | ||
{'email': '[email protected]', 'name': 'Demo'}, | ||
{'email': '[email protected]', 'name': 'Dude'} | ||
{'email': '[email protected]', 'name': 'Dude'}, | ||
{'email': '[email protected]', 'name': 'JustNow'}, | ||
{'email': '[email protected]', 'name': 'Oldie'}, | ||
{'email': '[email protected]', 'name': 'TooLate'} | ||
]} | ||
self.assertEqual(obs, exp) | ||
|
||
|
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 |
---|---|---|
|
@@ -39,7 +39,3 @@ ALTER TABLE qiita.qiita_user | |
ADD creation_timestamp timestamp without time zone DEFAULT NOW(); | ||
|
||
COMMENT ON COLUMN qiita.qiita_user.creation_timestamp IS 'The date the user account was created'; | ||
|
||
-- for testing: provide creation date for one of the existing users | ||
|
||
UPDATE qiita.qiita_user SET creation_timestamp = '2015-12-03 13:52:42.751331-07' WHERE email = '[email protected]'; |
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 |
---|---|---|
|
@@ -925,4 +925,15 @@ INSERT INTO qiita.slurm_resource_allocations(processing_job_id, samples, columns | |
('61da73ff-b4ff-49a1-b775-c6215cfbd291', 231, 107, 2, 'nan', 333544000, 200, '2023-02-17T15:05:17', NULL, NULL), | ||
('6c84dcf1-c5ea-4e69-b17f-d2d5b8d48bdf', 123, 50, 2, 'nan', 327520000, 82, '2023-02-18T15:13:15', NULL, NULL), | ||
('dcb12603-4142-44d1-9a52-3ca3511e380e', 320, 44, 2, 'nan', 329448000, 475, '2023-02-19T06:29:32', NULL, NULL), | ||
('a0dd0a4d-b73f-4e9d-87dd-d29efba25336', 41, 50, 2, 'nan', 301108000, 144, '2023-02-19T09:14:27', NULL, NULL); | ||
('a0dd0a4d-b73f-4e9d-87dd-d29efba25336', 41, 50, 2, 'nan', 301108000, 144, '2023-02-19T09:14:27', NULL, NULL); | ||
|
||
-- for testing: provide creation date for one of the existing users | ||
|
||
UPDATE qiita.qiita_user SET creation_timestamp = '2015-12-03 13:52:42.751331-07' WHERE email = '[email protected]'; | ||
|
||
-- Jun 20, 2024 | ||
-- Add some non-verified users to the test DB to test new admin page: /admin/purge_users/ | ||
|
||
INSERT INTO qiita.qiita_user VALUES ('[email protected]', 5, '$2a$12$gnUi8Qg.0tvW243v889BhOBhWLIHyIJjjgaG6dxuRJkUM8nXG9Efe', 'JustNow', 'NonVeriUser', '1634 Edgemont Avenue', '303-492-1984', NULL, NULL, NULL, false, NULL, NULL, NULL, NOW()); | ||
INSERT INTO qiita.qiita_user VALUES ('[email protected]', 5, '$2a$12$gnUi8Qg.0tvW243v889BhOBhWLIHyIJjjgaG6dxuRJkUM8nXG9Efe', 'Oldie', 'NonVeriUser', '172 New Lane', '102-111-1984', NULL, NULL, NULL, false, NULL, NULL, NULL, NOW() - INTERVAL '1 YEAR'); | ||
INSERT INTO qiita.qiita_user VALUES ('[email protected]', 5, '$2a$12$gnUi8Qg.0tvW243v889BhOBhWLIHyIJjjgaG6dxuRJkUM8nXG9Efe', 'TooLate', 'NonVeriUser', '564 C Street', '508-492-222', NULL, NULL, NULL, false, NULL, NULL, NULL, NOW() - INTERVAL '30 DAY'); |
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
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 |
---|---|---|
|
@@ -9,9 +9,13 @@ | |
from unittest import main | ||
from wtforms.validators import ValidationError | ||
from wtforms import StringField | ||
from mock import Mock | ||
from json import loads | ||
|
||
from qiita_pet.test.tornado_test_base import TestHandlerBase | ||
from qiita_pet.handlers.user_handlers import UserProfile | ||
from qiita_pet.handlers.base_handlers import BaseHandler | ||
from qiita_db.user import User | ||
|
||
|
||
class TestUserProfile(TestHandlerBase): | ||
|
@@ -124,5 +128,32 @@ def test_get(self): | |
self.assertEqual(response.code, 200) | ||
|
||
|
||
class TestPurgeUsersAJAXHandler(TestHandlerBase): | ||
def setUp(self): | ||
super().setUp() | ||
BaseHandler.get_current_user = Mock(return_value=User("[email protected]")) | ||
|
||
def test_get(self): | ||
response = self.get('/admin/purge_usersAjax/?_=1718805487494') | ||
obs_users_table = loads(response.body.decode('ascii')) | ||
obs_users = {user['email'] for user in obs_users_table} | ||
self.assertIn('[email protected]', obs_users) | ||
self.assertIn('[email protected]', obs_users) | ||
self.assertNotIn('[email protected]', obs_users) | ||
|
||
def test_post_removeBoth(self): | ||
# remove both users | ||
response = self.post('/admin/purge_users/', | ||
{'action': 'Remove', | ||
'selected': ['[email protected]', | ||
'[email protected]']}) | ||
self.assertEqual(response.code, 200) | ||
|
||
# test that zero users are listed now | ||
response = self.get('/admin/purge_usersAjax/?_=1718805487495') | ||
obs_users_table = loads(response.body.decode('ascii')) | ||
self.assertEqual(obs_users_table, []) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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