diff options
author | Chmouel Boudjnah <chmouel@enovance.com> | 2014-04-15 16:43:25 -0400 |
---|---|---|
committer | Chmouel Boudjnah <chmouel@enovance.com> | 2014-04-17 12:04:43 -0400 |
commit | e2b7636d66d2217683fe49cbb5863aefb1d2b339 (patch) | |
tree | dc8643da3d954589e78a20ae6fe246dd496762a2 /tests/test_swiftclient.py | |
parent | 504e5a7f53beb53ee1f099471017d63acf42cf65 (diff) | |
download | python-swiftclient-e2b7636d66d2217683fe49cbb5863aefb1d2b339.tar.gz |
Fix test_raw_upload test
We were testing the test but we were not testing that we have actually
properly uploaded the object with the right content-len
(and it was broken under py3)
Change-Id: Ifa91c30532090cac9f8e18ff18eaf5e6c98737d1
Diffstat (limited to 'tests/test_swiftclient.py')
-rw-r--r-- | tests/test_swiftclient.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/tests/test_swiftclient.py b/tests/test_swiftclient.py index 6088bf3..2a49114 100644 --- a/tests/test_swiftclient.py +++ b/tests/test_swiftclient.py @@ -679,19 +679,25 @@ class TestPutObject(MockHttpTest): resp = MockHttpResponse(status=200) conn[1].getresponse = resp.fake_response conn[1]._request = resp._fake_request - mock_file = StringIO.StringIO('asdf') + astring = 'asdf' + astring_len = len(astring) + mock_file = StringIO.StringIO(astring) c.put_object(url='http://www.test.com', http_conn=conn, - contents=mock_file, content_length=4) + contents=mock_file, content_length=astring_len) self.assertTrue(isinstance(resp.requests_params['data'], swiftclient.utils.LengthWrapper)) - self.assertEqual(mock_file.len, 4) + self.assertEqual(astring_len, + len(resp.requests_params['data'].read())) + mock_file = StringIO.StringIO(astring) c.put_object(url='http://www.test.com', http_conn=conn, - headers={'Content-Length': '4'}, contents=mock_file) + headers={'Content-Length': str(astring_len)}, + contents=mock_file) self.assertTrue(isinstance(resp.requests_params['data'], swiftclient.utils.LengthWrapper)) - self.assertEqual(mock_file.len, 4) + self.assertEqual(astring_len, + len(resp.requests_params['data'].read())) def test_chunk_upload(self): # Chunked upload happens when no content_length is passed to put_object |