'Tests contents of reset password email, and that user is not active'

@unittest.skipUnless((settings.ROOT_URLCONF == 'lms.urls'), 'Test    only    valid    in    LMS')
@patch('django.core.mail.send_mail')
@patch('student.views.render_to_string', Mock(side_effect=mock_render_to_string, autospec=True))
def test_reset_password_email(self, send_email):

    good_req = self.request_factory.post('/password_reset/', {'email': self.user.email})
    good_req.user = self.user
    dop_client = ClientFactory()
    dop_access_token = AccessTokenFactory(user=self.user, client=dop_client)
    RefreshTokenFactory(user=self.user, client=dop_client, access_token=dop_access_token)
    dot_application = dot_factories.ApplicationFactory(user=self.user)
    dot_access_token = dot_factories.AccessTokenFactory(user=self.user, application=dot_application)
    dot_factories.RefreshTokenFactory(user=self.user, application=dot_application, access_token=dot_access_token)
    good_resp = password_reset(good_req)
    self.assertEquals(good_resp.status_code, 200)
    self.assertFalse(dop_models.AccessToken.objects.filter(user=self.user).exists())
    self.assertFalse(dop_models.RefreshToken.objects.filter(user=self.user).exists())
    self.assertFalse(dot_models.AccessToken.objects.filter(user=self.user).exists())
    self.assertFalse(dot_models.RefreshToken.objects.filter(user=self.user).exists())
    obj = json.loads(good_resp.content)
    self.assertEquals(obj, {'success': True, 'value': "('registration/password_reset_done.html',    [])"})
    (subject, msg, from_addr, to_addrs) = send_email.call_args[0]
    self.assertIn('Password    reset', subject)
    self.assertIn("You're    receiving    this    e-mail    because    you    requested    a    password    reset", msg)
    self.assertEquals(from_addr, configuration_helpers.get_value('email_from_address', settings.DEFAULT_FROM_EMAIL))
    self.assertEquals(len(to_addrs), 1)
    self.assertIn(self.user.email, to_addrs)
    self.assert_event_emitted(SETTING_CHANGE_INITIATED, user_id=self.user.id, setting=u'password', old=None, new=None)
    self.user = User.objects.get(pk=self.user.pk)
    self.assertFalse(self.user.is_active)
    re.search('password_reset_confirm/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/', msg).groupdict()
