def add_group(db_session, group_name="group", description="desc"): group = Group(group_name=group_name, description=description) test_perm = GroupPermission(perm_name="manage_apps") group.permissions.append(test_perm) db_session.add(group) db_session.flush() return group
def add_group(db_session, group_name='group', description='desc'): group = Group(group_name=group_name, description=description) test_perm = GroupPermission(perm_name='manage_apps') group.permissions.append(test_perm) db_session.add(group) db_session.flush() return group
def test_by_group_and_perm(self, db_session): add_group(db_session, ) queried = GroupPermission.by_group_and_perm(1, 'manage_apps', db_session=db_session) assert queried.group_id == 1 assert queried.perm_name == 'manage_apps'
def test_by_group_and_perm_wrong_perm(self, db_session): add_group(db_session, ) queried = GroupPermission.by_group_and_perm(1, 'wrong_perm', db_session=db_session) assert queried is None
def test_by_group_and_perm_wrong_group(self, db_session): add_group(db_session, ) queried = GroupPermission.by_group_and_perm(2, 'manage_apps', db_session=db_session) assert queried is None
def test_repr(self, db_session): group_permission = GroupPermission(group_id=1, perm_name='perm') assert repr(group_permission) == '<GroupPermission: perm>'
def test_by_group_and_perm_wrong_perm(self, db_session): add_group(db_session, ) queried = GroupPermission.by_group_and_perm(1, 'wrong_perm', db_session=db_session) assert queried is None
def test_by_group_and_perm_wrong_group(self, db_session): add_group(db_session, ) queried = GroupPermission.by_group_and_perm(2, 'manage_apps', db_session=db_session) assert queried is None
def test_by_group_and_perm(self, db_session): add_group(db_session, ) queried = GroupPermission.by_group_and_perm(1, 'manage_apps', db_session=db_session) assert queried.group_id == 1 assert queried.perm_name == 'manage_apps'
def test_repr(self, db_session): group_permission = GroupPermission(group_id=1, perm_name="perm") assert repr(group_permission) == "<GroupPermission: perm>"