Skip to content

Commit

Permalink
Make Glance work with SQLAlchemy 0.7
Browse files Browse the repository at this point in the history
Fix execption caught during tests
Fix test failure wiping out engine in use

Fixes bug 892754

Change-Id: I9de6f077af656730c95bc715c2b765b0c49c7d3c
  • Loading branch information
LinuxJedi committed Feb 8, 2012
1 parent 24c14d5 commit e4db87c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions Authors
@@ -1,5 +1,6 @@
Adam Gandelman <adam.gandelman@canonical.com>
Alex Meade <alex.meade@rackspace.com>
Andrew Hutchings <andrew@linuxjedi.co.uk>
Andrey Brindeyev <abrindeyev@griddynamics.com>
Brian Lamar <brian.lamar@rackspace.com>
Brian Waldon <brian.waldon@rackspace.com>
Expand Down
11 changes: 7 additions & 4 deletions glance/tests/unit/test_api.py
Expand Up @@ -24,6 +24,7 @@
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
Expand All @@ -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):
"""
Expand All @@ -61,9 +63,9 @@ def test_bad_sql_connection(self):
})
# 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

Expand All @@ -74,16 +76,17 @@ def fake_log_error(msg):
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()


Expand Down
4 changes: 2 additions & 2 deletions tools/pip-requires
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit e4db87c

Please sign in to comment.