Systematic rename of all semantic anchors (#region, [DEF], @RELATION) across 1400+ files — backend Python, frontend Svelte/TS, specs, docs: - Flat anchors become Namespace.Module.Entity - @RELATION references updated to match new anchor paths - Zero business logic changes
34 lines
1.3 KiB
Python
34 lines
1.3 KiB
Python
# #region Test.NotificationsAsync.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 -> [Services.Service.NotificationService]
|
|
# @TEST_EDGE: smtp_timeout -> SMTP timeout must not block API response
|
|
import asyncio
|
|
import pytest
|
|
|
|
|
|
# #region Test.NotificationsAsync.TestSmtpTimeoutDoesntBlockApi [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.NotificationsAsync.TestSmtpTimeoutDoesntBlockApi
|
|
|
|
|
|
# #endregion Test.NotificationsAsync.TestAsyncNotifications
|