We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f206597 commit aa0a830Copy full SHA for aa0a830
test_event_bus.py
@@ -0,0 +1,26 @@
1
+import asyncio
2
+import pytest
3
+
4
+from src.common.event_bus import EventBus
5
6
7
+@pytest.mark.asyncio
8
+async def test_event_bus_publish_and_subscribe():
9
10
+ bus = EventBus()
11
+ received_messages = []
12
13
+ async def handler(payload):
14
+ received_messages.append(payload)
15
16
+ # Subscribe
17
+ await bus.subscribe("test_topic", handler)
18
19
+ # Publish event
20
+ await bus.publish("test_topic", {"value": 123})
21
22
+ # Allow async loop to process event
23
+ await asyncio.sleep(0.1)
24
25
+ assert len(received_messages) == 1
26
+ assert received_messages[0]["value"] == 123
0 commit comments