-
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.
Merge branch '0.6.0' of github.com:airtai/faststream into 0.6.0
- Loading branch information
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() |