Exemplo n.º 1
0
async def test_get_return_path(redis_result_transport: RedisResultTransport):
    return_path = redis_result_transport.get_return_path(
        RpcMessage(
            api_name="my.api",
            procedure_name="my_proc",
            kwargs={"field": "value"},
            return_path="abc",
        ))
    assert return_path.startswith("redis+key://my.api.my_proc:result:")
    result_uuid = b64decode(return_path.split(":")[-1])
    assert UUID(bytes=result_uuid)
Exemplo n.º 2
0
async def test_get_return_path(redis_result_transport: RedisResultTransport):
    return_path = redis_result_transport.get_return_path(
        RpcMessage(
            api_name='my.api',
            procedure_name='my_proc',
            kwargs={'field': 'value'},
            return_path='abc',
        ))
    assert return_path.startswith('redis+key://my.api.my_proc:result:')
    result_uuid = b64decode(return_path.split(':')[-1])
    assert UUID(bytes=result_uuid)
Exemplo n.º 3
0
async def test_from_config(redis_client):
    await redis_client.select(5)
    host, port = redis_client.address
    transport = RedisResultTransport.from_config(
        config=None,
        url=f"redis://127.0.0.1:{port}/5",
        connection_parameters=dict(maxsize=123),
        # Non default serializers, event though they wouldn't make sense in this context
        serializer="lightbus.serializers.ByFieldMessageSerializer",
        deserializer="lightbus.serializers.ByFieldMessageDeserializer",
    )
    with await transport.connection_manager() as transport_client:
        assert transport_client.connection.address == ("127.0.0.1", port)
        assert transport_client.connection.db == 5
        await transport_client.set("x", 1)
        assert await redis_client.get("x")

    assert transport._redis_pool.connection.maxsize == 123
    assert isinstance(transport.serializer, ByFieldMessageSerializer)
    assert isinstance(transport.deserializer, ByFieldMessageDeserializer)