From caf166eacba9bb4f47fc668a8ea74688cd4e4b5e Mon Sep 17 00:00:00 2001 From: Gabriel Hurley Date: Sat, 11 Aug 2012 16:33:56 -0700 Subject: [PATCH] Update python-glanceclient to allow anything < v2 The python-glanceclient pythonic API shouldn't break until v2 is released, so let's allow anything up to that known point. Alters the way test exceptions are constructed so that we're not dependent on the internals of how 3rd party libraries handle their exceptions while still being able to use them for real testing in Horizon. Fixes bug 1035511 Change-Id: I9a4379a19d5d6dee9d2349a73d9321def45ad78d --- horizon/tests/test_data/exceptions.py | 43 ++++++++++++++++++--------- run_tests.sh | 2 +- tools/pip-requires | 2 +- 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/horizon/tests/test_data/exceptions.py b/horizon/tests/test_data/exceptions.py index 93009edeeb..a33978faff 100644 --- a/horizon/tests/test_data/exceptions.py +++ b/horizon/tests/test_data/exceptions.py @@ -19,22 +19,37 @@ from novaclient import exceptions as nova_exceptions from .utils import TestDataContainer -def data(TEST): - TEST.exceptions = TestDataContainer() +def create_stubbed_exception(cls, status_code=500): msg = "Expected failure." - keystone_unauthorized = keystone_exceptions.Unauthorized(401) - keystone_unauthorized.silence_logging = True - TEST.exceptions.keystone_unauthorized = keystone_unauthorized + def fake_init_exception(self, code, message): + self.code = code + self.message = message - keystone_exception = keystone_exceptions.ClientException(500, message=msg) - keystone_exception.silence_logging = True - TEST.exceptions.keystone = keystone_exception + def fake_str(self): + return str(self.message) - nova_exception = nova_exceptions.ClientException(500, message=msg) - nova_exception.silence_logging = True - TEST.exceptions.nova = nova_exception + def fake_unicode(self): + return unicode(self.message) - glance_exception = glance_exceptions.ClientException(500, message=msg) - glance_exception.silence_logging = True - TEST.exceptions.glance = glance_exception + cls.__init__ = fake_init_exception + cls.__str__ = fake_str + cls.__unicode__ = fake_unicode + cls.silence_logging = True + return cls(status_code, msg) + + +def data(TEST): + TEST.exceptions = TestDataContainer() + + unauth = keystone_exceptions.Unauthorized + TEST.exceptions.keystone_unauthorized = create_stubbed_exception(unauth) + + keystone_exception = keystone_exceptions.ClientException + TEST.exceptions.keystone = create_stubbed_exception(keystone_exception) + + nova_exception = nova_exceptions.ClientException + TEST.exceptions.nova = create_stubbed_exception(nova_exception) + + glance_exception = glance_exceptions.ClientException + TEST.exceptions.glance = create_stubbed_exception(glance_exception) diff --git a/run_tests.sh b/run_tests.sh index 7e7b5d1965..d0020681d7 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -6,7 +6,7 @@ set -o errexit # Increment me any time the environment should be rebuilt. # This includes dependncy changes, directory renames, etc. # Simple integer secuence: 1, 2, 3... -environment_version=25 +environment_version=26 #--------------------------------------------------------# function usage { diff --git a/tools/pip-requires b/tools/pip-requires index bf30391a27..cb565cc1f5 100644 --- a/tools/pip-requires +++ b/tools/pip-requires @@ -3,7 +3,7 @@ Django>=1.4 django_compressor django_openstack_auth python-cloudfiles -python-glanceclient>=0.3,<0.4 +python-glanceclient<2 python-keystoneclient python-novaclient pytz