Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: TestRabbitBroker does not throw error when rpc and reply_to are both provided #1415

Closed
maxalbert opened this issue May 2, 2024 · 0 comments · Fixed by #1419
Closed
Labels
bug Something isn't working

Comments

@maxalbert
Copy link
Contributor

Describe the bug

When using the TestRabbitBroker with the argument with_real=False, the command broker.publish() will allow the simultaneous use of the arguments rpc and reply_to, even though this should trigger a SetupError.

How to reproduce

Save the following script as example.py, then run

$ pytest example.py
import pytest
from faststream import FastStream
from faststream.rabbit import RabbitBroker, TestRabbitBroker

broker = RabbitBroker("amqp://guest:guest@localhost:5672/")
app = FastStream(broker)

@broker.subscriber("in-queue")
async def handle_msg(msg: str) -> str:
    return f"Received message: {msg!r}"

@pytest.mark.asyncio
async def test_rpc():
    async with TestRabbitBroker(broker, with_real=False) as br:
        response = await br.publish(
            "Hello there!",
            "in-queue",
            rpc=True,
            reply_to="reponse-queue",
        )
        assert response == "Received message: 'Hello there!'"

Expected behavior

I expect FastStream to throw an exception (which it does when using with_real=True):

faststream.exceptions.SetupError: You should use `reply_to` to send response to
                                  long-living queue and `rpc` to get response in sync mode.

Observed behavior
There is no error and the test passes even though it should fail.

Environment

$ faststream -v
Running FastStream 0.5.3 with CPython 3.12.3 on Darwin
@maxalbert maxalbert added the bug Something isn't working label May 2, 2024
Lancetnik added a commit that referenced this issue May 2, 2024
github-merge-queue bot pushed a commit that referenced this issue May 3, 2024
#1419)

* fix (#1415): raise SetupError if rpc and reply_to are using in TestCLient in the same time

* tests: make RMQ test client test in-memory

* tests: do not use already connected fixtures

* tests: do not use already connected fixtures
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant