Move NamedTupleFactoryAndNumericColNamesTests to row_factories tests.

This commit is contained in:
Adam Holmberg
2014-10-15 08:47:16 -05:00
parent 7a1646a185
commit 073f4a155b
2 changed files with 50 additions and 50 deletions

View File

@@ -421,53 +421,3 @@ class LightweightTransactionTests(unittest.TestCase):
# Make sure test passed
self.assertTrue(received_timeout)
class NamedTupleFactoryAndNumericColNamesTests(unittest.TestCase):
"""
Test for PYTHON-122: Improve Error Handling/Reporting for named_tuple_factory and Numeric Column Names
"""
def setUp(self):
self.cluster = Cluster(protocol_version=PROTOCOL_VERSION)
self.session = self.cluster.connect()
ddl = '''
CREATE TABLE test3rf.ToBeIndexed ( key blob PRIMARY KEY, "626972746864617465" blob )
WITH COMPACT STORAGE'''
self.session.execute(ddl)
def tearDown(self):
"""
Shutdown cluster
"""
self.session.execute("DROP TABLE test3rf.ToBeIndexed")
self.cluster.shutdown()
def test_no_exception_on_select(self):
"""
no exception on SELECT for numeric column name
"""
try:
self.session.execute('SELECT * FROM test3rf.ToBeIndexed')
except ValueError as e:
self.fail("Unexpected ValueError exception: %s" % e.message)
def test_can_select_using_alias(self):
"""
can SELECT "<numeric col name>" AS aliases
"""
try:
self.session.execute('SELECT key, "626972746864617465" AS my_col from test3rf.ToBeIndexed')
except ValueError as e:
self.fail("Unexpected ValueError exception: %s" % e.message)
def test_can_select_with_dict_factory(self):
"""
can SELECT numeric column using dict_factory
"""
self.session.row_factory = dict_factory
try:
self.session.execute('SELECT * FROM test3rf.ToBeIndexed')
except ValueError as e:
self.fail("Unexpected ValueError exception: %s" % e.message)

View File

@@ -137,3 +137,53 @@ class RowFactoryTests(unittest.TestCase):
self.assertEqual(result[0]['k'], 1)
self.assertEqual(result[1]['k'], result[1]['v'])
self.assertEqual(result[1]['k'], 2)
class NamedTupleFactoryAndNumericColNamesTests(unittest.TestCase):
"""
Test for PYTHON-122: Improve Error Handling/Reporting for named_tuple_factory and Numeric Column Names
"""
def setUp(self):
self.cluster = Cluster(protocol_version=PROTOCOL_VERSION)
self.session = self.cluster.connect()
ddl = '''
CREATE TABLE test3rf.ToBeIndexed ( key blob PRIMARY KEY, "626972746864617465" blob )
WITH COMPACT STORAGE'''
self.session.execute(ddl)
def tearDown(self):
"""
Shutdown cluster
"""
self.session.execute("DROP TABLE test3rf.ToBeIndexed")
self.cluster.shutdown()
def test_no_exception_on_select(self):
"""
no exception on SELECT for numeric column name
"""
try:
self.session.execute('SELECT * FROM test3rf.ToBeIndexed')
except ValueError as e:
self.fail("Unexpected ValueError exception: %s" % e.message)
def test_can_select_using_alias(self):
"""
can SELECT "<numeric col name>" AS aliases
"""
try:
self.session.execute('SELECT key, "626972746864617465" AS my_col from test3rf.ToBeIndexed')
except ValueError as e:
self.fail("Unexpected ValueError exception: %s" % e.message)
def test_can_select_with_dict_factory(self):
"""
can SELECT numeric column using dict_factory
"""
self.session.row_factory = dict_factory
try:
self.session.execute('SELECT * FROM test3rf.ToBeIndexed')
except ValueError as e:
self.fail("Unexpected ValueError exception: %s" % e.message)