diff options
author | Jenkins <jenkins@review.openstack.org> | 2015-06-04 12:08:07 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2015-06-04 12:08:07 +0000 |
commit | ec3e2ab3a099b1276ae5d87fda936567f64423dc (patch) | |
tree | bd2d542f8a371ecc9dc050b158f1183683e19e95 /tests/functional/test_swiftclient.py | |
parent | f0cc3be2ac2cb6474ba117da323f6369c1e6c791 (diff) | |
parent | b6457e0f95c2563f745bbfb64c739929bc0dc901 (diff) | |
download | python-swiftclient-ec3e2ab3a099b1276ae5d87fda936567f64423dc.tar.gz |
Merge "Allow reading from object body on download"
Diffstat (limited to 'tests/functional/test_swiftclient.py')
-rw-r--r-- | tests/functional/test_swiftclient.py | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/tests/functional/test_swiftclient.py b/tests/functional/test_swiftclient.py index 4b57f1d..7a31fad 100644 --- a/tests/functional/test_swiftclient.py +++ b/tests/functional/test_swiftclient.py @@ -16,7 +16,6 @@ import os import testtools import time -import types from io import BytesIO from six.moves import configparser @@ -260,8 +259,24 @@ class TestFunctional(testtools.TestCase): hdrs, body = self.conn.get_object( self.containername, self.objectname, resp_chunk_size=10) - self.assertTrue(isinstance(body, types.GeneratorType)) - self.assertEqual(self.test_data, b''.join(body)) + downloaded_contents = b'' + while True: + try: + chunk = next(body) + except StopIteration: + break + downloaded_contents += chunk + self.assertEqual(self.test_data, downloaded_contents) + + # Download in chunks, should also work with read + hdrs, body = self.conn.get_object( + self.containername, self.objectname, + resp_chunk_size=10) + num_bytes = 5 + downloaded_contents = body.read(num_bytes) + self.assertEqual(num_bytes, len(downloaded_contents)) + downloaded_contents += body.read() + self.assertEqual(self.test_data, downloaded_contents) def test_post_account(self): self.conn.post_account({'x-account-meta-data': 'Something'}) |