def test_password_must_not_be_blank(self): data = {'password': ''} serializer = PasswordSerializer(data=data) self.assertFalse(serializer.is_valid()) self.assertDictContainsSubset( {'password': ['This field may not be blank.']}, serializer.errors)
def test_password_must_contain_digits(self): data = {'password': '******'} serializer = PasswordSerializer(data=data) self.assertFalse(serializer.is_valid()) self.assertDictContainsSubset( {'password': ['Ensure this field has at least one digit.']}, serializer.errors)
def test_password_must_contain_letters(self): data = {'password': '******'} serializer = PasswordSerializer(data=data) self.assertFalse(serializer.is_valid()) self.assertDictContainsSubset( {'password': ['Ensure this field has at least one latin letter.']}, serializer.errors)
def test_password_must_be_at_least_7_characters_long(self): data = {'password': '******'} serializer = PasswordSerializer(data=data) self.assertFalse(serializer.is_valid()) self.assertDictContainsSubset( {'password': ['Ensure this field has at least 7 characters.']}, serializer.errors)