示例#1
0
 def test_datetime_property_validate_default_value(self):
     prop = DateTimeProperty(
         required=True,
         default_value=datetime.datetime.now())
     # Make sure that the default value works
     prop.validate(None, 'no_packages')
     self.assertEqual(type(prop.get_default_value()), datetime.datetime)
示例#2
0
 def test_datetime_property_validate(self):
     prop = DateTimeProperty(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 datetime object.')