From ab3460905084aeb0961ad8e1ca280ff6d6b6c9dd Mon Sep 17 00:00:00 2001 From: Alistair Coles Date: Tue, 5 Jan 2016 18:25:19 +0000 Subject: [PATCH] Add functional test for object PUT with raw iterator Adds a functional test to verify change made in [1] [1] change id I19579ed7a0181ac3f488433e7c1839f7f7a040b8 Change-Id: I45dbf66edab645e6339e67906aee5faa4fb7efbd --- tests/functional/test_swiftclient.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/functional/test_swiftclient.py b/tests/functional/test_swiftclient.py index 35a5ea7e..ef1b9d52 100644 --- a/tests/functional/test_swiftclient.py +++ b/tests/functional/test_swiftclient.py @@ -318,6 +318,21 @@ class TestFunctional(testtools.TestCase): downloaded_contents += body.read() self.assertEqual(self.test_data, downloaded_contents) + def test_put_object_using_generator(self): + # verify that put using a generator yielding empty strings does not + # cause connection to be closed + def data(): + yield "should" + yield "" + yield " tolerate" + yield "" + yield " empty chunks" + + self.conn.put_object( + self.containername, self.objectname, data()) + hdrs, body = self.conn.get_object(self.containername, self.objectname) + self.assertEqual("should tolerate empty chunks", body) + def test_post_account(self): self.conn.post_account({'x-account-meta-data': 'Something'}) headers = self.conn.head_account()