Exemplo n.º 1
0
def test_set_nodelay_prepared():
    resp = StreamResponse()
    writer = mock.Mock()
    req = make_request('GET', '/', writer=writer)

    yield from resp.prepare(req)
    resp.set_tcp_nodelay(True)
    writer.set_tcp_nodelay.assert_called_with(True)
Exemplo n.º 2
0
def test_set_nodelay_prepared():
    resp = StreamResponse()
    writer = mock.Mock()
    req = make_request('GET', '/', payload_writer=writer)

    yield from resp.prepare(req)
    resp.set_tcp_nodelay(True)
    writer.set_tcp_nodelay.assert_called_with(True)
Exemplo n.º 3
0
def test_set_tcp_nodelay_after_start():
    req = make_request('GET', '/')
    resp = StreamResponse()

    with mock.patch('aiohttp.web_reqrep.ResponseImpl'):
        resp_impl = yield from resp.prepare(req)
    resp_impl.transport.set_tcp_cork.assert_called_with(False)
    resp_impl.transport.set_tcp_nodelay.assert_called_with(True)
    resp.set_tcp_nodelay(False)
    assert not resp.tcp_nodelay
    resp_impl.transport.set_tcp_nodelay.assert_called_with(False)
    resp.set_tcp_nodelay(True)
    assert resp.tcp_nodelay
    resp_impl.transport.set_tcp_nodelay.assert_called_with(True)
Exemplo n.º 4
0
def test_set_tcp_nodelay_after_start():
    req = make_request('GET', '/')
    resp = StreamResponse()

    with mock.patch('aiohttp.web_reqrep.ResponseImpl'):
        resp_impl = yield from resp.prepare(req)
    resp_impl.transport.set_tcp_cork.assert_called_with(False)
    resp_impl.transport.set_tcp_nodelay.assert_called_with(True)
    resp.set_tcp_nodelay(False)
    assert not resp.tcp_nodelay
    resp_impl.transport.set_tcp_nodelay.assert_called_with(False)
    resp.set_tcp_nodelay(True)
    assert resp.tcp_nodelay
    resp_impl.transport.set_tcp_nodelay.assert_called_with(True)
Exemplo n.º 5
0
def test_set_tcp_nodelay_before_start():
    resp = StreamResponse()
    resp.set_tcp_nodelay(False)
    assert not resp.tcp_nodelay
    resp.set_tcp_nodelay(True)
    assert resp.tcp_nodelay
Exemplo n.º 6
0
def test_set_tcp_nodelay_before_start():
    resp = StreamResponse()
    resp.set_tcp_nodelay(False)
    assert not resp.tcp_nodelay
    resp.set_tcp_nodelay(True)
    assert resp.tcp_nodelay
Exemplo n.º 7
0
def test_set_nodelay_unprepared():
    resp = StreamResponse()
    with pytest.raises(RuntimeError):
        resp.set_tcp_nodelay(True)
Exemplo n.º 8
0
def test_set_nodelay_unprepared():
    resp = StreamResponse()
    with pytest.raises(AssertionError):
        resp.set_tcp_nodelay(True)