# #region TestAsyncNotifications [C:3] [TYPE Module] [SEMANTICS test, notifications, async, smtp] # @BRIEF Tests for async notification delivery — SMTP timeout isolation from API responsiveness. # @RELATION BINDS_TO -> [NotificationService] # @TEST_EDGE: smtp_timeout -> SMTP timeout must not block API response import asyncio import pytest # #region test_smtp_timeout_doesnt_block_api [C:2] [TYPE Function] # @BRIEF Verify SMTP timeout via asyncio.wait_for does not block concurrent API calls. @pytest.mark.asyncio async def test_smtp_timeout_doesnt_block_api(): api_latency = [] async def api_call(): await asyncio.sleep(0.01) api_latency.append("ok") return 200 async def smtp_timeout(): with pytest.raises(asyncio.TimeoutError): await asyncio.wait_for(asyncio.sleep(10), timeout=0.02) t0 = asyncio.get_event_loop().time() api, smtp = await asyncio.gather(api_call(), smtp_timeout(), return_exceptions=True) elapsed = asyncio.get_event_loop().time() - t0 assert elapsed < 0.1, f"SMTP timeout blocked: {elapsed:.3f}s" assert api == 200 # #endregion test_smtp_timeout_doesnt_block_api # #endregion TestAsyncNotifications