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
This commit is contained in:
Gabriel Hurley 2012-08-11 16:33:56 -07:00
parent 3640c380d1
commit caf166eacb
3 changed files with 31 additions and 16 deletions

View File

@ -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)

View File

@ -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 {

View File

@ -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