def test_group_delete_doesnt_affect_user(self): # create group g1 = Group.testing_create() # create user assigned to group and make sure count logic works u = User.testing_create(groups=g1) u1_id = u.id eq_(User.count_by(id=u1_id), 1) # delete group Group.delete(g1.id) # user should still be there eq_(User.count_by(id=u1_id), 1)
def test_group_delete(self): g1 = Group.testing_create() g2 = Group.testing_create() u = User.testing_create(groups=[g1, g2]) eq_(len(u.groups), 2) assert Group.delete(g1.id) eq_(len(g2.users), 1) eq_(len(u.groups), 1) eq_(u.groups[0].id, g2.id) eq_(Group.count(), 1)