示例#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)