@pytest.mark.gen_test
def test_tornado_client_with_server_not_there():
    with pytest.raises(NetworkError):
        yield StreamConnection.outgoing(
            # Try a random port that we're not listening on.
            # This should fail.
            'localhost:41942')


# TODO test case will fail due to StreamClosedError when
# increase the LARGE_AMOUNT to even bigger
@pytest.mark.gen_test
@pytest.mark.parametrize('arg2, arg3', [
    ("", big_arg()),
    (big_arg(), ""),
    ("test", big_arg()),
    (big_arg(), "test"),
    (big_arg(), big_arg()),
    ("", ""),
    ("test", "test"),
],
                         ids=lambda arg: str(len(arg)))
def test_tchannel_call_request_fragment(mock_server, arg2, arg3):
    endpoint = b'tchannelpeertest'

    mock_server.expect_call(endpoint).and_write(headers=endpoint, body=arg3)

    tchannel = TChannel(name='test')
@pytest.mark.gen_test
def test_tornado_client_with_server_not_there():
    with pytest.raises(NetworkError):
        yield StreamConnection.outgoing(
            # Try a random port that we're not listening on.
            # This should fail.
            'localhost:41942'
        )


# TODO test case will fail due to StreamClosedError when
# increase the LARGE_AMOUNT to even bigger
@pytest.mark.gen_test
@pytest.mark.parametrize('arg2, arg3', [
    ("", big_arg()),
    (big_arg(), ""),
    ("test", big_arg()),
    (big_arg(),  "test"),
    (big_arg(), big_arg()),
    ("", ""),
    ("test", "test"),
],
    ids=lambda arg: str(len(arg))
)
def test_tchannel_call_request_fragment(mock_server,
                                        arg2, arg3):
    endpoint = b'tchannelpeertest'

    mock_server.expect_call(endpoint).and_write(
        headers=endpoint,
Example #3
0
    assert msg.headers == {'key': 'val'}
    assert msg.checksum == (messages.ChecksumType.none, None)

    assert msg.args == [b'on', b'to', b'te']


def test_equality_check_against_none(init_request_with_headers):
    assert messages.InitRequestMessage().__eq__(None) is False


# TODO test case will fail due to StreamClosedError when
# increase the LARGE_AMOUNT to even bigger
@pytest.mark.gen_test
@pytest.mark.parametrize('arg2, arg3', [
    (b"", big_arg()),
    (big_arg(), b""),
    (b"test", big_arg()),
    (big_arg(),  b"test"),
    (big_arg(), big_arg()),
    (b"", b""),
    (b"test", b"test"),
],
    ids=lambda arg: str(len(arg))
)
def test_message_fragment(arg2, arg3, connection):
    msg = CallRequestMessage(args=["", arg2, arg3])
    origin_msg = CallRequestMessage(args=["", arg2, arg3])
    message_factory = MessageFactory(connection)
    fragments = message_factory.fragment(msg)
    recv_msg = None