def test_validvalues_validate(self):
     schema = {'valid_values': [2, 4, 6, 8]}
     constraint = Constraint('prop', Schema.INTEGER, schema)
     self.assertIsNone(constraint.validate(4))
 def test_max_length_validate(self):
     schema = {'max_length': 4}
     constraint = Constraint('prop', Schema.STRING, schema)
     self.assertIsNone(constraint.validate('abcd'))
     self.assertIsNone(constraint.validate('abc'))
 def test_pattern_validate(self):
     schema = {'pattern': '[0-9]*'}
     constraint = Constraint('prop', Schema.STRING, schema)
     self.assertIsNone(constraint.validate('123'))
 def test_less_or_equal_validate(self):
     schema = {'less_or_equal': 4}
     constraint = Constraint('prop', Schema.INTEGER, schema)
     self.assertIsNone(constraint.validate(4))
     self.assertIsNone(constraint.validate(3))
 def test_less_than_validate(self):
     schema = {'less_than': datetime.date(2014, 0o7, 25)}
     constraint = Constraint('prop', Schema.TIMESTAMP, schema)
     self.assertIsNone(constraint.validate(datetime.date(2014, 0o7, 20)))
     self.assertIsNone(constraint.validate(datetime.date(2014, 0o7, 24)))
 def test_greater_or_equal_validate(self):
     schema = {'greater_or_equal': 3.9}
     constraint = Constraint('prop', Schema.FLOAT, schema)
     self.assertIsNone(constraint.validate(3.9))
     self.assertIsNone(constraint.validate(4.0))
 def test_greater_than_validate(self):
     schema = {'greater_than': 4}
     constraint = Constraint('prop', Schema.INTEGER, schema)
     self.assertIsNone(constraint.validate(6))
 def test_in_range_validate(self):
     schema = {'in_range': [2, 6]}
     constraint = Constraint('prop', Schema.INTEGER, schema)
     self.assertIsNone(constraint.validate(2))
     self.assertIsNone(constraint.validate(4))
     self.assertIsNone(constraint.validate(6))