コード例 #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)