Refactor code structure for improved readability and maintainability
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
from typing import cast
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from faststream.rabbit import RabbitBroker
|
||||
|
||||
from app.messaging import (
|
||||
DEAD_ROUTING_KEY,
|
||||
PAYMENTS_ROUTING_KEY,
|
||||
declare_topology,
|
||||
)
|
||||
|
||||
|
||||
async def test_declare_topology_binds_both_queues() -> None:
|
||||
broker = AsyncMock()
|
||||
payments_exchange = object()
|
||||
dead_exchange = object()
|
||||
payments_queue = AsyncMock()
|
||||
dead_queue = AsyncMock()
|
||||
broker.declare_exchange.side_effect = [payments_exchange, dead_exchange]
|
||||
broker.declare_queue.side_effect = [payments_queue, dead_queue]
|
||||
|
||||
await declare_topology(cast(RabbitBroker, broker))
|
||||
|
||||
payments_queue.bind.assert_awaited_once_with(
|
||||
payments_exchange,
|
||||
routing_key=PAYMENTS_ROUTING_KEY,
|
||||
)
|
||||
dead_queue.bind.assert_awaited_once_with(
|
||||
dead_exchange,
|
||||
routing_key=DEAD_ROUTING_KEY,
|
||||
)
|
||||
Reference in New Issue
Block a user