-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* docs: update CONTRIBUTING.md Added missing 'and not confluent' to pytest command for running the tests when no broker instances are present. * feat: enable spy_decorator to wrap both async and non-async methods * feat: add NatsBroker.new_inbox() * chore: linting * fix: raise error if new_inbox() is called before broker was started * refactor: use assert statement instead of raising an exception * docs: mention 'inbox_prefix' argument in docstring for 'new_inbox()'
- Loading branch information
Showing
5 changed files
with
48 additions
and
5 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
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,23 @@ | ||
from unittest.mock import patch | ||
|
||
import pytest | ||
from nats.aio.client import Client as NatsClient | ||
|
||
from faststream.nats import NatsBroker | ||
from tests.tools import spy_decorator | ||
|
||
|
||
@pytest.mark.asyncio() | ||
@pytest.mark.nats() | ||
async def test_new_inbox(): | ||
with patch.object( | ||
NatsClient, | ||
"new_inbox", | ||
spy_decorator(NatsClient.new_inbox), | ||
) as m: | ||
broker = NatsBroker(inbox_prefix="_FOO_TEST_INBOX") | ||
await broker.connect() | ||
inbox_name = await broker.new_inbox() | ||
|
||
m.mock.assert_called_once() | ||
assert inbox_name.startswith("_FOO_TEST_INBOX.") |
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