-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from galaxy-genome-annotation/update_email
Improve user update method + add tests
- Loading branch information
Showing
9 changed files
with
208 additions
and
14 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
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 |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = '4.1' | ||
__version__ = '4.2' |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
requests | ||
biopython | ||
cachetools | ||
cachetools<4 | ||
click>=6.7 | ||
wrapt | ||
pyyaml | ||
|
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 |
---|---|---|
@@ -0,0 +1,132 @@ | ||
import time | ||
|
||
from . import ApolloTestCase, wa | ||
|
||
|
||
class UserTest(ApolloTestCase): | ||
|
||
def test_get_users(self): | ||
|
||
users = wa.users.get_users() | ||
|
||
# We at least have admin + junior + temp from setup | ||
assert len(users) >= 3 | ||
|
||
first_user = users[0] | ||
|
||
assert 'firstName' in first_user | ||
assert 'lastName' in first_user | ||
assert 'inactive' in first_user | ||
assert 'role' in first_user | ||
assert 'availableGroups' in first_user | ||
assert 'userCount' in first_user | ||
assert 'searchName' in first_user | ||
assert 'groups' in first_user | ||
assert 'userId' in first_user | ||
assert 'organismPermissions' in first_user | ||
assert 'username' in first_user | ||
|
||
def test_show_user(self): | ||
|
||
users = wa.users.get_users() | ||
|
||
user_id = users[0]['userId'] | ||
|
||
user_info = wa.users.show_user(user_id) | ||
|
||
# userCount changes depending on what was requested to Apollo | ||
del user_info['userCount'] | ||
del users[0]['userCount'] | ||
|
||
assert user_info == users[0] | ||
|
||
def test_create_user(self): | ||
|
||
meta = {"bla": "bli"} | ||
res = wa.users.create_user("[email protected]", 'Poutrelle', 'Lapinou', 'superpassword', role="user", metadata=meta) | ||
self.waitUserCreated(res['userId']) | ||
|
||
res = wa.users.show_user('[email protected]') | ||
|
||
assert res['username'] == '[email protected]' | ||
assert res['firstName'] == 'Poutrelle' | ||
assert res['lastName'] == 'Lapinou' | ||
assert res['role'] == 'USER' | ||
|
||
def test_delete_user(self): | ||
|
||
user_info = wa.users.create_user("[email protected]", 'Tempxx', 'oraryxx', 'coolpasswordxx', role="user") | ||
self.waitUserCreated(user_info['userId']) | ||
|
||
wa.users.delete_user(user_info['username']) | ||
self.waitUserDeleted(user_info['userId']) | ||
|
||
users = wa.users.get_users() | ||
|
||
for user in users: | ||
assert user['username'] != '[email protected]' | ||
|
||
def test_update_user(self): | ||
|
||
user_info = wa.users.create_user("[email protected]", 'Tempxx', 'oraryxx', 'coolpasswordxx', role="user") | ||
self.waitUserCreated(user_info['userId']) | ||
|
||
wa.users.update_user(user_info['username'], 'firstname2', 'lastname2') | ||
|
||
time.sleep(3) | ||
res = wa.users.show_user('[email protected]') | ||
|
||
assert res['username'] == '[email protected]' | ||
assert res['firstName'] == 'firstname2' | ||
assert res['lastName'] == 'lastname2' | ||
assert res['role'] == 'USER' | ||
|
||
def test_update_user_email(self): | ||
|
||
user_info = wa.users.create_user("[email protected]", 'Tempxx', 'oraryxx', 'coolpasswordxx', role="user") | ||
self.waitUserCreated(user_info['userId']) | ||
|
||
wa.users.update_user(user_info['username'], 'firstname2', 'lastname2', new_email='[email protected]') | ||
|
||
time.sleep(3) | ||
res = wa.users.show_user('[email protected]') | ||
|
||
assert res['username'] == '[email protected]' | ||
assert res['firstName'] == 'firstname2' | ||
assert res['lastName'] == 'lastname2' | ||
assert res['role'] == 'USER' | ||
|
||
def setUp(self): | ||
# Make sure the user is not already there | ||
temp_user_info = wa.users.show_user('[email protected]') | ||
if 'username' in temp_user_info: | ||
wa.users.delete_user(temp_user_info['username']) | ||
self.waitUserDeleted(temp_user_info['userId']) | ||
|
||
temp_user_info = wa.users.show_user('[email protected]') | ||
if 'username' in temp_user_info: | ||
wa.users.delete_user(temp_user_info['username']) | ||
self.waitUserDeleted(temp_user_info['userId']) | ||
|
||
temp_user_info = wa.users.show_user('[email protected]') | ||
if 'username' in temp_user_info: | ||
wa.users.delete_user(temp_user_info['username']) | ||
self.waitUserDeleted(temp_user_info['userId']) | ||
|
||
wa.users.create_user("[email protected]", 'Temp', 'orary', 'coolpassword', role="user") | ||
|
||
def tearDown(self): | ||
temp_user_info = wa.users.show_user('[email protected]') | ||
if temp_user_info and 'username' in temp_user_info: | ||
wa.users.delete_user(temp_user_info['username']) | ||
self.waitUserDeleted(temp_user_info['userId']) | ||
|
||
temp_user_info = wa.users.show_user('[email protected]') | ||
if 'username' in temp_user_info: | ||
wa.users.delete_user(temp_user_info['username']) | ||
self.waitUserDeleted(temp_user_info['userId']) | ||
|
||
temp_user_info = wa.users.show_user('[email protected]') | ||
if 'username' in temp_user_info: | ||
wa.users.delete_user(temp_user_info['username']) | ||
self.waitUserDeleted(temp_user_info['userId']) |