示例#1
0
 def test_prep_none(self):
     field = models.SmallUUIDField()
     out = field.get_db_prep_value(None, connection=connection)
     self.assertEqual(out, None)
示例#2
0
 def test_form_field(self):
     field = models.SmallUUIDField()
     self.assertIsInstance(field.formfield(), forms.ShortUUIDField)
示例#3
0
 def test_to_python_class_string(self):
     field = models.SmallUUIDField(uuid_class='smalluuid.TypedSmallUUID')
     out = field.to_python('IBNApQOzTHGzdjkSt6t-Jg')
     self.assertIsInstance(out, TypedSmallUUID)
示例#4
0
 def test_prep(self):
     field = models.SmallUUIDField()
     out = field.get_db_prep_value(SmallUUID('IBNApQOzTHGzdjkSt6t-Jg'),
                                   connection=connection)
     self.assertEqual(out, '201340a503b34c71b3763912b7ab7e26')
示例#5
0
 def test_to_python_custom_class(self):
     field = models.SmallUUIDField(uuid_class=TypedSmallUUID)
     out = field.to_python('IBNApQOzTHGzdjkSt6t-Jg')
     self.assertIsInstance(out, TypedSmallUUID)
示例#6
0
 def test_to_python_invalid_value(self):
     field = models.SmallUUIDField()
     self.assertRaises(ValidationError, field.to_python, 'xxx')
示例#7
0
 def test_to_python(self):
     field = models.SmallUUIDField()
     out = field.to_python('IBNApQOzTHGzdjkSt6t-Jg')
     self.assertIsInstance(out, SmallUUID)
示例#8
0
 def test_force_not_unique(self):
     field = models.SmallUUIDField(unique=False)
     self.assertFalse(field.unique)
示例#9
0
 def test_unique_by_default(self):
     field = models.SmallUUIDField()
     self.assertTrue(field.unique)