Пример #1
0
def test_set_cork_prepared():
    resp = StreamResponse()
    writer = mock.Mock()
    req = make_request('GET', '/', writer=writer)

    yield from resp.prepare(req)
    resp.set_tcp_cork(True)
    writer.set_tcp_cork.assert_called_with(True)
Пример #2
0
def test_set_cork_prepared():
    resp = StreamResponse()
    writer = mock.Mock()
    req = make_request('GET', '/', payload_writer=writer)

    yield from resp.prepare(req)
    resp.set_tcp_cork(True)
    writer.set_tcp_cork.assert_called_with(True)
Пример #3
0
def test_set_tcp_cork_on_start():
    req = make_request('GET', '/')
    resp = StreamResponse()
    resp.set_tcp_cork(True)

    with mock.patch('aiohttp.web_reqrep.ResponseImpl'):
        resp_impl = yield from resp.prepare(req)
    resp_impl.transport.set_tcp_nodelay.assert_called_with(False)
    resp_impl.transport.set_tcp_cork.assert_called_with(True)
Пример #4
0
def test_set_tcp_cork_on_start():
    req = make_request('GET', '/')
    resp = StreamResponse()
    resp.set_tcp_cork(True)

    with mock.patch('aiohttp.web_reqrep.ResponseImpl'):
        resp_impl = yield from resp.prepare(req)
    resp_impl.transport.set_tcp_nodelay.assert_called_with(False)
    resp_impl.transport.set_tcp_cork.assert_called_with(True)
Пример #5
0
def test_set_tcp_cork_before_start():
    resp = StreamResponse()
    resp.set_tcp_cork(True)
    assert resp.tcp_cork
    resp.set_tcp_cork(False)
    assert not resp.tcp_cork
Пример #6
0
def test_set_tcp_cork_before_start():
    resp = StreamResponse()
    resp.set_tcp_cork(True)
    assert resp.tcp_cork
    resp.set_tcp_cork(False)
    assert not resp.tcp_cork
Пример #7
0
def test_set_cork_unprepared():
    resp = StreamResponse()
    with pytest.raises(RuntimeError):
        resp.set_tcp_cork(True)
Пример #8
0
def test_set_cork_unprepared():
    resp = StreamResponse()
    with pytest.raises(AssertionError):
        resp.set_tcp_cork(True)