'Tests accepting an invitation'

def test_accept_invitation(self):

    anon = get_anonymous_user()
    normal = get_user_model().objects.get(username='norman')
    admin = get_user_model().objects.get(username='admin')
    group = GroupProfile.objects.get(slug='bar')
    group.invite(normal, admin, role='member', send=False)
    invitation = GroupInvitation.objects.get(user=normal, from_user=admin, group=group)
    self.assertRaises(ValueError, (lambda : invitation.accept(anon)))
    self.assertRaises(ValueError, (lambda : invitation.accept(admin)))
    invitation.accept(normal)
    self.assert_(group.user_is_member(normal))
    self.assert_((invitation.state == 'accepted'))
