diff --git a/tests/test_perm_app.py b/tests/test_perm_app.py index 84262e1..88ca17d 100644 --- a/tests/test_perm_app.py +++ b/tests/test_perm_app.py @@ -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)()