-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ricky Cook
committed
Jul 13, 2016
1 parent
070cb66
commit e1b66ee
Showing
3 changed files
with
19 additions
and
17 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 |
---|---|---|
|
@@ -20,30 +20,22 @@ def test_add_to_empty(self): | |
assert [role.name for role in user.roles] == ['admin'] | ||
|
||
@pytest.mark.usefixtures('db') | ||
def test_add_multiple(self): | ||
def test_add_multiple(self, role): | ||
""" Add multiple roles to a user with no roles """ | ||
role = Role(name='test') | ||
DB.session.add(role) | ||
DB.session.commit() | ||
|
||
user = User() | ||
rest_set_roles(user, ['admin', 'test']) | ||
assert [role.name for role in user.roles] == ['admin', 'test'] | ||
rest_set_roles(user, ['admin', role.name]) | ||
assert [role.name for role in user.roles] == ['admin', role.name] | ||
|
||
@pytest.mark.usefixtures('db') | ||
def test_set_with_existing(self): | ||
def test_set_with_existing(self, role, user): | ||
""" Set roles on a user with an existing role """ | ||
role = Role(name='test') | ||
user = SECURITY_STATE.datastore.create_user( | ||
email='[email protected]', | ||
) | ||
user.roles.append(Role.query.get(1)) | ||
user.roles.append(role) | ||
DB.session.add(role) | ||
DB.session.add(user) | ||
DB.session.commit() | ||
|
||
rest_set_roles(user, ['test']) | ||
assert [role.name for role in user.roles] == ['test'] | ||
rest_set_roles(user, [role.name]) | ||
assert [role.name for role in user.roles] == [role.name] | ||
|
||
@pytest.mark.usefixtures('db') | ||
def test_add_fake(self): | ||
|
@@ -110,7 +102,6 @@ def test_no_admin_update_roles(self, client, user, role): | |
'roles': [role.name], | ||
}) | ||
|
||
print(response.data) | ||
assert response.status_code == 401 | ||
|
||
DB.session.refresh(user) | ||
|
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