Ejemplo n.º 1
0
def test_client_for_with_sync_tchannel(server, ThriftTest):

    @server.thrift.register(ThriftTest)
    def testString(request):
        return request.body.thing.encode('rot13')

    tchannel = SyncTChannel(name='client')

    client = sync_client_for('server', _ThriftTest)(
        tchannel=tchannel,
        hostport=server.hostport,
    )

    future = client.testString(thing='foo')

    assert not isinstance(future, concurrent.Future)

    # Our server is sharing our IO loop so let it handle the
    # request.
    while not future.done():
        yield gen.moment

    resp = future.result()

    assert resp == 'sbb'
Ejemplo n.º 2
0
def test_client_for_with_sync_tchannel(server, ThriftTest):

    @server.thrift.register(ThriftTest)
    def testString(request):
        return request.body.thing.encode('utf8')

    tchannel = SyncTChannel(name='client')

    client = sync_client_for('server', _ThriftTest)(
        tchannel=tchannel,
        hostport=server.hostport,
    )

    future = client.testString(thing='foo')

    assert not isinstance(future, concurrent.Future)

    # Our server is sharing our IO loop so let it handle the
    # request.
    while not future.done():
        yield gen.moment

    resp = future.result()

    assert resp == 'foo'
Ejemplo n.º 3
0
def test_client_for_with_sync_tchannel_and_injected_thread_loop(
    server,
    ThriftTest,
    loop,
):
    tchannel = SyncTChannel(name='client', threadloop=loop)

    client = sync_client_for('server', _ThriftTest)(
        tchannel=tchannel,
        hostport=server.hostport,
    )

    assert client.testString(thing='foo')
Ejemplo n.º 4
0
def test_client_for_with_sync_tchannel_and_injected_thread_loop(
    server,
    ThriftTest,
    loop,
):
    tchannel = SyncTChannel(name='client', threadloop=loop)

    client = sync_client_for('server', _ThriftTest)(
        tchannel=tchannel,
        hostport=server.hostport,
    )

    assert client.testString(thing='foo')