Let enginefacade._TransactionContextManager look for context
The previous behavior was to assume that a RequestContext was the first argument of the wrapped method. This has meant creating staticmethods within classes in order to be wrapped properly. It's not always desirable to do so and should not be necessary. Change-Id: I76b0d9c80dd7841c1333f8b8a2ccdd15e55dfcff Closes-bug: 1520195
This commit is contained in:
@@ -1004,6 +1004,19 @@ class MockFacadeTest(oslo_test_base.BaseTestCase):
|
||||
getattr, context, 'transaction_ctx'
|
||||
)
|
||||
|
||||
def test_context_found_for_bound_method(self):
|
||||
context = oslo_context.RequestContext()
|
||||
|
||||
@enginefacade.reader
|
||||
def go(self, context):
|
||||
context.session.execute("test")
|
||||
go(self, context)
|
||||
|
||||
with self._assert_engines() as engines:
|
||||
with self._assert_makers(engines) as makers:
|
||||
with self._assert_reader_session(makers) as session:
|
||||
session.execute("test")
|
||||
|
||||
|
||||
class SynchronousReaderWSlaveMockFacadeTest(MockFacadeTest):
|
||||
synchronous_reader = True
|
||||
|
||||
Reference in New Issue
Block a user