From e4db87ce4c2757b734b5fc62a82e1076c3367af0 Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Mon, 6 Feb 2012 18:35:49 +0000 Subject: [PATCH] Make Glance work with SQLAlchemy 0.7 Fix execption caught during tests Fix test failure wiping out engine in use Fixes bug 892754 Change-Id: I9de6f077af656730c95bc715c2b765b0c49c7d3c --- Authors | 1 + glance/tests/unit/test_api.py | 11 +++++++---- tools/pip-requires | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Authors b/Authors index 3d5ef9c4ed..c56441ed7c 100644 --- a/Authors +++ b/Authors @@ -1,5 +1,6 @@ Adam Gandelman Alex Meade +Andrew Hutchings Andrey Brindeyev Brian Lamar Brian Waldon diff --git a/glance/tests/unit/test_api.py b/glance/tests/unit/test_api.py index a8ee132626..bc9f7ae288 100644 --- a/glance/tests/unit/test_api.py +++ b/glance/tests/unit/test_api.py @@ -24,6 +24,7 @@ import unittest import stubout import webob +from sqlalchemy import exc from glance.api.v1 import images from glance.api.v1 import router from glance.common import context @@ -47,6 +48,7 @@ class TestRegistryDb(unittest.TestCase): def setUp(self): """Establish a clean test environment""" self.stubs = stubout.StubOutForTesting() + self.orig_engine = db_api._ENGINE def test_bad_sql_connection(self): """ @@ -61,9 +63,9 @@ class TestRegistryDb(unittest.TestCase): }) # We set this to None to trigger a reconfigure, otherwise # other modules may have already correctly configured the DB - orig_engine = db_api._ENGINE db_api._ENGINE = None - self.assertRaises(ImportError, db_api.configure_db, bad_conf) + self.assertRaises((ImportError, exc.ArgumentError), + db_api.configure_db, bad_conf) exc_raised = False self.log_written = False @@ -74,16 +76,17 @@ class TestRegistryDb(unittest.TestCase): self.stubs.Set(db_api.logger, 'error', fake_log_error) try: api_obj = rserver.API(bad_conf) + except exc.ArgumentError: + exc_raised = True except ImportError: exc_raised = True - finally: - db_api._ENGINE = orig_engine self.assertTrue(exc_raised) self.assertTrue(self.log_written) def tearDown(self): """Clear the test environment""" + db_api._ENGINE = self.orig_engine self.stubs.UnsetAll() diff --git a/tools/pip-requires b/tools/pip-requires index 7e25a6b0cd..78d0c7d984 100644 --- a/tools/pip-requires +++ b/tools/pip-requires @@ -3,7 +3,7 @@ # package to get the right headers... greenlet>=0.3.1 -SQLAlchemy>=0.6.3,<0.7 +SQLAlchemy>=0.7 anyjson eventlet>=0.9.12 PasteDeploy @@ -15,7 +15,7 @@ argparse mox boto==2.1.1 swift -sqlalchemy-migrate>=0.6,<0.7 +sqlalchemy-migrate>=0.7 httplib2 xattr>=0.6.0 kombu