'Tests declining an invitation'

def test_decline_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.decline(anon)))
    self.assertRaises(ValueError, (lambda : invitation.decline(admin)))
    invitation.decline(normal)
    self.assert_((not group.user_is_member(normal)))
    self.assert_((invitation.state == 'declined'))
