Fix TestConnectionUtils to py3x compatibility

Tests in TestConnectionUtils class depends on database and DB connector,
so the simplest way to run them with python 3.X is to use same database
and connector for the both python versions. PostgreSQL and psycopg2 are
looks good for this.

Replaced ``mysql`` to ``postgresql`` in TestConnectionUtils.

Change-Id: Icb1d6324b58feed515e4eb885715cbf2195768cf
This commit is contained in:
Victor Sergeyev 2014-11-12 16:06:03 +02:00
parent 34caedc342
commit 4c939b38eb

@ -512,12 +512,12 @@ class TestConnectionUtils(test_utils.BaseTestCase):
def setUp(self):
super(TestConnectionUtils, self).setUp()
self.full_credentials = {'backend': 'mysql',
self.full_credentials = {'backend': 'postgresql',
'database': 'test',
'user': 'dude',
'passwd': 'pass'}
self.connect_string = 'mysql://dude:pass@localhost/test'
self.connect_string = 'postgresql://dude:pass@localhost/test'
def test_connect_string(self):
connect_string = utils.get_connect_string(**self.full_credentials)
@ -540,7 +540,7 @@ class TestConnectionUtils(test_utils.BaseTestCase):
def test_is_backend_unavail(self):
log = self.useFixture(fixtures.FakeLogger())
err = OperationalError("Can't connect to database", None, None)
error_msg = "The mysql backend is unavailable: %s\n" % err
error_msg = "The postgresql backend is unavailable: %s\n" % err
self.mox.StubOutWithMock(sqlalchemy.engine.base.Engine, 'connect')
sqlalchemy.engine.base.Engine.connect().AndRaise(err)
self.mox.ReplayAll()
@ -571,7 +571,7 @@ class TestConnectionUtils(test_utils.BaseTestCase):
)
self.assertEqual("Could not connect", str(exc))
self.assertEqual(
"The mysql backend is unavailable: %s" % err,
"The postgresql backend is unavailable: %s" % err,
log.output.strip())
def test_ensure_backend_available_no_dbapi_raises(self):
@ -588,7 +588,7 @@ class TestConnectionUtils(test_utils.BaseTestCase):
)
self.assertEqual("No DBAPI installed", str(exc))
self.assertEqual(
"The mysql backend is unavailable: Can't import "
"The postgresql backend is unavailable: Can't import "
"DBAPI module foobar", log.output.strip())
def test_get_db_connection_info(self):
@ -599,7 +599,7 @@ class TestConnectionUtils(test_utils.BaseTestCase):
def test_connect_string_host(self):
self.full_credentials['host'] = 'myhost'
connect_string = utils.get_connect_string(**self.full_credentials)
self.assertEqual(connect_string, 'mysql://dude:pass@myhost/test')
self.assertEqual(connect_string, 'postgresql://dude:pass@myhost/test')
class MyModelSoftDeletedProjectId(declarative_base(), models.ModelBase,