-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create users if not found. * Do not fail is user is a duplicate. * Make endpoint faster.
- Loading branch information
Showing
2 changed files
with
81 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -354,14 +354,17 @@ def test_update_role_do_not_exist(self): | |
if update_role: | ||
db.session.delete(update_role) | ||
db.session.commit() | ||
with self.assertRaises(AttributeError): | ||
self.get_resp( | ||
'/superset/update_role/', | ||
data=json.dumps({ | ||
'usernames': ['gamma'], | ||
'role_name': update_role_str, | ||
}) | ||
) | ||
data = json.dumps({ | ||
'users': [{ | ||
'username': 'gamma', | ||
'first_name': 'Gamma', | ||
'last_name': 'Gamma', | ||
'email': '[email protected]', | ||
}], | ||
'role_name': update_role_str}) | ||
r = self.client.post('/superset/update_role/', data=data, | ||
follow_redirects=True) | ||
self.assertEquals(500, r.status_code) | ||
|
||
def test_update_role(self): | ||
update_role_str = 'update_me' | ||
|
@@ -370,7 +373,12 @@ def test_update_role(self): | |
resp = self.client.post( | ||
'/superset/update_role/', | ||
data=json.dumps({ | ||
'usernames': ['gamma'], | ||
'users': [{ | ||
'username': 'gamma', | ||
'first_name': 'Gamma', | ||
'last_name': 'Gamma', | ||
'email': '[email protected]' | ||
}], | ||
'role_name': update_role_str | ||
}), | ||
follow_redirects=True | ||
|
@@ -383,17 +391,34 @@ def test_update_role(self): | |
resp = self.client.post( | ||
'/superset/update_role/', | ||
data=json.dumps({ | ||
'usernames': ['alpha', 'unknown'], | ||
'users': [{ | ||
'username': 'alpha', | ||
'first_name': 'Alpha', | ||
'last_name': 'Alpha', | ||
'email': '[email protected]' | ||
}, { | ||
'username': 'unknown', | ||
'first_name': 'Unknown1', | ||
'last_name': 'Unknown2', | ||
'email': '[email protected]' | ||
}], | ||
'role_name': update_role_str | ||
}), | ||
follow_redirects=True | ||
) | ||
self.assertEquals(resp.status_code, 201) | ||
update_role = sm.find_role(update_role_str) | ||
self.assertEquals( | ||
update_role.user, [sm.find_user(username='alpha')]) | ||
|
||
update_role.user, [ | ||
sm.find_user(username='alpha'), | ||
sm.find_user(username='unknown'), | ||
]) | ||
unknown = sm.find_user(username='unknown') | ||
self.assertEquals('Unknown2', unknown.last_name) | ||
self.assertEquals('Unknown1', unknown.first_name) | ||
self.assertEquals('[email protected]', unknown.email) | ||
db.session.delete(update_role) | ||
db.session.delete(unknown) | ||
db.session.commit() | ||
|
||
|
||
|