diff options
author | Roman Podoliaka <rpodolyaka@mirantis.com> | 2016-06-08 15:34:16 +0300 |
---|---|---|
committer | Roman Podoliaka <rpodolyaka@mirantis.com> | 2016-06-27 17:22:01 +0300 |
commit | 8a5fbb723f234c89630360bca24aa91160edd8e0 (patch) | |
tree | 52dad5e007aa2393a96badfacede08dd1f9e303d /oslo_db | |
parent | 1579c7ce1526a952d74faeaad3e0ad1719604221 (diff) | |
download | oslo-db-8a5fbb723f234c89630360bca24aa91160edd8e0.tar.gz |
Make it possible to use enginefacade decorators with class methods
The decorator form can now be used with bound methods after a fix
for the related bug was merged. Mention this in docs and release
notes, so that people are aware of it.
A new test is added to make sure this also works with class methods
(as well as to check that the proposed decorator applying order
is actually correct).
Related-Bug: #1520195
Change-Id: Ifea08114d6d89de9d67fcae397eb94c0afc4d339
Diffstat (limited to 'oslo_db')
-rw-r--r-- | oslo_db/tests/sqlalchemy/test_enginefacade.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/oslo_db/tests/sqlalchemy/test_enginefacade.py b/oslo_db/tests/sqlalchemy/test_enginefacade.py index 7f77c28..d27f7bf 100644 --- a/oslo_db/tests/sqlalchemy/test_enginefacade.py +++ b/oslo_db/tests/sqlalchemy/test_enginefacade.py @@ -1017,6 +1017,21 @@ class MockFacadeTest(oslo_test_base.BaseTestCase): with self._assert_reader_session(makers) as session: session.execute("test") + def test_context_found_for_class_method(self): + context = oslo_context.RequestContext() + + class Spam(object): + @classmethod + @enginefacade.reader + def go(cls, context): + context.session.execute("test") + Spam.go(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 |