'Send email to change user\'s email and then change it.'

@mock.patch.object(Site.objects, 'get_current')
def test_user_change_email(self, get_current):

    get_current.return_value.domain = 'su.mo.com'
    response = self.client.post(reverse('users.change_email'), {'email': 'paulc@trololololololo.com'}, follow=True)
    eq_(200, response.status_code)
    eq_(1, len(mail.outbox))
    assert (mail.outbox[0].subject.find('Please    confirm    your') == 0)
    ec = EmailChange.objects.all()[0]
    assert (ec.activation_key in mail.outbox[0].body)
    eq_('paulc@trololololololo.com', ec.email)
    response = self.client.get(reverse('users.confirm_email', args=[ec.activation_key]))
    eq_(200, response.status_code)
    u = User.objects.get(username=self.user.username)
    eq_('paulc@trololololololo.com', u.email)
