diff options
| author | Kevin L. Mitchell <kevin.mitchell@rackspace.com> | 2011-06-17 20:40:28 +0000 |
|---|---|---|
| committer | Tarmac <> | 2011-06-17 20:40:28 +0000 |
| commit | 2e6c26fcc8967192e35e0d2b2473bae578eb5b04 (patch) | |
| tree | 53cdfbb99c59ceeca447b136cc441ac60a46ebc9 /nova/tests | |
| parent | 33434e33f8f2e8fd809554cefeb3293efb372141 (diff) | |
| parent | f0b0f4ad4c6f90b1b3b23e6a048ebda8e62cb254 (diff) | |
Fixes two minor bugs (lp795123 and lp795126) in the extension mechanism. The first bug is that each extension has _check_extension() called twice on it; this is a minor cosmetic problem, but the second is that extensions which flunk _check_extension() are still added. The proposed fix is to make _check_extensions() return True or False, then make _add_extension() call it from the top and return immediately if _check_extensions() returns False.
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/api/openstack/test_extensions.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/nova/tests/api/openstack/test_extensions.py b/nova/tests/api/openstack/test_extensions.py index 60914c0a3..697c62e5c 100644 --- a/nova/tests/api/openstack/test_extensions.py +++ b/nova/tests/api/openstack/test_extensions.py @@ -128,6 +128,11 @@ class ResourceExtensionTest(unittest.TestCase): self.assertEqual(response_body, response.body) +class InvalidExtension(object): + def get_alias(self): + return "THIRD" + + class ExtensionManagerTest(unittest.TestCase): response_body = "Try to say this Mr. Knox, sir..." @@ -144,6 +149,14 @@ class ExtensionManagerTest(unittest.TestCase): self.assertEqual(200, response.status_int) self.assertEqual(response_body, response.body) + def test_invalid_extensions(self): + app = openstack.APIRouterV11() + ext_midware = extensions.ExtensionMiddleware(app) + ext_mgr = ext_midware.ext_mgr + ext_mgr.add_extension(InvalidExtension()) + self.assertTrue('FOXNSOX' in ext_mgr.extensions) + self.assertTrue('THIRD' not in ext_mgr.extensions) + class ActionExtensionTest(unittest.TestCase): |
