@@ -0,0 +1,2622 @@
+import unittest%0A%0Aimport responses%0A%0Aimport smart_open.http%0Aimport smart_open.s3%0A%0A%0ABYTES = b'i tried so hard and got so far but in the end it doesn%5C't even matter'%0AURL = 'http://localhost'%0AHEADERS = %7B%0A    'Content-Length': str(len(BYTES)),%0A    'Accept-Ranges': 'bytes',%0A%7D%0A%0A%0Adef request_callback(request):%0A    try:%0A        range_string = request.headers%5B'range'%5D%0A    except KeyError:%0A        return (200, HEADERS, BYTES)%0A%0A    start, end = range_string.replace('bytes=', '').split('-', 1)%0A    start = int(start)%0A    if end:%0A        end = int(end)%0A    else:%0A        end = len(BYTES)%0A    return (200, HEADERS, BYTES%5Bstart:end%5D)%0A%0A%0Aclass HttpTest(unittest.TestCase):%0A%0A    @responses.activate%0A    def test_read_all(self):%0A        responses.add(responses.GET, URL, body=BYTES, stream=True)%0A        reader = smart_open.http.SeekableBufferedInputBase(URL)%0A        read_bytes = reader.read()%0A        self.assertEqual(BYTES, read_bytes)%0A%0A    @responses.activate%0A    def test_seek_from_start(self):%0A        responses.add_callback(responses.GET, URL, callback=request_callback)%0A        reader = smart_open.http.SeekableBufferedInputBase(URL)%0A%0A        reader.seek(10)%0A        self.assertEqual(reader.tell(), 10)%0A        read_bytes = reader.read(size=10)%0A        self.assertEqual(reader.tell(), 20)%0A        self.assertEqual(BYTES%5B10:20%5D, read_bytes)%0A%0A        reader.seek(20)%0A        read_bytes = reader.read(size=10)%0A        self.assertEqual(BYTES%5B20:30%5D, read_bytes)%0A%0A        reader.seek(0)%0A        read_bytes = reader.read(size=10)%0A        self.assertEqual(BYTES%5B:10%5D, read_bytes)%0A%0A    @responses.activate%0A    def test_seek_from_current(self):%0A        responses.add_callback(responses.GET, URL, callback=request_callback)%0A        reader = smart_open.http.SeekableBufferedInputBase(URL)%0A%0A        reader.seek(10)%0A        read_bytes = reader.read(size=10)%0A        self.assertEqual(BYTES%5B10:20%5D, read_bytes)%0A%0A        self.assertEqual(reader.tell(), 20)%0A        reader.seek(10, whence=smart_open.s3.CURRENT)%0A        self.assertEqual(reader.tell(), 30)%0A        read_bytes = reader.read(size=10)%0A        self.assertEqual(reader.tell(), 40)%0A        self.assertEqual(BYTES%5B30:40%5D, read_bytes)%0A%0A    @responses.activate%0A    def test_seek_from_end(self):%0A        responses.add_callback(responses.GET, URL, callback=request_callback)%0A        reader = smart_open.http.SeekableBufferedInputBase(URL)%0A%0A        reader.seek(-10, whence=smart_open.s3.END)%0A        self.assertEqual(reader.tell(), len(BYTES) - 10)%0A        read_bytes = reader.read(size=10)%0A        self.assertEqual(reader.tell(), len(BYTES))%0A        self.assertEqual(BYTES%5B-10:%5D, read_bytes)%0A

add unit tests for seekable http