def test_macadressfield_field_validation_error(self): dialect = "wrong" with self.assertRaises(FieldError) as exc: models.MACAdressField(dialect=dialect) self.assertEqual(exc.exception.args[0], '"{}" is not a correct mac dialect'.format(dialect))
class Publisher(models.Model): name = models.CharField(max_length=50, db_index=True) json = models.JsonField(max_length=50, null=True) mac = models.MACAdressField(null=True, dialect="unix") inet = models.GenericIPAddressField(null=True, protocol="both", unpack_protocol="ipv4")
def test_macadressfield_field_error(self): with self.assertRaises(FieldError) as exc: models.MACAdressField().validate('00-1B-77-49-54') self.assertEqual(exc.exception.args[0], 'Not a correct MAC address')
def test_macadressfield_field_ok(self): models.MACAdressField().validate('00-1B-77-49-54-FD')
def test_macadressfield_field_ok(self): try: models.MACAdressField().validate("00-1B-77-49-54-FD") except AsyncOrmFieldError: self.fail("unexpectedly exception raised!")