diff options
Diffstat (limited to 'nova')
| -rw-r--r-- | nova/db/sqlalchemy/api.py | 2 | ||||
| -rw-r--r-- | nova/tests/test_db_api.py | 16 |
2 files changed, 18 insertions, 0 deletions
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index a35e8154d..53131331d 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -95,6 +95,7 @@ def require_admin_context(f): """ + @functools.wraps(f) def wrapper(*args, **kwargs): nova.context.require_admin_context(args[0]) return f(*args, **kwargs) @@ -112,6 +113,7 @@ def require_context(f): """ + @functools.wraps(f) def wrapper(*args, **kwargs): nova.context.require_context(args[0]) return f(*args, **kwargs) 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'} |
