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