Skip to content

Commit

Permalink
Test require_group.
Browse files Browse the repository at this point in the history
  • Loading branch information
soasme committed Jan 14, 2016
1 parent fb49ac1 commit 970cb4c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/test_perm_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,22 @@ def test_get_permissions(perm):
assert 'test_perm_app.test_get_permissions' in map(
lambda p: p['code'], perm.get_user_permissions(1))
assert perm.has_permission(1, 'test_perm_app.test_get_permissions')

def test_require_group_passed(perm):
from flask_perm.services import UserGroupService, UserGroupMemberService
user_group = UserGroupService.create(
'Test require_group passed',
'test.require_group_passed',
)
member = UserGroupMemberService.create(user_id=1, user_group_id=user_group.id)
assert perm.require_group('test.require_group_passed')(lambda: True)()

def test_require_group_failed(perm):
from flask_perm.services import UserGroupService, UserGroupMemberService
user_group = UserGroupService.create(
'Test require_group failed',
'test.require_group_failed',
)
member = UserGroupMemberService.create(user_id=2, user_group_id=user_group.id)
with raises(perm.Denied):
assert perm.require_group('test.require_group_passed')(lambda: True)()

0 comments on commit 970cb4c

Please sign in to comment.