Create and switch the PROTOCOL_VERSION for tests

This commit is contained in:
Joaquin Casares
2014-03-27 14:35:06 -05:00
parent bd6d474e2e
commit 0183ef52fc
12 changed files with 105 additions and 77 deletions

View File

@@ -18,7 +18,12 @@ except ImportError as e:
CLUSTER_NAME = 'test_cluster'
CCM_CLUSTER = None
DEFAULT_CASSANDRA_VERSION = '2.0.6'
CASSANDRA_VERSION = os.getenv('CASSANDRA_VERSION', '2.0.6')
if CASSANDRA_VERSION.startswith('1'):
PROTOCOL_VERSION = 1
else:
PROTOCOL_VERSION = 2
path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'ccm')
if not os.path.exists(path):
@@ -38,7 +43,7 @@ def get_server_versions():
if cass_version is not None:
return (cass_version, cql_version)
c = Cluster()
c = Cluster(protocol_version=PROTOCOL_VERSION)
s = c.connect()
s.set_keyspace('system')
row = s.execute('SELECT cql_version, release_version FROM local')[0]
@@ -67,17 +72,16 @@ def get_node(node_id):
def setup_package():
version = os.getenv("CASSANDRA_VERSION", DEFAULT_CASSANDRA_VERSION)
print 'Using Cassandra version: %s' % version
print 'Using Cassandra version: %s' % CASSANDRA_VERSION
try:
try:
cluster = CCMCluster.load(path, CLUSTER_NAME)
log.debug("Found existing ccm test cluster, clearing")
cluster.clear()
cluster.set_cassandra_dir(cassandra_version=version)
cluster.set_cassandra_dir(cassandra_version=CASSANDRA_VERSION)
except Exception:
log.debug("Creating new ccm test cluster with version %s", version)
cluster = CCMCluster(path, CLUSTER_NAME, cassandra_version=version)
log.debug("Creating new ccm test cluster with version %s", CASSANDRA_VERSION)
cluster = CCMCluster(path, CLUSTER_NAME, cassandra_version=CASSANDRA_VERSION)
cluster.set_configuration_options({'start_native_transport': True})
common.switch_cluster(path, CLUSTER_NAME)
cluster.populate(3)
@@ -94,7 +98,7 @@ def setup_package():
def setup_test_keyspace():
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
try:

View File

@@ -7,6 +7,7 @@ from cassandra.cluster import Cluster
from cassandra.policies import TokenAwarePolicy, RoundRobinPolicy, \
DowngradingConsistencyRetryPolicy
from cassandra.query import SimpleStatement
from tests.integration import PROTOCOL_VERSION
from tests.integration.long.utils import force_stop, create_schema, \
wait_for_down, wait_for_up, start, CoordinatorStats
@@ -98,7 +99,8 @@ class ConsistencyTests(unittest.TestCase):
def _test_tokenaware_one_node_down(self, keyspace, rf, accepted):
cluster = Cluster(
load_balancing_policy=TokenAwarePolicy(RoundRobinPolicy()))
load_balancing_policy=TokenAwarePolicy(RoundRobinPolicy()),
protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
wait_for_up(cluster, 1, wait=False)
wait_for_up(cluster, 2)
@@ -147,7 +149,8 @@ class ConsistencyTests(unittest.TestCase):
def test_rfthree_tokenaware_none_down(self):
keyspace = 'test_rfthree_tokenaware_none_down'
cluster = Cluster(
load_balancing_policy=TokenAwarePolicy(RoundRobinPolicy()))
load_balancing_policy=TokenAwarePolicy(RoundRobinPolicy()),
protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
wait_for_up(cluster, 1, wait=False)
wait_for_up(cluster, 2)
@@ -169,7 +172,8 @@ class ConsistencyTests(unittest.TestCase):
def _test_downgrading_cl(self, keyspace, rf, accepted):
cluster = Cluster(
load_balancing_policy=TokenAwarePolicy(RoundRobinPolicy()),
default_retry_policy=DowngradingConsistencyRetryPolicy())
default_retry_policy=DowngradingConsistencyRetryPolicy(),
protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
create_schema(session, keyspace, replication_factor=rf)
@@ -210,14 +214,16 @@ class ConsistencyTests(unittest.TestCase):
keyspace = 'test_rfthree_roundrobin_downgradingcl'
cluster = Cluster(
load_balancing_policy=RoundRobinPolicy(),
default_retry_policy=DowngradingConsistencyRetryPolicy())
default_retry_policy=DowngradingConsistencyRetryPolicy(),
protocol_version=PROTOCOL_VERSION)
self.rfthree_downgradingcl(cluster, keyspace, True)
def test_rfthree_tokenaware_downgradingcl(self):
keyspace = 'test_rfthree_tokenaware_downgradingcl'
cluster = Cluster(
load_balancing_policy=TokenAwarePolicy(RoundRobinPolicy()),
default_retry_policy=DowngradingConsistencyRetryPolicy())
default_retry_policy=DowngradingConsistencyRetryPolicy(),
protocol_version=PROTOCOL_VERSION)
self.rfthree_downgradingcl(cluster, keyspace, False)
def rfthree_downgradingcl(self, cluster, keyspace, roundrobin):

