Merge pull request #512 from datastax/503-test
Simple test for Python-503, slight doc tweak
This commit is contained in:
@@ -46,7 +46,7 @@ cdef class DesBytesType(Deserializer):
|
|||||||
cdef deserialize(self, Buffer *buf, int protocol_version):
|
cdef deserialize(self, Buffer *buf, int protocol_version):
|
||||||
return to_bytes(buf)
|
return to_bytes(buf)
|
||||||
|
|
||||||
# this is to facilitate cqlengine integration, which requires bytearrays for BytesType
|
# this is to facilitate cqlsh integration, which requires bytearrays for BytesType
|
||||||
# It is switched in by simply overwriting DesBytesType:
|
# It is switched in by simply overwriting DesBytesType:
|
||||||
# deserializers.DesBytesType = deserializers.DesBytesTypeByteArray
|
# deserializers.DesBytesType = deserializers.DesBytesTypeByteArray
|
||||||
cdef class DesBytesTypeByteArray(Deserializer):
|
cdef class DesBytesTypeByteArray(Deserializer):
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ from datetime import datetime
|
|||||||
import math
|
import math
|
||||||
import six
|
import six
|
||||||
|
|
||||||
|
import cassandra
|
||||||
from cassandra import InvalidRequest
|
from cassandra import InvalidRequest
|
||||||
from cassandra.cluster import Cluster
|
from cassandra.cluster import Cluster
|
||||||
from cassandra.concurrent import execute_concurrent_with_args
|
from cassandra.concurrent import execute_concurrent_with_args
|
||||||
@@ -98,6 +99,36 @@ class TypeTests(BasicSharedKeyspaceUnitTestCase):
|
|||||||
for expected, actual in zip(params, results):
|
for expected, actual in zip(params, results):
|
||||||
self.assertEqual(expected, actual)
|
self.assertEqual(expected, actual)
|
||||||
|
|
||||||
|
@unittest.skipIf(not hasattr(cassandra, 'deserializers'), "Cython required for to test DesBytesTypeArray deserializer")
|
||||||
|
def test_des_bytes_type_array(self):
|
||||||
|
"""
|
||||||
|
Simple test to ensure the DesBytesTypeByteArray deserializer functionally works
|
||||||
|
|
||||||
|
@since 3.1
|
||||||
|
@jira_ticket PYTHON-503
|
||||||
|
@expected_result byte array should be deserialized appropriately.
|
||||||
|
|
||||||
|
@test_category queries:custom_payload
|
||||||
|
"""
|
||||||
|
original = None
|
||||||
|
try:
|
||||||
|
|
||||||
|
original = cassandra.deserializers.DesBytesType
|
||||||
|
cassandra.deserializers.DesBytesType = cassandra.deserializers.DesBytesTypeByteArray
|
||||||
|
s = self.session
|
||||||
|
|
||||||
|
s.execute("CREATE TABLE blobbytes2 (a ascii PRIMARY KEY, b blob)")
|
||||||
|
|
||||||
|
params = ['key1', bytearray(b'blob1')]
|
||||||
|
s.execute("INSERT INTO blobbytes2 (a, b) VALUES (%s, %s)", params)
|
||||||
|
|
||||||
|
results = s.execute("SELECT * FROM blobbytes2")[0]
|
||||||
|
for expected, actual in zip(params, results):
|
||||||
|
self.assertEqual(expected, actual)
|
||||||
|
finally:
|
||||||
|
if original is not None:
|
||||||
|
cassandra.deserializers.DesBytesType=original
|
||||||
|
|
||||||
def test_can_insert_primitive_datatypes(self):
|
def test_can_insert_primitive_datatypes(self):
|
||||||
"""
|
"""
|
||||||
Test insertion of all datatype primitives
|
Test insertion of all datatype primitives
|
||||||
|
|||||||
Reference in New Issue
Block a user