File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2424 os .mkdir (path )
2525
2626
27+ class BaseTestCase (unittest .TestCase ):
28+ def _get_cass_and_cql_version (self ):
29+ """
30+ Probe system.local table to determine Cassandra and CQL version.
31+ """
32+ c = Cluster ()
33+ s = c .connect ()
34+ s .set_keyspace ('system' )
35+ row = s .execute ('SELECT cql_version, release_version FROM local' )[0 ]
36+
37+ cass_version = self ._get_version_as_tuple (row .release_version )
38+ cql_version = self ._get_version_as_tuple (row .cql_version )
39+
40+ c .shutdown ()
41+
42+ result = {'cass_version' : cass_version , 'cql_version' : cql_version }
43+ return result
44+
45+ def _get_version_as_tuple (self , version ):
46+ version = version .split ('.' )
47+ version = [int (p ) for p in version ]
48+ version = tuple (version )
49+ return version
50+
51+
2752def get_cluster ():
2853 return CCM_CLUSTER
2954
Original file line number Diff line number Diff line change 1212from cassandra import InvalidRequest
1313from cassandra .cluster import Cluster , NoHostAvailable
1414
15+ from tests .integration import BaseTestCase
1516
16- class TypeTests (unittest .TestCase ):
17+
18+ class TypeTests (BaseTestCase ):
1719 def setUp (self ):
1820 super (TypeTests , self ).setUp ()
19-
20- # Detect CQL and Cassandra version
21- c = Cluster ()
22- s = c .connect ()
23- s .set_keyspace ('system' )
24- row = s .execute ('SELECT cql_version, release_version FROM local' )[0 ]
25- self ._cql_version = self ._get_version_as_tuple (row .cql_version )
26- self ._cass_version = self ._get_version_as_tuple (row .release_version )
21+ self ._versions = self ._get_cass_and_cql_version ()
2722
2823 def test_blob_type_as_string (self ):
2924 c = Cluster ()
@@ -49,7 +44,7 @@ def test_blob_type_as_string(self):
4944
5045 query = 'INSERT INTO mytable (a, b) VALUES (%s, %s)'
5146
52- if self ._cql_version >= (3 , 1 , 0 ):
47+ if self ._versions [ 'cql_version' ] >= (3 , 1 , 0 ):
5348 # Blob values can't be specified using string notation in CQL 3.1.0 and
5449 # above which is used by default in Cassandra 2.0.
5550 msg = r'.*Invalid STRING constant \(.*?\) for b of type blob.*'
You can’t perform that action at this time.
0 commit comments