mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 23:47:41 +08:00
refactor(db): 修复异步连接池无界增长,并完成 SQLAlchemy 2.0 迁移与分层归位 (#6320)
This commit is contained in:
@@ -333,7 +333,7 @@ def _load_subscribe_chain_class():
|
||||
|
||||
db_model_module.Subscribe = _SubscribeModel
|
||||
|
||||
subscribe_oper_module = ensure_module("app.db.subscribe_oper", types.ModuleType("app.db.subscribe_oper"))
|
||||
subscribe_oper_module = ensure_module("app.db.oper.subscribe", types.ModuleType("app.db.oper.subscribe"))
|
||||
|
||||
class _SubscribeOper:
|
||||
def update(self, *args, **kwargs):
|
||||
@@ -354,9 +354,9 @@ def _load_subscribe_chain_class():
|
||||
subscribe_oper_module.SubscribeOper = _SubscribeOper
|
||||
|
||||
simple_oper_modules = {
|
||||
"app.db.downloadhistory_oper": "DownloadHistoryOper",
|
||||
"app.db.site_oper": "SiteOper",
|
||||
"app.db.systemconfig_oper": "SystemConfigOper",
|
||||
"app.db.oper.downloadhistory": "DownloadHistoryOper",
|
||||
"app.db.oper.site": "SiteOper",
|
||||
"app.db.oper.systemconfig": "SystemConfigOper",
|
||||
}
|
||||
for module_name_key, class_name in simple_oper_modules.items():
|
||||
module = ensure_module(module_name_key, types.ModuleType(module_name_key))
|
||||
@@ -3325,12 +3325,13 @@ class SubscribeProgressConsolidationTest(TestCase):
|
||||
chain = SubscribeChain()
|
||||
chain.obtain_images = lambda **_kwargs: None
|
||||
|
||||
class _SubscribeOper:
|
||||
def add(self, **kwargs):
|
||||
added.append(kwargs)
|
||||
return 41, None
|
||||
# 落库入口已迁到 app/application/subscribe.py,链路层的接缝是 add_subscribe;
|
||||
# 截在这里拿到的就是链路交给写入路径的原始字段,正是本用例要断言的总集数
|
||||
def _add_subscribe(**kwargs):
|
||||
added.append(kwargs)
|
||||
return 41, None
|
||||
|
||||
with patch.object(module, "SubscribeOper", return_value=_SubscribeOper()), patch.object(
|
||||
with patch.object(module, "add_subscribe", _add_subscribe), patch.object(
|
||||
module,
|
||||
"eventmanager",
|
||||
eventmanager,
|
||||
|
||||
Reference in New Issue
Block a user