-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: added some testing for the doc code snippet
- Loading branch information
1 parent
771b355
commit 313d823
Showing
2 changed files
with
41 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from unittest.mock import AsyncMock | ||
|
||
import pytest | ||
from aio_pika import RobustQueue | ||
|
||
from faststream import TestApp | ||
from tests.marks import require_aiopika | ||
|
||
|
||
@pytest.mark.asyncio | ||
@pytest.mark.rabbit | ||
@require_aiopika | ||
async def test_bind(monkeypatch, async_mock: AsyncMock): | ||
from docs.docs_src.rabbit.bind import app, broker, some_exchange, some_queue | ||
|
||
with monkeypatch.context() as m: | ||
m.setattr(RobustQueue, "bind", async_mock) | ||
async with TestApp(app): | ||
assert len(broker.declarer._RabbitDeclarer__queues) == 2 # with `reply-to` | ||
assert len(broker.declarer._RabbitDeclarer__exchanges) == 1 | ||
|
||
assert some_queue in broker.declarer._RabbitDeclarer__queues | ||
assert some_exchange in broker.declarer._RabbitDeclarer__exchanges | ||
|
||
async_mock.assert_awaited_once_with( | ||
queue=broker.declarer._RabbitDeclarer__queues[some_queue], | ||
exchange=broker.declarer._RabbitDeclarer__exchanges[some_exchange], | ||
routing_key=some_queue.name, | ||
) |