Esempio n. 1
0
    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))
Esempio n. 2
0
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")
Esempio n. 3
0
    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')
Esempio n. 4
0
 def test_macadressfield_field_ok(self):
     models.MACAdressField().validate('00-1B-77-49-54-FD')
Esempio n. 5
0
 def test_macadressfield_field_ok(self):
     try:
         models.MACAdressField().validate("00-1B-77-49-54-FD")
     except AsyncOrmFieldError:
         self.fail("unexpectedly exception raised!")