refactor(db): 修复异步连接池无界增长,并完成 SQLAlchemy 2.0 迁移与分层归位 (#6320)

This commit is contained in:
Aqr-K
2026-08-15 06:58:38 +08:00
committed by GitHub
parent e28de9cfe1
commit 8a11214a43
252 changed files with 11405 additions and 2889 deletions
+5 -3
View File
@@ -654,13 +654,14 @@ class SubscribeEndpointTest(TestCase):
"""
owner-aware 创建不应把他人已有订阅当作当前用户订阅。
"""
from app.db.subscribe_oper import SubscribeOper
from app.application.subscribe import async_add_subscribe
from app.db.oper.subscribe import SubscribeOper
other = _EndpointSubscribe(id=21, username="bob")
own = _EndpointSubscribe(id=22, username="alice")
created = SimpleNamespace(async_create=AsyncMock())
with patch("app.db.subscribe_oper.Subscribe") as subscribe_model:
with patch("app.db.oper.subscribe.Subscribe") as subscribe_model:
subscribe_model.async_exists = AsyncMock(return_value=other)
subscribe_model.async_exists_by_username = AsyncMock(
side_effect=[None, own]
@@ -668,7 +669,8 @@ class SubscribeEndpointTest(TestCase):
subscribe_model.return_value = created
sid, message = asyncio.run(
SubscribeOper(db=object()).async_add(
async_add_subscribe(
subscribe_oper=SubscribeOper(db=object()),
mediainfo=_EndpointMediaInfo(),
username="alice",
owner_scope=True,