inet address support
This commit is contained in:
@@ -224,6 +224,9 @@ class Bytes(Column):
|
||||
class Ascii(Column):
|
||||
db_type = 'ascii'
|
||||
|
||||
class Inet(Column):
|
||||
db_type = 'inet'
|
||||
|
||||
|
||||
class Text(Column):
|
||||
db_type = 'text'
|
||||
|
@@ -5,6 +5,7 @@ from datetime import tzinfo
|
||||
from decimal import Decimal as D
|
||||
from unittest import TestCase
|
||||
from uuid import uuid4, uuid1
|
||||
from cassandra import InvalidRequest
|
||||
from cqlengine import ValidationError
|
||||
from cqlengine.connection import execute
|
||||
|
||||
@@ -23,6 +24,7 @@ from cqlengine.columns import UUID
|
||||
from cqlengine.columns import Boolean
|
||||
from cqlengine.columns import Float
|
||||
from cqlengine.columns import Decimal
|
||||
from cqlengine.columns import Inet
|
||||
|
||||
from cqlengine.management import sync_table, drop_table
|
||||
from cqlengine.models import Model
|
||||
@@ -345,3 +347,24 @@ class TestTimeUUIDFromDatetime(TestCase):
|
||||
# checks that we created a UUID1 with the proper timestamp
|
||||
assert new_dt == dt
|
||||
|
||||
class TestInet(BaseCassEngTestCase):
|
||||
|
||||
class InetTestModel(Model):
|
||||
id = UUID(primary_key=True, default=uuid4)
|
||||
address = Inet()
|
||||
|
||||
def setUp(self):
|
||||
drop_table(self.InetTestModel)
|
||||
sync_table(self.InetTestModel)
|
||||
|
||||
def test_inet_saves(self):
|
||||
tmp = self.InetTestModel.create(address="192.168.1.1")
|
||||
|
||||
m = self.InetTestModel.get(id=tmp.id)
|
||||
|
||||
assert m.address == "192.168.1.1"
|
||||
|
||||
def test_non_address_fails(self):
|
||||
with self.assertRaises(InvalidRequest):
|
||||
self.InetTestModel.create(address="ham sandwich")
|
||||
|
||||
|
Reference in New Issue
Block a user