Merge "Replace inheritance hierarchy with composition"

This commit is contained in:
Jenkins 2013-12-19 18:23:52 +00:00 committed by Gerrit Code Review
commit e7b7cfe2f3
3 changed files with 8 additions and 6 deletions

@ -18,7 +18,7 @@ from glanceclient.v1 import images
from glanceclient.v1 import image_members from glanceclient.v1 import image_members
class Client(http.HTTPClient): class Client(object):
"""Client for the OpenStack Images v1 API. """Client for the OpenStack Images v1 API.
:param string endpoint: A user-supplied endpoint URL for the glance :param string endpoint: A user-supplied endpoint URL for the glance
@ -30,6 +30,6 @@ class Client(http.HTTPClient):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
"""Initialize a new client for the Images v1 API.""" """Initialize a new client for the Images v1 API."""
super(Client, self).__init__(*args, **kwargs) self.http_client = http.HTTPClient(*args, **kwargs)
self.images = images.ImageManager(self) self.images = images.ImageManager(self.http_client)
self.image_members = image_members.ImageMemberManager(self) self.image_members = image_members.ImageMemberManager(self.http_client)

@ -75,7 +75,7 @@ def print_image_formatted(client, image):
:param client: The Glance client object :param client: The Glance client object
:param image: The image metadata :param image: The image metadata
""" """
uri_parts = urlparse.urlparse(client.endpoint) uri_parts = urlparse.urlparse(client.http_client.endpoint)
if uri_parts.port: if uri_parts.port:
hostbase = "%s:%s" % (uri_parts.hostname, uri_parts.port) hostbase = "%s:%s" % (uri_parts.hostname, uri_parts.port)
else: else:

@ -27,7 +27,9 @@ class LegacyShellV1Test(testtools.TestCase):
def test_print_image_formatted(self): def test_print_image_formatted(self):
class FakeClient(): class FakeClient():
endpoint = 'http://is.invalid' class FakeHTTPClient():
endpoint = 'http://is.invalid'
http_client = FakeHTTPClient()
class FakeImage(): class FakeImage():
id = 1 id = 1