Minor fixes and unit test updates

This commit is contained in:
Tyler Hobbs
2014-05-23 17:29:14 -05:00
parent 2c2c2c48da
commit e3e6c4040f
4 changed files with 9 additions and 9 deletions

View File

@@ -680,7 +680,7 @@ class _SimpleParameterizedType(_ParameterizedType):
p += 2
item = byts[p:p + itemlen]
p += itemlen
result.append(subtype.from_binary(item))
result.append(subtype.from_binary(item, protocol_version))
return cls.adapter(result)
@classmethod
@@ -734,8 +734,8 @@ class MapType(_ParameterizedType):
p += 2
valbytes = byts[p:p + val_len]
p += val_len
key = subkeytype.from_binary(keybytes)
val = subvaltype.from_binary(valbytes)
key = subkeytype.from_binary(keybytes, protocol_version)
val = subvaltype.from_binary(valbytes, protocol_version)
themap[key] = val
return themap

View File

@@ -337,13 +337,13 @@ class PreparedStatement(object):
return PreparedStatement(column_metadata, query_id, routing_key_indexes, query, keyspace)
def bind(self, values):
def bind(self, values, protocol_version):
"""
Creates and returns a :class:`BoundStatement` instance using `values`.
The `values` parameter **must** be a sequence, such as a tuple or list,
even if there is only one value to bind.
"""
return BoundStatement(self).bind(values)
return BoundStatement(self).bind(values, protocol_version)
def __str__(self):
consistency = ConsistencyLevel.value_to_name.get(self.consistency_level, 'Not Set')

View File

@@ -109,7 +109,7 @@ class TestUnmarshal(unittest.TestCase):
def test_unmarshalling(self):
for serializedval, valtype, nativeval in marshalled_value_pairs:
unmarshaller = lookup_casstype(valtype)
whatwegot = unmarshaller.from_binary(serializedval)
whatwegot = unmarshaller.from_binary(serializedval, 1)
self.assertEqual(whatwegot, nativeval,
msg='Unmarshaller for %s (%s) failed: unmarshal(%r) got %r instead of %r'
% (valtype, unmarshaller, serializedval, whatwegot, nativeval))
@@ -120,7 +120,7 @@ class TestUnmarshal(unittest.TestCase):
def test_marshalling(self):
for serializedval, valtype, nativeval in marshalled_value_pairs:
marshaller = lookup_casstype(valtype)
whatwegot = marshaller.to_binary(nativeval)
whatwegot = marshaller.to_binary(nativeval, 1)
self.assertEqual(whatwegot, serializedval,
msg='Marshaller for %s (%s) failed: marshal(%r) got %r instead of %r'
% (valtype, marshaller, nativeval, whatwegot, serializedval))

View File

@@ -89,7 +89,7 @@ class BoundStatementTestCase(unittest.TestCase):
values = ['nonint', 1]
try:
bound_statement.bind(values)
bound_statement.bind(values, protocol_version=1)
except TypeError as e:
self.assertIn('foo1', str(e))
self.assertIn('Int32Type', str(e))
@@ -100,7 +100,7 @@ class BoundStatementTestCase(unittest.TestCase):
values = [1, ['1', '2']]
try:
bound_statement.bind(values)
bound_statement.bind(values, protocol_version=1)
except TypeError as e:
self.assertIn('foo2', str(e))
self.assertIn('Int32Type', str(e))