File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed
packages/faststream-stomp Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 1+ import typing
12import uuid
23from collections .abc import Generator , Iterator
34from contextlib import contextmanager
@@ -28,7 +29,6 @@ def create_publisher_fake_subscriber(
2829 if handler .config .full_destination == publisher .config .full_destination :
2930 subscriber = handler
3031 break
31-
3232 if subscriber is None :
3333 is_real = False
3434 subscriber = broker .subscriber (publisher .config .full_destination )
@@ -73,6 +73,6 @@ async def publish(self, cmd: StompPublishCommand) -> None:
7373 if content_type :
7474 all_headers ["content-type" ] = content_type
7575 frame = FakeAckableMessageFrame (headers = all_headers , body = body , _subscription = mock .AsyncMock ())
76- for handler in self .broker ._subscribers :
77- if handler .config .full_destination == cmd .destination :
76+ for handler in self .broker .subscribers :
77+ if typing . cast ( "StompSubscriber" , handler ) .config .full_destination == cmd .destination :
7878 await handler .process_message (frame )
Original file line number Diff line number Diff line change 77from faststream .message import gen_cor_id
88from faststream_stomp .opentelemetry import StompTelemetryMiddleware
99from faststream_stomp .prometheus import StompPrometheusMiddleware
10+ from faststream_stomp .router import StompRouter
1011from opentelemetry .sdk .metrics import MeterProvider
1112from opentelemetry .sdk .trace import TracerProvider
1213from polyfactory .factories .pydantic_factory import ModelFactory
@@ -65,6 +66,18 @@ class SomePydanticModel(pydantic.BaseModel):
6566 async with faststream_stomp .TestStompBroker (broker ) as br :
6667 await br .publish (ModelFactory .create_factory (SomePydanticModel ).build (), faker .pystr ())
6768
69+ async def test_routers (self , faker : faker .Faker , broker : faststream_stomp .StompBroker ) -> None :
70+ router = StompRouter ()
71+ broker .include_router (router )
72+
73+ @router .subscriber (destination := faker .pystr ())
74+ def handle_message (body : str ) -> None : ...
75+
76+ async with faststream_stomp .TestStompBroker (broker ):
77+ await broker .publish (faker .pystr (), destination )
78+ assert handle_message .mock
79+ handle_message .mock .assert_called_once ()
80+
6881
6982class TestNotImplemented :
7083 async def test_broker_request (self , faker : faker .Faker , broker : faststream_stomp .StompBroker ) -> None :
You can’t perform that action at this time.
0 commit comments