mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-11-03 05:44:44 +08:00
Merge pull request #7050 from DDSRem-Dev/codex-comment-migration
docs: 统一全项目中文注释和结构化契约说明
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
"""插件实例描述符表 Alembic 迁移测试。"""
|
||||
"""
|
||||
插件实例描述符表 Alembic 迁移测试。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -27,7 +29,9 @@ EXPECTED_COLUMNS = {
|
||||
|
||||
|
||||
def _bind_migration(monkeypatch, connection):
|
||||
"""把迁移绑定到隔离数据库连接。"""
|
||||
"""
|
||||
把迁移绑定到隔离数据库连接。
|
||||
"""
|
||||
migration = importlib.import_module(MIGRATION_MODULE)
|
||||
context = MigrationContext.configure(connection)
|
||||
monkeypatch.setattr(migration, "op", Operations(context))
|
||||
@@ -35,7 +39,9 @@ def _bind_migration(monkeypatch, connection):
|
||||
|
||||
|
||||
def _seed_legacy_key(connection: sa.engine.Connection, value) -> None:
|
||||
"""写入旧 systemconfig 单键,模拟迁移前的实例描述存量数据。"""
|
||||
"""
|
||||
写入旧 systemconfig 单键,模拟迁移前的实例描述存量数据。
|
||||
"""
|
||||
connection.execute(
|
||||
sa.insert(SystemConfig.__table__).values(key="PluginInstances", value=value)
|
||||
)
|
||||
@@ -44,7 +50,9 @@ def _seed_legacy_key(connection: sa.engine.Connection, value) -> None:
|
||||
def test_plugin_instance_migration_migrates_legacy_dict_payload_and_keeps_source_key(
|
||||
monkeypatch,
|
||||
) -> None:
|
||||
"""字典载荷应逐条搬入新表,原 systemconfig 键保留不删,且可重复升级与完整回滚。"""
|
||||
"""
|
||||
字典载荷应逐条搬入新表,原 systemconfig 键保留不删,且可重复升级与完整回滚。
|
||||
"""
|
||||
engine = sa.create_engine("sqlite://")
|
||||
with engine.begin() as connection:
|
||||
SystemConfig.__table__.create(connection)
|
||||
@@ -111,7 +119,9 @@ def test_plugin_instance_migration_migrates_legacy_dict_payload_and_keeps_source
|
||||
|
||||
|
||||
def test_plugin_instance_migration_drops_the_redundant_mode_field(monkeypatch) -> None:
|
||||
"""旧载荷里的 mode 是身份等式的冗余副本,新表不再为它建列。"""
|
||||
"""
|
||||
旧载荷里的 mode 是身份等式的冗余副本,新表不再为它建列。
|
||||
"""
|
||||
engine = sa.create_engine("sqlite://")
|
||||
with engine.begin() as connection:
|
||||
SystemConfig.__table__.create(connection)
|
||||
@@ -141,7 +151,9 @@ def test_plugin_instance_migration_drops_the_redundant_mode_field(monkeypatch) -
|
||||
|
||||
|
||||
def test_plugin_instance_migration_migrates_legacy_list_payload(monkeypatch) -> None:
|
||||
"""历史列表载荷同样应逐条搬入新表。"""
|
||||
"""
|
||||
历史列表载荷同样应逐条搬入新表。
|
||||
"""
|
||||
engine = sa.create_engine("sqlite://")
|
||||
with engine.begin() as connection:
|
||||
SystemConfig.__table__.create(connection)
|
||||
@@ -164,7 +176,9 @@ def test_plugin_instance_migration_migrates_legacy_list_payload(monkeypatch) ->
|
||||
|
||||
|
||||
def test_plugin_instance_migration_skips_malformed_legacy_entries(monkeypatch) -> None:
|
||||
"""缺失必填字段或非字典条目必须被跳过,不得中断迁移。"""
|
||||
"""
|
||||
缺失必填字段或非字典条目必须被跳过,不得中断迁移。
|
||||
"""
|
||||
engine = sa.create_engine("sqlite://")
|
||||
with engine.begin() as connection:
|
||||
SystemConfig.__table__.create(connection)
|
||||
@@ -188,7 +202,9 @@ def test_plugin_instance_migration_skips_malformed_legacy_entries(monkeypatch) -
|
||||
def test_plugin_instance_migration_without_legacy_key_creates_empty_table(
|
||||
monkeypatch,
|
||||
) -> None:
|
||||
"""旧键缺失或为空时应正常建表,不产生任何数据行。"""
|
||||
"""
|
||||
旧键缺失或为空时应正常建表,不产生任何数据行。
|
||||
"""
|
||||
engine = sa.create_engine("sqlite://")
|
||||
with engine.begin() as connection:
|
||||
SystemConfig.__table__.create(connection)
|
||||
@@ -201,7 +217,9 @@ def test_plugin_instance_migration_without_legacy_key_creates_empty_table(
|
||||
|
||||
|
||||
def test_plugin_instance_migration_accepts_fresh_current_schema(monkeypatch) -> None:
|
||||
"""create_all 已建当前表时重复升级不得创建冲突对象。"""
|
||||
"""
|
||||
create_all 已建当前表时重复升级不得创建冲突对象。
|
||||
"""
|
||||
from app.db.models.plugininstance import PluginInstance
|
||||
|
||||
engine = sa.create_engine("sqlite://")
|
||||
|
||||
Reference in New Issue
Block a user