View File

@@ -6,6 +6,7 @@ from cassandra import ConsistencyLevel
from cassandra.cluster import Cluster
from cassandra.query import dict_factory
from cassandra.query import SimpleStatement
from tests.integration import PROTOCOL_VERSION
from tests.integration.long.utils import create_schema
@@ -29,7 +30,7 @@ class LargeDataTests(unittest.TestCase):
self.keyspace = 'large_data'
def make_session_and_keyspace(self):
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
session.default_timeout = 20.0 # increase the default timeout
session.row_factory = dict_factory

View File

@@ -3,6 +3,7 @@ import logging
from cassandra import ConsistencyLevel
from cassandra.cluster import Cluster
from cassandra.query import SimpleStatement
from tests.integration import PROTOCOL_VERSION
try:
import unittest2 as unittest
@@ -15,7 +16,7 @@ log = logging.getLogger(__name__)
class SchemaTests(unittest.TestCase):
def test_recreates(self):
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
replication_factor = 3

View File

@@ -1,3 +1,5 @@
from tests.integration import PROTOCOL_VERSION
try:
import unittest2 as unittest
except ImportError:
@@ -18,7 +20,7 @@ class ClusterTests(unittest.TestCase):
Test basic connection and usage
"""
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
result = session.execute(
"""
@@ -54,7 +56,7 @@ class ClusterTests(unittest.TestCase):
Ensure clusters that connect on a keyspace, do
"""
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
result = session.execute(
"""
@@ -71,7 +73,7 @@ class ClusterTests(unittest.TestCase):
self.assertEquals(result, result2)
def test_set_keyspace_twice(self):
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
session.execute("USE system")
session.execute("USE system")
@@ -86,7 +88,8 @@ class ClusterTests(unittest.TestCase):
reconnection_policy=ExponentialReconnectionPolicy(1.0, 600.0),
default_retry_policy=RetryPolicy(),
conviction_policy_factory=SimpleConvictionPolicy,
connection_class=AsyncoreConnection
connection_class=AsyncoreConnection,
protocol_version=PROTOCOL_VERSION
)
def test_double_shutdown(self):
@@ -94,7 +97,7 @@ class ClusterTests(unittest.TestCase):
Ensure that a cluster can be shutdown twice, without error
"""
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
cluster.shutdown()
try:
@@ -108,7 +111,7 @@ class ClusterTests(unittest.TestCase):
Ensure you cannot connect to a cluster that's been shutdown
"""
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
cluster.shutdown()
self.assertRaises(Exception, cluster.connect)
@@ -132,7 +135,8 @@ class ClusterTests(unittest.TestCase):
when a cluster cannot connect to given hosts
"""
cluster = Cluster(['127.1.2.9', '127.1.2.10'])
cluster = Cluster(['127.1.2.9', '127.1.2.10'],
protocol_version=PROTOCOL_VERSION)
self.assertRaises(NoHostAvailable, cluster.connect)
def test_cluster_settings(self):
@@ -140,7 +144,7 @@ class ClusterTests(unittest.TestCase):
Test connection setting getters and setters
"""
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
min_requests_per_connection = cluster.get_min_requests_per_connection(HostDistance.LOCAL)
self.assertEqual(cassandra.cluster.DEFAULT_MIN_REQUESTS, min_requests_per_connection)
@@ -167,11 +171,11 @@ class ClusterTests(unittest.TestCase):
Ensure new new schema is refreshed after submit_schema_refresh()
"""
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
cluster.connect()
self.assertNotIn("newkeyspace", cluster.metadata.keyspaces)
other_cluster = Cluster()
other_cluster = Cluster(protocol_version=PROTOCOL_VERSION)
session = other_cluster.connect()
session.execute(
"""
@@ -189,7 +193,7 @@ class ClusterTests(unittest.TestCase):
Ensure trace can be requested for async and non-async queries
"""
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
self.assertRaises(TypeError, session.execute, "SELECT * FROM system.local", trace=True)
@@ -215,7 +219,7 @@ class ClusterTests(unittest.TestCase):
self.assertEqual(None, future.get_query_trace())
def test_trace_timeout(self):
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
query = "SELECT * FROM system.local"
@@ -229,7 +233,7 @@ class ClusterTests(unittest.TestCase):
Ensure str(future) returns without error
"""
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
query = "SELECT * FROM system.local"

