Пример #1
0
 def test_required_fails(self):
     validator = Validator({})
     self.assert_fails(validator, {"name": "required"})
     self.assertIn("name", validator.errors)
Пример #2
0
 def test_max_length_fails(self):
     validator = Validator(dict(name="Roland"))
     self.assert_fails(validator, {"name": "max_length:3"})
     self.assertIn("name", validator.errors)
Пример #3
0
 def test_max_lenght_passes(self):
     validator = Validator(dict(name="Andela"))
     validator.validate({"name": "max_length:10"})
     self.assertNotIn("name", validator.errors)
Пример #4
0
 def test_lenght_passes(self):
     validator = Validator(dict(name="Roland"))
     validator.validate({"name": "length:6"})
     self.assertNotIn("name", validator.errors)
Пример #5
0
 def test_min_lenght_passes(self):
     validator = Validator(dict(name="Ahimbisibwe Roland"))
     validator.validate({"name": "min_length:10"})
     self.assertNotIn("name", validator.errors)
Пример #6
0
 def test_required_passes(self):
     validator = Validator(dict(name="Roland"))
     validator.validate({"name": "required"})
     self.assertNotIn("name", validator.errors)
Пример #7
0
 def test_validate_confirmed_passed(self):
     validator = Validator(
         dict(password="******", password_confirmation="secret"))
     validator.validate({"password": "******"})
     self.assertNotIn("password", validator.errors)
Пример #8
0
 def test_validate_confirmed_fails(self):
     validator = Validator(
         dict(password="******", password_confirmation="password"))
     self.assert_fails(validator, {"password": "******"})
     self.assertIn("password", validator.errors)
Пример #9
0
 def test_validate_email_passes(self):
     validator = Validator(dict(email="*****@*****.**"))
     validator.validate({"email": "email"})
     self.assertNotIn("email", validator.errors)
Пример #10
0
 def test_validate_email_fails(self):
     validator = Validator(dict(email="some_invald_email"))
     self.assert_fails(validator, {"email": "email"})
     self.assertIn("email", validator.errors)