Make initialization test failure more explicit
A few changes to make the db initialization test failure mode more explicit. Change-Id: I533cd33476a57ecb854a1af1a5fb170c65daa825
This commit is contained in:
parent
d4a1d75bfc
commit
6145c57f4a
@ -22,6 +22,7 @@ from uuid import uuid4
|
||||
|
||||
from swift.account.backend import AccountBroker
|
||||
from swift.common.utils import normalize_timestamp
|
||||
from swift.common.db import DatabaseConnectionError
|
||||
|
||||
|
||||
class TestAccountBroker(unittest.TestCase):
|
||||
@ -31,13 +32,18 @@ class TestAccountBroker(unittest.TestCase):
|
||||
# Test AccountBroker.__init__
|
||||
broker = AccountBroker(':memory:', account='a')
|
||||
self.assertEqual(broker.db_file, ':memory:')
|
||||
got_exc = False
|
||||
try:
|
||||
with broker.get() as conn:
|
||||
pass
|
||||
except Exception:
|
||||
got_exc = True
|
||||
self.assert_(got_exc)
|
||||
except DatabaseConnectionError as e:
|
||||
self.assertTrue(hasattr(e, 'path'))
|
||||
self.assertEquals(e.path, ':memory:')
|
||||
self.assertTrue(hasattr(e, 'msg'))
|
||||
self.assertEquals(e.msg, "DB doesn't exist")
|
||||
except Exception as e:
|
||||
self.fail("Unexpected exception raised: %r" % e)
|
||||
else:
|
||||
self.fail("Expected a DatabaseConnectionError exception")
|
||||
broker.initialize(normalize_timestamp('1'))
|
||||
with broker.get() as conn:
|
||||
curs = conn.cursor()
|
||||
|
Loading…
Reference in New Issue
Block a user