Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/faststream-stomp/faststream_stomp/testing.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import typing
import uuid
from collections.abc import Generator, Iterator
from contextlib import contextmanager
Expand Down Expand Up @@ -28,7 +29,6 @@ def create_publisher_fake_subscriber(
if handler.config.full_destination == publisher.config.full_destination:
subscriber = handler
break

if subscriber is None:
is_real = False
subscriber = broker.subscriber(publisher.config.full_destination)
Expand Down Expand Up @@ -73,6 +73,6 @@ async def publish(self, cmd: StompPublishCommand) -> None:
if content_type:
all_headers["content-type"] = content_type
frame = FakeAckableMessageFrame(headers=all_headers, body=body, _subscription=mock.AsyncMock())
for handler in self.broker._subscribers:
if handler.config.full_destination == cmd.destination:
for handler in self.broker.subscribers:
if typing.cast("StompSubscriber", handler).config.full_destination == cmd.destination:
await handler.process_message(frame)
13 changes: 13 additions & 0 deletions packages/faststream-stomp/test_faststream_stomp/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from faststream.message import gen_cor_id
from faststream_stomp.opentelemetry import StompTelemetryMiddleware
from faststream_stomp.prometheus import StompPrometheusMiddleware
from faststream_stomp.router import StompRouter
from opentelemetry.sdk.metrics import MeterProvider
from opentelemetry.sdk.trace import TracerProvider
from polyfactory.factories.pydantic_factory import ModelFactory
Expand Down Expand Up @@ -65,6 +66,18 @@ class SomePydanticModel(pydantic.BaseModel):
async with faststream_stomp.TestStompBroker(broker) as br:
await br.publish(ModelFactory.create_factory(SomePydanticModel).build(), faker.pystr())

async def test_routers(self, faker: faker.Faker, broker: faststream_stomp.StompBroker) -> None:
router = StompRouter()
broker.include_router(router)

@router.subscriber(destination := faker.pystr())
def handle_message(body: str) -> None: ...

async with faststream_stomp.TestStompBroker(broker):
await broker.publish(faker.pystr(), destination)
assert handle_message.mock
handle_message.mock.assert_called_once()


class TestNotImplemented:
async def test_broker_request(self, faker: faker.Faker, broker: faststream_stomp.StompBroker) -> None:
Expand Down