示例#1
0
 def test_date_property_validate(self):
     prop = DateProperty(required=True)
     with self.assertRaises(ValidationException) as vm:
         prop.validate(None, 'no_packages')
     self.assertEqual(str(vm.exception),
                      'no_packages: This value is required')
     with self.assertRaises(ValidationException) as vm:
         prop.validate('brains', 'no_packages')
     self.assertEqual(str(vm.exception),
                      'no_packages: This value should be a valid date object.')
示例#2
0
 def test_date_property_validate_default_value(self):
     prop = DateProperty(required=True, default_value=datetime.date.today())
     # Make sure that the default value works
     prop.validate(None, 'no_packages')
     self.assertEqual(prop.get_default_value(), datetime.date.today())
示例#3
0
 def test_date_property_validators_set(self):
     prop = DateProperty()
     self.assertEqual(2, len(prop.validators))