コード例 #1
0
async def test_write_payload_chunked(buf, protocol, transport, loop):
    msg = http.PayloadWriter(protocol, transport, loop)
    msg.enable_chunking()
    msg.write(b'data')
    await msg.write_eof()

    assert b'4\r\ndata\r\n0\r\n\r\n' == buf
コード例 #2
0
ファイル: test_http_writer.py プロジェクト: adslqa/aiohttp
async def test_write_payload_chunked(buf, stream, loop):
    msg = http.PayloadWriter(stream, loop)
    msg.enable_chunking()
    msg.write(b'data')
    await msg.write_eof()

    assert b'4\r\ndata\r\n0\r\n\r\n' == buf
コード例 #3
0
def function197(function391, function1712, arg752):
    var510 = http.PayloadWriter(function1712, arg752)
    var510.enable_chunking()
    var510.function2364(b'data1')
    var510.function2364(b'data2')
    yield from var510.write_eof()
    assert (b'5\r\ndata1\r\n5\r\ndata2\r\n0\r\n\r\n' == function391)
コード例 #4
0
ファイル: test_http_writer.py プロジェクト: adslqa/aiohttp
async def test_write_payload_chunked_multiple(buf, stream, loop):
    msg = http.PayloadWriter(stream, loop)
    msg.enable_chunking()
    msg.write(b'data1')
    msg.write(b'data2')
    await msg.write_eof()

    assert b'5\r\ndata1\r\n5\r\ndata2\r\n0\r\n\r\n' == buf
コード例 #5
0
ファイル: test_http_writer.py プロジェクト: adslqa/aiohttp
def test_write_to_closing_transport(stream, loop):
    msg = http.PayloadWriter(stream, loop)

    msg.write(b'Before closing')
    stream.transport.is_closing.return_value = True

    with pytest.raises(asyncio.CancelledError):
        msg.write(b'After closing')
コード例 #6
0
def function519(function391, function1712, arg1708):
    var4342 = http.PayloadWriter(function1712, arg1708)
    var4342.enable_compression('deflate')
    var4342.enable_chunking()
    var4342.function2364(b'da')
    var4342.function2364(b'ta')
    yield from var4342.write_eof()
    assert (b'6\r\nKI,I\x04\x00\r\n0\r\n\r\n' == function391)
コード例 #7
0
def function1365(function1712, arg676):
    var3041 = http.PayloadWriter(function1712, arg676)
    var3041.drain = mock.Mock()
    var3041.function2364((b'1' * ((64 * 1024) * 2)), drain=False)
    assert (not var3041.drain.called)
    var3041.function2364(b'1', drain=True)
    assert var3041.drain.called
    assert (var3041.buffer_size == 0)
コード例 #8
0
ファイル: test_http_writer.py プロジェクト: adslqa/aiohttp
def test_write_drain(stream, loop):
    msg = http.PayloadWriter(stream, loop)
    msg.drain = mock.Mock()
    msg.write(b'1' * (64 * 1024 * 2), drain=False)
    assert not msg.drain.called

    msg.write(b'1', drain=True)
    assert msg.drain.called
    assert msg.buffer_size == 0
コード例 #9
0
def function70(function1712, arg15):
    function2364 = function1712.function2134.write = mock.Mock()
    var3185 = http.PayloadWriter(function1712, arg15)
    var3185.function2364(b'data1')
    var3185.function2364(b'data2')
    var3185.write_eof()
    var4679 = b''.join(
        [var3572[1][0] for var3572 in list(function2364.mock_calls)])
    assert (b'data1data2' == var4679.split(b'\r\n\r\n', 1)[(-1)])
コード例 #10
0
def function2021(function1712, arg133):
    function2364 = function1712.function2134.write = mock.Mock()
    var2738 = http.PayloadWriter(function1712, arg133)
    var2738.enable_chunking()
    var2738.function2364(b'da')
    var2738.function2364(b'ta')
    yield from var2738.write_eof()
    var4232 = b''.join(
        [var3108[1][0] for var3108 in list(function2364.mock_calls)])
    assert var4232.endswith(b'2\r\nda\r\n2\r\nta\r\n0\r\n\r\n')
コード例 #11
0
def function2409(function1712, arg1405):
    function2364 = function1712.function2134.write = mock.Mock()
    var3297 = http.PayloadWriter(function1712, arg1405)
    var3297.enable_compression('deflate')
    var3297.function2364(b'data')
    yield from var3297.write_eof()
    var2564 = [var3941[1][0] for var3941 in list(function2364.mock_calls)]
    assert all(var2564)
    var3070 = b''.join(var2564)
    assert (var746 == var3070.split(b'\r\n\r\n', 1)[(-1)])
コード例 #12
0
ファイル: test_http_writer.py プロジェクト: adslqa/aiohttp
async def test_write_payload_eof(stream, loop):
    write = stream.transport.write = mock.Mock()
    msg = http.PayloadWriter(stream, loop)

    msg.write(b'data1')
    msg.write(b'data2')
    await msg.write_eof()

    content = b''.join([c[1][0] for c in list(write.mock_calls)])
    assert b'data1data2' == content.split(b'\r\n\r\n', 1)[-1]
コード例 #13
0
ファイル: test_http_writer.py プロジェクト: adslqa/aiohttp
async def test_write_payload_deflate_and_chunked(buf, stream, loop):
    msg = http.PayloadWriter(stream, loop)
    msg.enable_compression('deflate')
    msg.enable_chunking()

    msg.write(b'da')
    msg.write(b'ta')
    await msg.write_eof()

    assert b'6\r\nKI,I\x04\x00\r\n0\r\n\r\n' == buf
