summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorRoman Podolyaka <rpodolyaka@mirantis.com>2013-05-18 23:06:55 +0300
committerRoman Podolyaka <rpodolyaka@mirantis.com>2013-05-18 23:06:55 +0300
commit19aaaf5ee166ae0276a4bc00d8bfba1fb3c7fc57 (patch)
treeaf0d1cdeea28da0a882db93525f79a66b3df76bb /nova/tests
parentf19571050a2ca3bf9dfa5d036ede23aca32bb604 (diff)
downloadnova-19aaaf5ee166ae0276a4bc00d8bfba1fb3c7fc57.tar.gz
nova-19aaaf5ee166ae0276a4bc00d8bfba1fb3c7fc57.tar.xz
nova-19aaaf5ee166ae0276a4bc00d8bfba1fb3c7fc57.zip
Fix require_context() decorators.
require_context() and require_admin_context() decorators don't copy attributes of a decorated function (func_name, __doc__, __module__) to a wrapper function. This makes introspection and debugging harder and should be fixed. Fixes bug 1181606. Change-Id: I0926df92a40d3fc09b94a0c4b1ded63039abf18b
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/test_db_api.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/nova/tests/test_db_api.py b/nova/tests/test_db_api.py
index 4afefdfc8..efe63c738 100644
--- a/nova/tests/test_db_api.py
+++ b/nova/tests/test_db_api.py
@@ -1176,6 +1176,22 @@ class DbApiTestCase(DbTestCase):
_compare(bw_usages[2], expected_bw_usages[2])
timeutils.clear_time_override()
+ def _test_decorator_wraps_helper(self, decorator):
+ def test_func():
+ """Test docstring."""
+
+ decorated_func = decorator(test_func)
+
+ self.assertEquals(test_func.func_name, decorated_func.func_name)
+ self.assertEquals(test_func.__doc__, decorated_func.__doc__)
+ self.assertEquals(test_func.__module__, decorated_func.__module__)
+
+ def test_require_context_decorator_wraps_functions_properly(self):
+ self._test_decorator_wraps_helper(sqlalchemy_api.require_context)
+
+ def test_require_admin_context_decorator_wraps_functions_properly(self):
+ self._test_decorator_wraps_helper(sqlalchemy_api.require_admin_context)
+
def _get_fake_aggr_values():
return {'name': 'fake_aggregate'}