Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions tests/integration/cqlengine/model/test_model_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from uuid import uuid4, UUID
import random
from datetime import date, datetime
from datetime import datetime, date, time
from decimal import Decimal
from operator import itemgetter

Expand All @@ -23,7 +23,7 @@
from cassandra.cqlengine.management import sync_table
from cassandra.cqlengine.management import drop_table
from cassandra.cqlengine.models import Model
from cassandra.util import Date
from cassandra.util import Date, Time

from tests.integration.cqlengine.base import BaseCassEngTestCase

Expand Down Expand Up @@ -155,24 +155,28 @@ class AllDatatypesModel(Model):
i = columns.Float(double_precision=False)
j = columns.Inet()
k = columns.Integer()
l = columns.Text()
m = columns.TimeUUID()
n = columns.UUID()
o = columns.VarInt()
l = columns.SmallInt()
m = columns.Text()
n = columns.Time()
o = columns.TimeUUID()
p = columns.TinyInt()
q = columns.UUID()
r = columns.VarInt()

sync_table(AllDatatypesModel)

input = ['ascii', 2 ** 63 - 1, bytearray(b'hello world'), True, Date(date(1970, 1, 1)),
datetime.utcfromtimestamp(872835240), Decimal('12.3E+7'), 2.39,
3.4028234663852886e+38, '123.123.123.123', 2147483647, 'text',
UUID('FE2B4360-28C6-11E2-81C1-0800200C9A66'), UUID('067e6162-3b6f-4ae2-a171-2470b63dff00'),
3.4028234663852886e+38, '123.123.123.123', 2147483647, 32523, 'text', Time(time(16, 47, 25, 7)),
UUID('FE2B4360-28C6-11E2-81C1-0800200C9A66'), 123, UUID('067e6162-3b6f-4ae2-a171-2470b63dff00'),
int(str(2147483647) + '000')]

AllDatatypesModel.create(id=0, a='ascii', b=2 ** 63 - 1, c=bytearray(b'hello world'), d=True, e=date(1970, 1, 1),
f=datetime.utcfromtimestamp(872835240), g=Decimal('12.3E+7'), h=2.39,
i=3.4028234663852886e+38, j='123.123.123.123', k=2147483647, l='text',
m=UUID('FE2B4360-28C6-11E2-81C1-0800200C9A66'), n=UUID('067e6162-3b6f-4ae2-a171-2470b63dff00'),
o=int(str(2147483647) + '000'))
i=3.4028234663852886e+38, j='123.123.123.123', k=2147483647, l=32523, m='text',
n=time(16, 47, 25, 7), o=UUID('FE2B4360-28C6-11E2-81C1-0800200C9A66'),
p=123, q=UUID('067e6162-3b6f-4ae2-a171-2470b63dff00'),
r=int(str(2147483647) + '000'))

self.assertEqual(1, AllDatatypesModel.objects.count())
output = AllDatatypesModel.objects().first()
Expand Down
36 changes: 22 additions & 14 deletions tests/integration/cqlengine/model/test_udts.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from datetime import date, datetime
from datetime import datetime, date, time
from decimal import Decimal
import unittest
from uuid import UUID
Expand All @@ -21,7 +21,7 @@
from cassandra.cqlengine.usertype import UserType
from cassandra.cqlengine import columns
from cassandra.cqlengine.management import sync_table, sync_type, create_keyspace_simple, drop_keyspace
from cassandra.util import Date
from cassandra.util import Date, Time

from tests.integration import get_server_versions
from tests.integration.cqlengine.base import BaseCassEngTestCase
Expand Down Expand Up @@ -216,18 +216,22 @@ class AllDatatypes(UserType):
i = columns.Float(double_precision=False)
j = columns.Inet()
k = columns.Integer()
l = columns.Text()
m = columns.TimeUUID()
n = columns.UUID()
o = columns.VarInt()
l = columns.SmallInt()
m = columns.Text()
n = columns.Time()
o = columns.TimeUUID()
p = columns.TinyInt()
q = columns.UUID()
r = columns.VarInt()

class AllDatatypesModel(Model):
id = columns.Integer(primary_key=True)
data = columns.UserDefinedType(AllDatatypes)

sync_table(AllDatatypesModel)

input = AllDatatypes(a=None, b=None, c=None, d=None, e=None, f=None, g=None, h=None, i=None, j=None, k=None, l=None, m=None, n=None)
input = AllDatatypes(a=None, b=None, c=None, d=None, e=None, f=None, g=None, h=None, i=None, j=None, k=None,
l=None, m=None, n=None, o=None, p=None, q=None, r=None)
AllDatatypesModel.create(id=0, data=input)

self.assertEqual(1, AllDatatypesModel.objects.count())
Expand Down Expand Up @@ -263,10 +267,13 @@ class AllDatatypes(UserType):
i = columns.Float(double_precision=False)
j = columns.Inet()
k = columns.Integer()
l = columns.Text()
m = columns.TimeUUID()
n = columns.UUID()
o = columns.VarInt()
l = columns.SmallInt()
m = columns.Text()
n = columns.Time()
o = columns.TimeUUID()
p = columns.TinyInt()
q = columns.UUID()
r = columns.VarInt()

class AllDatatypesModel(Model):
id = columns.Integer(primary_key=True)
Expand All @@ -276,9 +283,10 @@ class AllDatatypesModel(Model):

input = AllDatatypes(a='ascii', b=2 ** 63 - 1, c=bytearray(b'hello world'), d=True, e=Date(date(1970, 1, 1)),
f=datetime.utcfromtimestamp(872835240), g=Decimal('12.3E+7'), h=2.39,
i=3.4028234663852886e+38, j='123.123.123.123', k=2147483647, l='text',
m=UUID('FE2B4360-28C6-11E2-81C1-0800200C9A66'), n=UUID('067e6162-3b6f-4ae2-a171-2470b63dff00'),
o=int(str(2147483647) + '000'))
i=3.4028234663852886e+38, j='123.123.123.123', k=2147483647, l=32523, m='text',
n=Time(time(16, 47, 25, 7)), o=UUID('FE2B4360-28C6-11E2-81C1-0800200C9A66'),
p=123, q=UUID('067e6162-3b6f-4ae2-a171-2470b63dff00'),
r=int(str(2147483647) + '000'))
AllDatatypesModel.create(id=0, data=input)

self.assertEqual(1, AllDatatypesModel.objects.count())
Expand Down