File tree Expand file tree Collapse file tree
packages/faststream-stomp Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010import stompman
1111from faststream ._internal .testing .broker import TestBroker , change_producer
1212from faststream .message import encode_message
13+ from stompman .frames import SendFrame
14+ from stompman .serde import dump_frame
1315
1416from faststream_stomp .broker import StompBroker
1517from faststream_stomp .models import StompPublishCommand
@@ -72,6 +74,16 @@ async def publish(self, cmd: StompPublishCommand) -> None:
7274 all_headers ["correlation-id" ] = cmd .correlation_id # type: ignore[typeddict-unknown-key]
7375 if content_type :
7476 all_headers ["content-type" ] = content_type
77+ dump_frame (
78+ SendFrame .build (
79+ body = body ,
80+ destination = cmd .destination ,
81+ transaction = None ,
82+ content_type = content_type ,
83+ add_content_length = False ,
84+ headers = cmd .headers ,
85+ )
86+ )
7587 frame = FakeAckableMessageFrame (headers = all_headers , body = body , _subscription = mock .AsyncMock ())
7688 for handler in self .broker .subscribers :
7789 if typing .cast ("StompSubscriber" , handler ).config .full_destination == cmd .destination :
Original file line number Diff line number Diff line change 1+ import typing
2+
13import faker
24import faststream_stomp
35import pydantic
@@ -59,6 +61,19 @@ def second_handle(body: str) -> None:
5961 assert third_publisher .mock
6062 third_publisher .mock .assert_called_once_with (expected_body )
6163
64+ async def test_non_string_header_values_raise_type_error (
65+ self , faker : faker .Faker , broker : faststream_stomp .StompBroker
66+ ) -> None :
67+ # gotcha: dict[str, typing.Any] is easily happily into dict[str, str]
68+ headers : dict [str , typing .Any ] = {"key" : 123 }
69+
70+ @broker .subscriber (destination := faker .pystr ())
71+ def handle (body : str ) -> None : ...
72+
73+ async with faststream_stomp .TestStompBroker (broker ) as br :
74+ with pytest .raises (TypeError ):
75+ await br .publish (faker .pystr (), destination , headers = headers )
76+
6277 async def test_publish_pydantic (self , faker : faker .Faker , broker : faststream_stomp .StompBroker ) -> None :
6378 class SomePydanticModel (pydantic .BaseModel ):
6479 foo : str
You can’t perform that action at this time.
0 commit comments