Commit 0bdcc50d authored by Josh Elser's avatar Josh Elser

Addresses Lukas' feedback

* Idiomatic dictionary iteration
* Remove new test from test_dbapi20, add to new test_connection
parent 9b8e46e3
......@@ -323,8 +323,8 @@ class AvaticaClient(object):
request.connection_id = connectionId
if info is not None:
# Info is a list of repeated pairs, setting a dict directly fails
for k in info:
request.info[k] = info[k]
for k, v in info.items():
request.info[k] = v
response_data = self._apply(request)
response = responses_pb2.OpenConnectionResponse()
......
import unittest
import phoenixdb
from . import dbapi20
from phoenixdb.tests import TEST_DB_URL
@unittest.skipIf(TEST_DB_URL is None, "these tests require the PHOENIXDB_TEST_DB_URL environment variable set to a clean database")
class PhoenixConnectionTest(unittest.TestCase):
def _connect(self, connect_kw_args):
try:
r = phoenixdb.connect(
*(TEST_DB_URL, ), **connect_kw_args
)
except AttributeError:
self.fail("Failed to connect")
return r
def test_connection_credentials(self):
connect_kw_args = {'user':'SCOTT', 'password':'TIGER', 'readonly':'True'}
con = self._connect(connect_kw_args)
try:
self.assertEqual(con._connection_args, {'user':'SCOTT', 'password':'TIGER'},
'Should have extract user and password'
)
self.assertEqual(con._filtered_args, {'readonly':'True'},
'Should have not extracted foo'
)
finally:
con.close()
......@@ -8,7 +8,6 @@ from phoenixdb.tests import TEST_DB_URL
class PhoenixDatabaseAPI20Test(dbapi20.DatabaseAPI20Test):
driver = phoenixdb
connect_args = (TEST_DB_URL, )
connect_kw_args = {}
ddl1 = 'create table %sbooze (name varchar(20) primary key)' % dbapi20.DatabaseAPI20Test.table_prefix
ddl2 = 'create table %sbarflys (name varchar(20) primary key, drink varchar(30))' % dbapi20.DatabaseAPI20Test.table_prefix
......@@ -37,7 +36,6 @@ class PhoenixDatabaseAPI20Test(dbapi20.DatabaseAPI20Test):
con.close()
def test_autocommit(self):
self.connect_kw_args = {}
con = dbapi20.DatabaseAPI20Test._connect(self)
self.assertFalse(con.autocommit)
con.autocommit = True
......@@ -47,7 +45,6 @@ class PhoenixDatabaseAPI20Test(dbapi20.DatabaseAPI20Test):
con.close()
def test_readonly(self):
self.connect_kw_args = {}
con = dbapi20.DatabaseAPI20Test._connect(self)
self.assertFalse(con.readonly)
con.readonly = True
......@@ -109,18 +106,3 @@ class PhoenixDatabaseAPI20Test(dbapi20.DatabaseAPI20Test):
self.failUnless(cur.rowcount in (-1,1))
finally:
con.close()
def test_credentials(self):
self.connect_kw_args['user'] = 'SCOTT'
self.connect_kw_args['password'] = 'TIGER'
self.connect_kw_args['readonly'] = 'True'
con = self._connect()
try:
self.assertEqual(con._connection_args, {'user':'SCOTT', 'password':'TIGER'},
'Should have extract user and password'
)
self.assertEqual(con._filtered_args, {'readonly':'True'},
'Should have not extracted foo'
)
finally:
con.close()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment