示例#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)
示例#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)
示例#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)
示例#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)
示例#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
示例#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
示例#7
0
def test_set_nodelay_unprepared():
    resp = StreamResponse()
    with pytest.raises(RuntimeError):
        resp.set_tcp_nodelay(True)
示例#8
0
def test_set_nodelay_unprepared():
    resp = StreamResponse()
    with pytest.raises(AssertionError):
        resp.set_tcp_nodelay(True)