MCPcopy
hub / github.com/ag2ai/faststream / test_publisher_object

Method test_publisher_object

tests/brokers/base/publish.py:321–356  ·  view source on GitHub ↗
(
        self,
        queue: str,
        mock: MagicMock,
    )

Source from the content-addressed store, hash-verified

319
320 @pytest.mark.asyncio()
321 async def test_publisher_object(
322 self,
323 queue: str,
324 mock: MagicMock,
325 ) -> None:
326 event = asyncio.Event()
327
328 pub_broker = self.get_broker(apply_types=True)
329
330 publisher = pub_broker.publisher(queue + "resp")
331
332 args, kwargs = self.get_subscriber_params(queue)
333
334 @publisher
335 @pub_broker.subscriber(*args, **kwargs)
336 async def m() -> str:
337 return ""
338
339 args, kwargs = self.get_subscriber_params(queue + "resp")
340
341 @pub_broker.subscriber(*args, **kwargs)
342 async def resp(msg) -> None:
343 event.set()
344 mock(msg)
345
346 async with self.patch_broker(pub_broker) as br:
347 await br.start()
348 await asyncio.wait(
349 (
350 asyncio.create_task(br.publish("", queue)),
351 asyncio.create_task(event.wait()),
352 ),
353 timeout=self.timeout,
354 )
355
356 mock.assert_called_once_with("")
357
358 @pytest.mark.asyncio()
359 async def test_publish_manual(

Callers

nothing calls this directly

Calls 7

waitMethod · 0.80
get_brokerMethod · 0.45
publisherMethod · 0.45
get_subscriber_paramsMethod · 0.45
patch_brokerMethod · 0.45
startMethod · 0.45
publishMethod · 0.45

Tested by

no test coverage detected