def test_prep_none(self): field = models.SmallUUIDField() out = field.get_db_prep_value(None, connection=connection) self.assertEqual(out, None)
def test_form_field(self): field = models.SmallUUIDField() self.assertIsInstance(field.formfield(), forms.ShortUUIDField)
def test_to_python_class_string(self): field = models.SmallUUIDField(uuid_class='smalluuid.TypedSmallUUID') out = field.to_python('IBNApQOzTHGzdjkSt6t-Jg') self.assertIsInstance(out, TypedSmallUUID)
def test_prep(self): field = models.SmallUUIDField() out = field.get_db_prep_value(SmallUUID('IBNApQOzTHGzdjkSt6t-Jg'), connection=connection) self.assertEqual(out, '201340a503b34c71b3763912b7ab7e26')
def test_to_python_custom_class(self): field = models.SmallUUIDField(uuid_class=TypedSmallUUID) out = field.to_python('IBNApQOzTHGzdjkSt6t-Jg') self.assertIsInstance(out, TypedSmallUUID)
def test_to_python_invalid_value(self): field = models.SmallUUIDField() self.assertRaises(ValidationError, field.to_python, 'xxx')
def test_to_python(self): field = models.SmallUUIDField() out = field.to_python('IBNApQOzTHGzdjkSt6t-Jg') self.assertIsInstance(out, SmallUUID)
def test_force_not_unique(self): field = models.SmallUUIDField(unique=False) self.assertFalse(field.unique)
def test_unique_by_default(self): field = models.SmallUUIDField() self.assertTrue(field.unique)