def test_username_not_exist(self):
     # Test that user with this username is not registered.
     username = faker.internet.user_name()
     form = InitResetPasswordForm({'username_or_email': username})
     self.assertFalse(form.is_valid())
     self.assertEqual(
         form['username_or_email'].errors,
         [u'User account with this username is not registered. <a href="#">Register now.</a>']
     )
 def test_email_not_exist(self):
     # Test that user with this email is not registered.
     data = self.get_test_userdata()
     form_data = {'username_or_email': data['email']}
     form = InitResetPasswordForm(form_data)
     self.assertFalse(form.is_valid())
     self.assertEqual(
         form['username_or_email'].errors,
         [u'User account with this email is not registered. <a href="#">Register now.</a>']
     )
 def test_success_with_username(self):
     # Test that form is valid with correct username.
     email = 'testuser'
     form = InitResetPasswordForm({'username_or_email': email})
     self.assertTrue(form.is_valid())
 def test_success_with_email(self):
     # Test that form is valid with correct email.
     email = '*****@*****.**'
     form = InitResetPasswordForm({'username_or_email': email})
     self.assertTrue(form.is_valid())