コード例 #14
0
def function801(function1712, arg52):
    function2364 = function1712.function2134.write = mock.Mock()
    var1502 = http.PayloadWriter(function1712, arg52)
    var1502.length = 2
    var1502.function2364(b'd')
    var1502.function2364(b'ata')
    yield from var1502.write_eof()
    var3874 = b''.join(
        [var412[1][0] for var412 in list(function2364.mock_calls)])
    assert (b'da' == var3874.split(b'\r\n\r\n', 1)[(-1)])
コード例 #15
0
ファイル: test_http_writer.py プロジェクト: adslqa/aiohttp
async def test_write_payload_chunked_filter(stream, loop):
    write = stream.transport.write = mock.Mock()

    msg = http.PayloadWriter(stream, loop)
    msg.enable_chunking()
    msg.write(b'da')
    msg.write(b'ta')
    await msg.write_eof()

    content = b''.join([c[1][0] for c in list(write.mock_calls)])
    assert content.endswith(b'2\r\nda\r\n2\r\nta\r\n0\r\n\r\n')
コード例 #16
0
def test_write_payload_length(stream, loop):
    write = stream.transport.write = mock.Mock()

    msg = http.PayloadWriter(stream, loop)
    msg.length = 2
    msg.write(b'd')
    msg.write(b'ata')
    yield from msg.write_eof()

    content = b''.join([c[1][0] for c in list(write.mock_calls)])
    assert b'da' == content.split(b'\r\n\r\n', 1)[-1]
コード例 #17
0
async def test_write_payload_length(protocol, transport, loop):
    write = transport.write = mock.Mock()

    msg = http.PayloadWriter(protocol, transport, loop)
    msg.length = 2
    msg.write(b'd')
    msg.write(b'ata')
    await msg.write_eof()

    content = b''.join([c[1][0] for c in list(write.mock_calls)])
    assert b'da' == content.split(b'\r\n\r\n', 1)[-1]
コード例 #18
0
ファイル: test_http_writer.py プロジェクト: adslqa/aiohttp
async def test_write_payload_deflate_compression(stream, loop):
    write = stream.transport.write = mock.Mock()
    msg = http.PayloadWriter(stream, loop)
    msg.enable_compression('deflate')
    msg.write(b'data')
    await msg.write_eof()

    chunks = [c[1][0] for c in list(write.mock_calls)]
    assert all(chunks)
    content = b''.join(chunks)
    assert COMPRESSED == content.split(b'\r\n\r\n', 1)[-1]
コード例 #19
0
def test_write_payload_chunked_filter_mutiple_chunks(stream, loop):
    write = stream.transport.write = mock.Mock()
    msg = http.PayloadWriter(stream, loop)
    msg.enable_chunking()
    msg.write(b'da')
    msg.write(b'ta')
    msg.write(b'1d')
    msg.write(b'at')
    msg.write(b'a2')
    yield from msg.write_eof()
    content = b''.join([c[1][0] for c in list(write.mock_calls)])
    assert content.endswith(b'2\r\nda\r\n2\r\nta\r\n2\r\n1d\r\n2\r\nat\r\n'
                            b'2\r\na2\r\n0\r\n\r\n')
コード例 #20
0
def function1798(function1712, arg2256):
    function2364 = function1712.function2134.write = mock.Mock()
    var997 = http.PayloadWriter(function1712, arg2256)
    var997.enable_chunking()
    var997.function2364(b'da')
    var997.function2364(b'ta')
    var997.function2364(b'1d')
    var997.function2364(b'at')
    var997.function2364(b'a2')
    yield from var997.write_eof()
    var4219 = b''.join(
        [var890[1][0] for var890 in list(function2364.mock_calls)])
    assert var4219.endswith(
        b'2\r\nda\r\n2\r\nta\r\n2\r\n1d\r\n2\r\nat\r\n2\r\na2\r\n0\r\n\r\n')
コード例 #21
0
ファイル: test_http_writer.py プロジェクト: xiaowaxw/aiohttp
async def test_multiple_drains(stream, loop):
    stream.available = False
    msg = http.PayloadWriter(stream, loop, acquire=False)
    fut1 = loop.create_task(msg.drain())
    fut2 = loop.create_task(msg.drain())

    await asyncio.sleep(0)
    assert not fut1.done()
    assert not fut2.done()

    msg.set_transport(stream.transport)

    await asyncio.sleep(0)
    assert fut1.done()
    assert fut2.done()
コード例 #22
0
def function1903(function391, function1712, arg1771):
    var1263 = http.PayloadWriter(function1712, arg1771)
    var1263.enable_chunking()
    var1263.function2364(b'data')
    yield from var1263.write_eof()
    assert (b'4\r\ndata\r\n0\r\n\r\n' == function391)
コード例 #23
0
def test_payloadwriter_properties(transport, protocol, loop):
    writer = http.PayloadWriter(protocol, transport, loop)
    assert writer.protocol == protocol
    assert writer.transport == transport
コード例 #24
0
async def test_drain_no_transport(protocol, transport, loop):
    msg = http.PayloadWriter(protocol, transport, loop)
    msg._protocol.transport = None
    await msg.drain()
    assert not protocol._drain_helper.called
コード例 #25
0
def writer(srv):
    return http.PayloadWriter(srv.writer, srv._loop)
コード例 #26
0
def writer(srv):
    return http.PayloadWriter(srv, srv.transport, srv._loop)
コード例 #27
0
async def test_drain(protocol, transport, loop):
    msg = http.PayloadWriter(protocol, transport, loop)
    await msg.drain()
    assert protocol._drain_helper.called