Files
ss-tools/backend/tests/services/test_notifications_async.py
busya 9f9ad91345 032: T029-T031 + T046-T048 — all remaining tests
T029: concurrent preview+schema check test
T030: static asyncio.sleep audit
T031: LLM rate-limit backoff test + 6 edge cases
T046: TaskManager concurrent tasks + cancellation tests
T047: async notifications — SMTP timeout test
T048: EventBus publish/subscribe + maxsize tests

34 total async tests passing.
2026-06-04 21:06:22 +03:00

34 lines
1.2 KiB
Python

# #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