View File

@@ -1,3 +1,5 @@
from tests.integration import PROTOCOL_VERSION
try:
import unittest2 as unittest
except ImportError:
@@ -24,7 +26,7 @@ class ConnectionTest(object):
"""
Test a single connection with sequential requests.
"""
conn = self.klass.factory()
conn = self.klass.factory(protocol_version=PROTOCOL_VERSION)
query = "SELECT keyspace_name FROM system.schema_keyspaces LIMIT 1"
event = Event()
@@ -47,7 +49,7 @@ class ConnectionTest(object):
"""
Test a single connection with pipelined requests.
"""
conn = self.klass.factory()
conn = self.klass.factory(protocol_version=PROTOCOL_VERSION)
query = "SELECT keyspace_name FROM system.schema_keyspaces LIMIT 1"
responses = [False] * 100
event = Event()
@@ -69,7 +71,7 @@ class ConnectionTest(object):
"""
Test multiple connections with pipelined requests.
"""
conns = [self.klass.factory() for i in range(5)]
conns = [self.klass.factory(protocol_version=PROTOCOL_VERSION) for i in range(5)]
events = [Event() for i in range(5)]
query = "SELECT keyspace_name FROM system.schema_keyspaces LIMIT 1"
@@ -100,7 +102,7 @@ class ConnectionTest(object):
num_threads = 5
event = Event()
conn = self.klass.factory()
conn = self.klass.factory(protocol_version=PROTOCOL_VERSION)
query = "SELECT keyspace_name FROM system.schema_keyspaces LIMIT 1"
def cb(all_responses, thread_responses, request_num, *args, **kwargs):
@@ -157,7 +159,7 @@ class ConnectionTest(object):
threads = []
for i in range(num_conns):
conn = self.klass.factory()
conn = self.klass.factory(protocol_version=PROTOCOL_VERSION)
t = Thread(target=send_msgs, args=(conn, events[i]))
threads.append(t)

View File

