'Test to remove a member from a closed group.'

@patch('mozillians.groups.models.unsubscribe_from_basket_task')
def test_remove_from_closed_group(self, unsubscribe_mock):

    self.group.accepting_new_members = Group.CLOSED
    self.group.save()
    curator = UserFactory()
    user = UserFactory()
    self.group.add_member(user.userprofile)
    self.group.curators.add(curator.userprofile)
    url = reverse('groups:remove_member', args=[self.group.url, user.userprofile.pk, GroupMembership.PENDING], prefix='/fr/')
    with patch('mozillians.groups.models.email_membership_change', autospec=True) as mock_email:
        with self.login(curator) as client:
            response = client.post(url, follow=False)
    eq_(302, response.status_code)
    membership = GroupMembership.objects.get(group=self.group, userprofile=user.userprofile)
    (group_pk, user_pk, old_status, new_status) = mock_email.delay.call_args[0]
    ok_(mock_email.delay.called)
    eq_(membership.status, GroupMembership.PENDING)
    eq_(self.group.pk, group_pk)
    eq_(user.pk, user_pk)
    eq_(old_status, GroupMembership.MEMBER)
    eq_(new_status, GroupMembership.PENDING)
    ok_((not unsubscribe_mock.delay.called))
