Skip to content

Commit 42a6823

Browse files
committed
fix(test): use get_nowait() to avoid Py3.11 async timeout in mesh test
Made-with: Cursor
1 parent 37f5fbb commit 42a6823

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

tests/test_mesh.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@
44

55
import pytest
66
from agentos.mesh.mesh_router import MeshRouter, MeshMessage
7-
import agentos.mesh.mesh_router as mesh_router_mod
87

98

109
@pytest.fixture
1110
def mesh_router():
1211
mr = MeshRouter()
13-
# Avoid real network calls when `REDIS_URL` is configured in CI.
14-
# Message delivery is in-memory; we only mock the async Redis publish.
1512
mr._publish_redis = AsyncMock(return_value=None)
1613
return mr
1714

@@ -27,17 +24,20 @@ async def test_register_agent(mesh_router):
2724

2825

2926
@pytest.mark.asyncio
30-
@pytest.mark.skip(reason="Async queue mismatch in CI Python 3.11 — see issue #23")
3127
async def test_send_message(mesh_router):
32-
# The queue-based assertion has been flaky in CI (Py3.11).
33-
# Validate the public contract: `send_message` returns the message it sent.
3428
msg = await mesh_router.send_message("agent_a", "agent_b", {"data": "hello"})
29+
assert isinstance(msg, MeshMessage)
3530
assert msg.sender == "agent_a"
3631
assert msg.receiver == "agent_b"
3732
assert msg.payload == {"data": "hello"}
33+
assert msg.topic == "default"
3834

39-
# Diagnostics for CI: ensure tests are importing the expected module path.
40-
assert hasattr(mesh_router_mod, "__file__")
35+
q = mesh_router._get_queue("agent_b")
36+
assert not q.empty()
37+
queued_msg = q.get_nowait()
38+
assert queued_msg.payload == {"data": "hello"}
39+
assert queued_msg.sender == "agent_a"
40+
assert queued_msg.receiver == "agent_b"
4141

4242

4343
@pytest.mark.asyncio

0 commit comments

Comments
 (0)