@@ -1,3 +1,5 @@
from tests.integration import PROTOCOL_VERSION
try:
import unittest2 as unittest
except ImportError:
@@ -36,7 +38,7 @@ class TestFactories(unittest.TestCase):
'''
def test_tuple_factory(self):
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
session.row_factory = tuple_factory
@@ -58,7 +60,7 @@ class TestFactories(unittest.TestCase):
self.assertEqual(result[1][0], 2)
def test_named_tuple_factoryy(self):
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
session.row_factory = named_tuple_factory
@@ -79,7 +81,7 @@ class TestFactories(unittest.TestCase):
self.assertEqual(result[1].k, 2)
def test_dict_factory(self):
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
session.row_factory = dict_factory
@@ -101,7 +103,7 @@ class TestFactories(unittest.TestCase):
self.assertEqual(result[1]['k'], 2)
def test_ordered_dict_factory(self):
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
session.row_factory = ordered_dict_factory

View File

@@ -13,7 +13,7 @@ from cassandra.metadata import (Metadata, KeyspaceMetadata, TableMetadata,
from cassandra.policies import SimpleConvictionPolicy
from cassandra.pool import Host
from tests.integration import get_cluster
from tests.integration import get_cluster, PROTOCOL_VERSION
class SchemaMetadataTest(unittest.TestCase):
@@ -26,7 +26,7 @@ class SchemaMetadataTest(unittest.TestCase):
@classmethod
def setup_class(cls):
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
try:
results = session.execute("SELECT keyspace_name FROM system.schema_keyspaces")
@@ -44,7 +44,8 @@ class SchemaMetadataTest(unittest.TestCase):
@classmethod
def teardown_class(cls):
cluster = Cluster(['127.0.0.1'])
cluster = Cluster(['127.0.0.1'],
protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
try:
session.execute("DROP KEYSPACE %s" % cls.ksname)
@@ -52,7 +53,8 @@ class SchemaMetadataTest(unittest.TestCase):
cluster.shutdown()
def setUp(self):
self.cluster = Cluster(['127.0.0.1'])
self.cluster = Cluster(['127.0.0.1'],
protocol_version=PROTOCOL_VERSION)
self.session = self.cluster.connect()
def tearDown(self):
@@ -292,7 +294,7 @@ class TestCodeCoverage(unittest.TestCase):
Test export schema functionality
"""
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
cluster.connect()
self.assertIsInstance(cluster.metadata.export_schema_as_string(), basestring)
@@ -302,7 +304,7 @@ class TestCodeCoverage(unittest.TestCase):
Test export keyspace schema functionality
"""
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
cluster.connect()
for keyspace in cluster.metadata.keyspaces:
@@ -315,7 +317,7 @@ class TestCodeCoverage(unittest.TestCase):
Test that names that need to be escaped in CREATE statements are
"""
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
ksname = 'AnInterestingKeyspace'
@@ -354,7 +356,7 @@ class TestCodeCoverage(unittest.TestCase):
Ensure AlreadyExists exception is thrown when hit
"""
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
ksname = 'test3rf'
@@ -378,7 +380,7 @@ class TestCodeCoverage(unittest.TestCase):
if murmur3 is None:
raise unittest.SkipTest('the murmur3 extension is not available')
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
self.assertEqual(cluster.metadata.get_replicas('test3rf', 'key'), [])
cluster.connect('test3rf')
@@ -393,7 +395,7 @@ class TestCodeCoverage(unittest.TestCase):
Test token mappings
"""
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
cluster.connect('test3rf')
ring = cluster.metadata.token_map.ring
owners = list(cluster.metadata.token_map.token_to_host_owner[token] for token in ring)
@@ -416,7 +418,7 @@ class TokenMetadataTest(unittest.TestCase):
def test_token(self):
expected_node_count = len(get_cluster().nodes)
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
cluster.connect()
tmap = cluster.metadata.token_map
self.assertTrue(issubclass(tmap.token_class, Token))

View File

@@ -7,7 +7,7 @@ from cassandra.query import SimpleStatement
from cassandra import ConsistencyLevel, WriteTimeout, Unavailable, ReadTimeout
from cassandra.cluster import Cluster, NoHostAvailable
from tests.integration import get_node, get_cluster
from tests.integration import get_node, get_cluster, PROTOCOL_VERSION
class MetricsTests(unittest.TestCase):
@@ -17,7 +17,8 @@ class MetricsTests(unittest.TestCase):
Trigger and ensure connection_errors are counted
"""
cluster = Cluster(metrics_enabled=True)
cluster = Cluster(metrics_enabled=True,
protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
session.execute("USE test3rf")
@@ -45,7 +46,8 @@ class MetricsTests(unittest.TestCase):
Attempt a write at cl.ALL and receive a WriteTimeout.
"""
cluster = Cluster(metrics_enabled=True)
cluster = Cluster(metrics_enabled=True,
protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
# Test write
@@ -75,7 +77,8 @@ class MetricsTests(unittest.TestCase):
Attempt a read at cl.ALL and receive a ReadTimeout.
"""
cluster = Cluster(metrics_enabled=True)
cluster = Cluster(metrics_enabled=True,
protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
# Test write
@@ -105,7 +108,8 @@ class MetricsTests(unittest.TestCase):
Attempt an insert/read at cl.ALL and receive a Unavailable Exception.
"""
cluster = Cluster(metrics_enabled=True)
cluster = Cluster(metrics_enabled=True,
protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
# Test write

View File

@@ -1,3 +1,5 @@
from tests.integration import PROTOCOL_VERSION
try:
import unittest2 as unittest
except ImportError:
@@ -14,7 +16,7 @@ class PreparedStatementTests(unittest.TestCase):
Test basic PreparedStatement usage
"""
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
session.execute(
"""
@@ -59,7 +61,7 @@ class PreparedStatementTests(unittest.TestCase):
when prepared statements are missing the primary key
"""
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
prepared = session.prepare(
@@ -76,7 +78,7 @@ class PreparedStatementTests(unittest.TestCase):
Ensure a ValueError is thrown when attempting to bind too many variables
"""
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
prepared = session.prepare(
@@ -92,7 +94,7 @@ class PreparedStatementTests(unittest.TestCase):
Ensure binding None is handled correctly
"""
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
prepared = session.prepare(
@@ -119,7 +121,7 @@ class PreparedStatementTests(unittest.TestCase):
Ensure None binding over async queries
"""
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
prepared = session.prepare(

View File

@@ -10,13 +10,13 @@ from cassandra.query import (PreparedStatement, BoundStatement, ValueSequence,
from cassandra.cluster import Cluster
from cassandra.policies import HostDistance
from tests.integration import get_server_versions
from tests.integration import get_server_versions, PROTOCOL_VERSION
class QueryTest(unittest.TestCase):
def test_query(self):
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
prepared = session.prepare(
@@ -44,7 +44,7 @@ class QueryTest(unittest.TestCase):
Code coverage to ensure trace prints to string without error
"""
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
query = "SELECT * FROM system.local"
@@ -57,7 +57,7 @@ class QueryTest(unittest.TestCase):
str(event)
def test_trace_ignores_row_factory(self):
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
session.row_factory = dict_factory
@@ -78,7 +78,7 @@ class PreparedStatementTests(unittest.TestCase):
Simple code coverage to ensure routing_keys can be accessed
"""
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
prepared = session.prepare(
@@ -96,7 +96,7 @@ class PreparedStatementTests(unittest.TestCase):
the routing key should be None
"""
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
prepared = session.prepare(
@@ -115,7 +115,7 @@ class PreparedStatementTests(unittest.TestCase):
overrides the current routing key
"""
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
prepared = session.prepare(
@@ -133,7 +133,7 @@ class PreparedStatementTests(unittest.TestCase):
Basic test that uses a fake routing_key_index
"""
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
prepared = session.prepare(
@@ -151,7 +151,7 @@ class PreparedStatementTests(unittest.TestCase):
Ensure that bound.keyspace works as expected
"""
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
prepared = session.prepare(
@@ -186,7 +186,7 @@ class PrintStatementTests(unittest.TestCase):
Highlight the difference between Prepared and Bound statements
"""
cluster = Cluster()
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
session = cluster.connect()
prepared = session.prepare('INSERT INTO test3rf.test (k, v) VALUES (?, ?)')
@@ -208,7 +208,7 @@ class BatchStatementTests(unittest.TestCase):
"Cassandra 2.0+ is required for BATCH operations, currently testing against %r"
% (cass_version,))
self.cluster = Cluster(protocol_version=2)
self.cluster = Cluster(protocol_version=PROTOCOL_VERSION)
self.cluster.set_core_connections_per_host(HostDistance.LOCAL, 1)
self.session = self.cluster.connect()
@@ -278,7 +278,7 @@ class SerialConsistencyTests(unittest.TestCase):
"Cassandra 2.0+ is required for BATCH operations, currently testing against %r"
% (cass_version,))
self.cluster = Cluster(protocol_version=2)
self.cluster = Cluster(protocol_version=PROTOCOL_VERSION)
self.cluster.set_core_connections_per_host(HostDistance.LOCAL, 1)
self.session = self.cluster.connect()

View File

@@ -18,7 +18,7 @@ from cassandra.cqltypes import Int32Type, EMPTY
from cassandra.query import dict_factory
from cassandra.util import OrderedDict
from tests.integration import get_server_versions
from tests.integration import get_server_versions, PROTOCOL_VERSION
class TypeTests(unittest.TestCase):
@@ -27,7 +27,7 @@ class TypeTests(unittest.TestCase):
self._cass_version, self._cql_version = get_server_versions()
def test_blob_type_as_string(self):
c = Cluster()
c = Cluster(protocol_version=PROTOCOL_VERSION)
s = c.connect()
s.execute("""
@@ -69,7 +69,7 @@ class TypeTests(unittest.TestCase):
self.assertEquals(expected, actual)
def test_blob_type_as_bytearray(self):
c = Cluster()
c = Cluster(protocol_version=PROTOCOL_VERSION)
s = c.connect()
s.execute("""
@@ -129,7 +129,7 @@ class TypeTests(unittest.TestCase):
"""
def test_basic_types(self):
c = Cluster()
c = Cluster(protocol_version=PROTOCOL_VERSION)
s = c.connect()
s.execute("""
CREATE KEYSPACE typetests
@@ -226,7 +226,7 @@ class TypeTests(unittest.TestCase):
self.assertEquals(expected, actual)
def test_empty_strings_and_nones(self):
c = Cluster()
c = Cluster(protocol_version=PROTOCOL_VERSION)
s = c.connect()
s.execute("""
CREATE KEYSPACE test_empty_strings_and_nones
@@ -329,7 +329,7 @@ class TypeTests(unittest.TestCase):
self.assertEqual([], [(name, val) for (name, val) in results[0].items() if val is not None])
def test_empty_values(self):
c = Cluster()
c = Cluster(protocol_version=PROTOCOL_VERSION)
s = c.connect()
s.execute("""
CREATE KEYSPACE test_empty_values
@@ -356,7 +356,7 @@ class TypeTests(unittest.TestCase):
eastern_tz = pytz.timezone('US/Eastern')
eastern_tz.localize(dt)
c = Cluster()
c = Cluster(protocol_version=PROTOCOL_VERSION)
s = c.connect()
s.execute("""CREATE KEYSPACE tz_aware_test