def test_get_object_full(self): new_connect = fake_http_connect(200, body='foobar') self.stubs.Set(swift.common.bufferedhttp, 'http_connect_raw', new_connect) headers, body = swobjects.get_object(self.orig_storage_url, "token", "cont1", "obj1", resp_chunk_size=None) self.assertEqual(body, 'foobar')
def test_get_headers(self): headers = {'X-FOO': 'BaR'}.items() new_connect = fake_http_connect(200, headers=headers) self.stubs.Set(swift.common.bufferedhttp, 'http_connect_raw', new_connect) headers, gen = swobjects.get_object(self.orig_storage_url, "token", "cont1", "obj1") self.assertIn('x-foo', headers) self.assertEquals(headers['x-foo'], 'BaR')
def test_get_object_chunked(self): chunk_size = 32 expected_chunk_time = 3 body = ("X" * expected_chunk_time) * chunk_size new_connect = fake_http_connect(200, body) self.stubs.Set(swift.common.bufferedhttp, 'http_connect_raw', new_connect) headers, gen = swobjects.get_object(self.orig_storage_url, "token", "cont1", "obj1", resp_chunk_size=chunk_size) sent_time = 0 for chunk in gen: sent_time += 1 self.assertEqual(sent_time, expected_chunk_time)