import asyncio
import json


async def test_consume_rpcs_no_expiry_key(redis_client, redis_rpc_transport, dummy_api):
    """Does call_rpc() add a message to a stream, but where the expiry key is missing

    Transport should assume that the RPC call has timed out and therefore not serve it.
    """

    async def co_enqeue():
        await asyncio.sleep(0.01)
        # NOT SETTING rpc_expiry_key:123abc
        return await redis_client.rpush(
            "my.dummy:rpc_queue",
            value=json.dumps(
                {
                    "metadata": {
                        "id": "123abc",
                        "api_name": "my.api",
                        "procedure_name": "my_proc",
                        "return_path": "abc",
                    },
                    "kwargs": {"field": "value"},
                }
            ),
        )

    async def co_consume():
        return await redis_rpc_transport.consume_rpcs(apis=[dummy_api], bus_client=None)

    enqueue_result, messages = await asyncio.gather(co_enqeue(), co_consume())
    assert not messages