mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 07:27:15 +08:00
refactor(db): 修复异步连接池无界增长,并完成 SQLAlchemy 2.0 迁移与分层归位 (#6320)
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user