1- import asyncio
1+ import inspect
22import logging
3+ from unittest .mock import AsyncMock , patch
34
45from pybot import endpoints
5- from tests .data .events import MESSAGE_DELETE , MESSAGE_EDIT , PLAIN_MESSAGE
6+ from pybot .endpoints .slack .events import team_join
7+ from pybot ._vendor .slack .events import Event
8+ from tests .data .events import MESSAGE_DELETE , MESSAGE_EDIT , PLAIN_MESSAGE , TEAM_JOIN
69
710
811async def test_team_join_handler_exists (bot ):
912 endpoints .slack .create_endpoints (bot ["plugins" ]["slack" ])
1013
11- assert asyncio .iscoroutinefunction (
14+ assert inspect .iscoroutinefunction (
1215 bot ["plugins" ]["slack" ].routers ["event" ]._routes ["team_join" ]["*" ]["*" ][0 ][0 ]
1316 )
1417
@@ -35,3 +38,31 @@ async def test_no_other_messages_logged(bot, aiohttp_client, caplog):
3538 with caplog .at_level (logging .INFO ):
3639 await client .post ("/slack/events" , json = PLAIN_MESSAGE )
3740 assert not any ("CHANGE_LOGGING" in record .message for record in caplog .records )
41+
42+
43+ async def test_team_join_asyncio_gather_does_not_raise_typeerror (bot ):
44+ """
45+ Regression test for Python 3.14 compatibility.
46+
47+ In Python 3.14, asyncio.wait() no longer accepts bare coroutines.
48+ This test verifies that team_join uses asyncio.gather() correctly.
49+ """
50+ event = Event .from_http (TEAM_JOIN , verification_token = "supersecuretoken" )
51+
52+ with (
53+ patch ("pybot.endpoints.slack.events.asyncio.sleep" , new_callable = AsyncMock ),
54+ patch (
55+ "pybot.endpoints.slack.events.send_user_greetings" , new_callable = AsyncMock
56+ ),
57+ patch (
58+ "pybot.endpoints.slack.events.send_community_notification" ,
59+ new_callable = AsyncMock ,
60+ ),
61+ patch (
62+ "pybot.endpoints.slack.events.get_backend_auth_headers" ,
63+ new_callable = AsyncMock ,
64+ return_value = {},
65+ ),
66+ ):
67+ # This should not raise TypeError about coroutines
68+ await team_join (event , bot )
0 commit comments