Ejemplo n.º 1
0
def test_get_permissions(perm):
    from flask_perm.services import PermissionService, UserPermissionService
    permission = PermissionService.create(
        'Test get_permissions passed', 'test_perm_app.test_get_permissions')
    UserPermissionService.create(user_id=1, permission_id=permission.id)

    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')
Ejemplo n.º 2
0
def test_get_require_permission_passed(perm):
    from flask_perm.services import PermissionService, UserPermissionService
    permission = PermissionService.create(
        'Test get_require_permission passed',
        'test.get_require_permission.passed'
    )
    UserPermissionService.create(user_id=1, permission_id=permission.id)

    g.user = {'id': 1, 'is_allowed': False}
    assert perm.require_permission('test.get_require_permission.passed')(lambda: True)()
Ejemplo n.º 3
0
def test_get_permissions(perm):
    from flask_perm.services import PermissionService, UserPermissionService
    permission = PermissionService.create(
        'Test get_permissions passed',
        'test_perm_app.test_get_permissions'
    )
    UserPermissionService.create(user_id=1, permission_id=permission.id)

    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')
Ejemplo n.º 4
0
def test_get_require_permission_passed(perm):
    from flask_perm.services import PermissionService, UserPermissionService
    permission = PermissionService.create(
        'Test get_require_permission passed',
        'test.get_require_permission.passed')
    UserPermissionService.create(user_id=1, permission_id=permission.id)

    g.user = {'id': 1, 'is_allowed': False}
    assert perm.require_permission('test.get_require_permission.passed')(
        lambda: True)()
    assert perm.require_permission_in_template(
        'test.get_require_permission.passed')