def test_passwords_dont_match(self):
        # Test that two passwords do not match.
        passwords = {"password": self.get_test_password(), "confirm_password": self.get_test_password()}

        form = ResetPasswordForm(passwords)
        self.assertFalse(form.is_valid())
        self.assertEqual(form["confirm_password"].errors, [u"The two passwords do not match."])
 def test_success(self):
     # Test that form is valid with correct passwords.
     password = self.get_test_password()
     passwords = {
         'password': password,
         'confirm_password': password
     }
     form = ResetPasswordForm(passwords)
     self.assertTrue(form.is_valid())
    def test_password_length(self):
        # Test that password length is valid.
        password = self.get_test_password(4)
        passwords = {"password": password, "confirm_password": password}

        form = ResetPasswordForm(passwords)
        self.assertFalse(form.is_valid())
        self.assertEqual(
            form["password"].errors, [u"Ensure this value has at least 5 characters (it has %d)." % len(password)]
        )
    def test_passwords_dont_match(self):
        # Test that two passwords do not match.
        passwords = {
            'password': self.get_test_password(),
            'confirm_password': self.get_test_password()
        }

        form = ResetPasswordForm(passwords)
        self.assertFalse(form.is_valid())
        self.assertEqual(form['confirm_password'].errors,
                         [u'The two passwords do not match.'])