Wrap image data in iterator

This is establishing the API for a future optimization. We want to
be able to offer true socket-level caching, but can't do that with
httplib2 right now. For now, we will just fake the optimization
by returning an iterator over the image body, which happens to already
be fully loaded into a string.

Change-Id: I2d36e3cdd45b26d7c7c27ba050bf6a4b5765df6c
This commit is contained in:
Brian Waldon
2012-07-11 19:34:28 -07:00
parent a814c15465
commit da360462a5
3 changed files with 34 additions and 6 deletions
+2 -2
View File
@@ -131,7 +131,7 @@ class ImageManagerTest(unittest.TestCase):
self.assertEqual(image.name, 'image-1')
def test_data(self):
data = self.mgr.data('1')
data = ''.join([b for b in self.mgr.data('1')])
expect = [('GET', '/v1/images/1', {}, None)]
self.assertEqual(self.api.calls, expect)
self.assertEqual(data, 'XXX')
@@ -256,7 +256,7 @@ class ImageTest(unittest.TestCase):
def test_data(self):
image = self.mgr.get('1')
data = image.data()
data = ''.join([b for b in image.data()])
expect = [
('HEAD', '/v1/images/1', {}, None),
('GET', '/v1/images/1', {}, None),