def test_edit_groups(self): group1 = Group.testing_create() group2 = Group.testing_create() u = User.testing_create(groups=group1) eq_(u.groups, [group1]) User.edit(u.id, loginid=u'group-edited-user') eq_(u.groups, [group1]) User.edit(u.id, assigned_groups=group2.id) eq_(u.groups, [group2])
def test_edit_permissions(self): u = User.testing_create( approved_perms=[u'auth-manage', u'prof-test-1'], denied_perms=[u'prof-test-2']) eq_(u.has_permission(u'auth-manage', u'prof-test-1'), True) eq_(u.has_permission(u'prof-test-2'), False) User.edit(u.id, loginid=u'perm-edited-user') eq_(u.has_permission(u'auth-manage', u'prof-test-1'), True) User.edit(u.id, approved_permissions=[ Permission.get_by(name=u'users-test1').id, Permission.get_by(name=u'prof-test-2').id ]) eq_(u.has_permission(u'auth-manage'), False) eq_(u.has_permission(u'prof-test-1'), False) eq_(u.has_permission(u'users-test1'), True) eq_(u.has_permission(u'prof-test-2'), True)