Use maybe_get more
Some suggestions in the review of the related change: * use maybe_get in another obvious place * make maybe_gets test assertions stronger Related-Change-Id: Ifd54d76ab1a5a9d82848f3cae89c3e53134aa129 Change-Id: I751f1086d885c18d938f18e8afe1dd0e9c0c57e5
This commit is contained in:
parent
2e321d94ed
commit
6714af8042
@ -888,11 +888,8 @@ class ContainerBroker(DatabaseBroker):
|
|||||||
def _populate_instance_cache(self, conn=None):
|
def _populate_instance_cache(self, conn=None):
|
||||||
# load cached instance attributes from the database if necessary
|
# load cached instance attributes from the database if necessary
|
||||||
if self.container is None:
|
if self.container is None:
|
||||||
if conn:
|
with self.maybe_get(conn) as conn:
|
||||||
self._do_get_info_query(conn)
|
self._do_get_info_query(conn)
|
||||||
else:
|
|
||||||
with self.get() as conn:
|
|
||||||
self._do_get_info_query(conn)
|
|
||||||
|
|
||||||
def _get_alternate_object_stats(self):
|
def _get_alternate_object_stats(self):
|
||||||
state = self.get_db_state()
|
state = self.get_db_state()
|
||||||
|
@ -618,7 +618,7 @@ class TestExampleBroker(unittest.TestCase):
|
|||||||
with broker.get() as other_conn:
|
with broker.get() as other_conn:
|
||||||
self.assertEqual(broker.conn, None)
|
self.assertEqual(broker.conn, None)
|
||||||
with broker.maybe_get(other_conn) as identity_conn:
|
with broker.maybe_get(other_conn) as identity_conn:
|
||||||
self.assertEqual(other_conn, identity_conn)
|
self.assertIs(other_conn, identity_conn)
|
||||||
self.assertEqual(broker.conn, None)
|
self.assertEqual(broker.conn, None)
|
||||||
self.assertEqual(broker.conn, None)
|
self.assertEqual(broker.conn, None)
|
||||||
self.assertEqual(broker.conn, conn)
|
self.assertEqual(broker.conn, conn)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user