Ejemplo n.º 1
0
def test_set_nodelay_enable_unix(loop):
    transport = mock.Mock()
    s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
    transport.get_extra_info.return_value = s
    proto = mock.Mock()
    reader = mock.Mock()
    writer = StreamWriter(transport, proto, reader, loop)
    writer.set_tcp_nodelay(True)
    assert writer.tcp_nodelay
Ejemplo n.º 2
0
def test_set_nodelay_enable_no_socket(loop):
    transport = mock.Mock()
    transport.get_extra_info.return_value = None
    proto = mock.Mock()
    reader = mock.Mock()
    writer = StreamWriter(transport, proto, reader, loop)
    writer.set_tcp_nodelay(True)
    assert writer.tcp_nodelay
    assert writer._socket is None
def test_set_cork_enable_no_socket(loop):
    transport = mock.Mock()
    transport.get_extra_info.return_value = None
    proto = mock.Mock()
    reader = mock.Mock()
    writer = StreamWriter(transport, proto, reader, loop)
    writer.set_tcp_cork(True)
    assert not writer.tcp_cork
    assert writer._socket is None
def test_set_cork_enable_unix(loop):
    transport = mock.Mock()
    s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
    transport.get_extra_info.return_value = s
    proto = mock.Mock()
    reader = mock.Mock()
    writer = StreamWriter(transport, proto, reader, loop)
    writer.set_tcp_cork(True)
    assert not writer.tcp_cork
Ejemplo n.º 5
0
def test_set_nodelay_enable_ipv6(loop):
    transport = mock.Mock()
    s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
    transport.get_extra_info.return_value = s
    proto = mock.Mock()
    reader = mock.Mock()
    writer = StreamWriter(transport, proto, reader, loop)
    writer.set_tcp_nodelay(True)
    assert writer.tcp_nodelay
    assert s.getsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY)
Ejemplo n.º 6
0
def test_set_cork_enable(loop):
    transport = mock.Mock()
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    transport.get_extra_info.return_value = s
    proto = mock.Mock()
    reader = mock.Mock()
    writer = StreamWriter(transport, proto, reader, loop)
    writer.set_tcp_cork(True)
    assert writer.tcp_cork
    assert s.getsockopt(socket.IPPROTO_TCP, CORK)
def test_set_nodelay_enable_ipv6(loop):
    transport = mock.Mock()
    s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
    transport.get_extra_info.return_value = s
    proto = mock.Mock()
    reader = mock.Mock()
    writer = StreamWriter(transport, proto, reader, loop)
    writer.set_tcp_nodelay(True)
    assert writer.tcp_nodelay
    assert s.getsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY)
def test_set_cork_enable(loop):
    transport = mock.Mock()
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    transport.get_extra_info.return_value = s
    proto = mock.Mock()
    reader = mock.Mock()
    writer = StreamWriter(transport, proto, reader, loop)
    writer.set_tcp_cork(True)
    assert writer.tcp_cork
    assert s.getsockopt(socket.IPPROTO_TCP, CORK)
def test_set_cork_exception(loop):
    transport = mock.Mock()
    s = mock.Mock()
    s.setsockopt = mock.Mock()
    s.family = (socket.AF_INET,)
    s.setsockopt.side_effect = OSError
    proto = mock.Mock()
    reader = mock.Mock()
    writer = StreamWriter(transport, proto, reader, loop)
    writer.set_tcp_cork(True)
    assert not writer.tcp_cork
Ejemplo n.º 10
0
def test_set_nodelay_exception(loop):
    transport = mock.Mock()
    s = mock.Mock()
    s.setsockopt = mock.Mock()
    s.family = (socket.AF_INET,)
    s.setsockopt.side_effect = OSError
    transport.get_extra_info.return_value = s
    proto = mock.Mock()
    reader = mock.Mock()
    writer = StreamWriter(transport, proto, reader, loop)
    writer.set_tcp_nodelay(True)
    assert not writer.tcp_nodelay
Ejemplo n.º 11
0
def test_nodelay_default(loop):
    transport = mock.Mock()
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    transport.get_extra_info.return_value = s
    proto = mock.Mock()
    reader = mock.Mock()
    writer = StreamWriter(transport, proto, reader, loop)
    assert not writer.tcp_nodelay
    assert not s.getsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY)