Added a test for password_changed() with a custom validator.

This commit is contained in:
Alexey 2018-09-19 12:03:02 +01:00 committed by Tim Graham
parent 553c24018e
commit 8624459586
1 changed files with 12 additions and 0 deletions

View File

@ -57,6 +57,18 @@ class PasswordValidationTest(TestCase):
def test_password_changed(self):
self.assertIsNone(password_changed('password'))
def test_password_changed_with_custom_validator(self):
class Validator:
def password_changed(self, password, user):
self.password = password
self.user = user
user = object()
validator = Validator()
password_changed('password', user=user, password_validators=(validator,))
self.assertIs(validator.user, user)
self.assertEqual(validator.password, 'password')
def test_password_validators_help_texts(self):
help_texts = password_validators_help_texts()
self.assertEqual(len(help_texts), 2)