-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: delayed broker setting (#1931)
* feat: delayed broker setting * feat: tests for delayed broker setting * feat: addition test * feat: broker -> **brokers * feat: ruff
- Loading branch information
1 parent
5f9c7b6
commit 0b49d76
Showing
5 changed files
with
67 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
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
Empty file.
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,38 @@ | ||
import pytest | ||
|
||
from faststream._internal.application import StartAbleApplication | ||
from faststream.exceptions import SetupError | ||
from faststream.rabbit import RabbitBroker | ||
|
||
|
||
def test_set_broker() -> None: | ||
app = StartAbleApplication() | ||
|
||
assert app.broker is None | ||
|
||
broker = RabbitBroker() | ||
app.set_broker(broker) | ||
|
||
assert app.broker is broker | ||
|
||
|
||
def test_set_more_than_once_broker() -> None: | ||
app = StartAbleApplication() | ||
broker_1 = RabbitBroker() | ||
broker_2 = RabbitBroker() | ||
|
||
app.set_broker(broker_1) | ||
|
||
with pytest.raises( | ||
SetupError, | ||
match=f"`{app}` already has a broker. You can't use multiple brokers until 1.0.0 release.", | ||
): | ||
app.set_broker(broker_2) | ||
|
||
|
||
@pytest.mark.asyncio() | ||
async def test_start_not_setup_broker() -> None: | ||
app = StartAbleApplication() | ||
|
||
with pytest.raises(AssertionError, match="You should setup a broker"): | ||
await app._start_broker() |