mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/jxxghp/MoviePilot.git
synced 2026-09-20 08:03:34 +08:00
* feat(subscription): govern concurrent search and match execution * refactor(subscription): consume complete candidate snapshots * refactor(subscription): remove download submission ledger * feat(subscription): stagger fallback searches without site gaps * refactor(subscription): remove unused retry capability * test(subscription): verify complete scale execution * fix(subscription): surface site search failures * test(subscription): verify site pressure through search * test(subscription): use static facade imports * fix(subscription): preserve completed downloads on shutdown * fix(subscription): classify execution expiry as failure * fix(subscription): preserve fallback search staggering * test(subscription): stabilize unfinished wrapper gate * fix(subscription): settle expired search returns * style(subscription): normalize governance imports * fix(subscription): align governance type contracts * docs(architecture): sync mypy debt metric * docs(architecture): sync startup module counts
62 lines
2.0 KiB
Python
62 lines
2.0 KiB
Python
"""订阅搜索批次跳过计数的 Alembic 可逆迁移测试。"""
|
|
|
|
import importlib
|
|
|
|
import sqlalchemy as sa
|
|
from alembic.migration import MigrationContext
|
|
from alembic.operations import Operations
|
|
|
|
MIGRATION = "database.versions.b6c1d9e4a7f2_3_0_24"
|
|
|
|
|
|
def _bind_migration(monkeypatch, connection):
|
|
"""把跳过计数迁移绑定到隔离 SQLite 连接。"""
|
|
migration = importlib.import_module(MIGRATION)
|
|
monkeypatch.setattr(
|
|
migration,
|
|
"op",
|
|
Operations(MigrationContext.configure(connection)),
|
|
)
|
|
return migration
|
|
|
|
|
|
def test_subscription_search_skipped_count_migration_is_reversible(monkeypatch) -> None:
|
|
"""存量批次获得零默认值,迁移可重复执行并完整回滚。"""
|
|
engine = sa.create_engine("sqlite://")
|
|
metadata = sa.MetaData()
|
|
batch = sa.Table(
|
|
"subscriptionsearchbatch",
|
|
metadata,
|
|
sa.Column("id", sa.Integer(), primary_key=True),
|
|
sa.Column("batch_id", sa.String(64), nullable=False),
|
|
)
|
|
with engine.begin() as connection:
|
|
metadata.create_all(connection)
|
|
connection.execute(batch.insert(), {"id": 1, "batch_id": "batch-1"})
|
|
migration = _bind_migration(monkeypatch, connection)
|
|
|
|
migration.upgrade()
|
|
migration.upgrade()
|
|
|
|
columns = {
|
|
column["name"]
|
|
for column in sa.inspect(connection).get_columns("subscriptionsearchbatch")
|
|
}
|
|
assert "skipped_count" in columns
|
|
assert connection.execute(
|
|
sa.text("SELECT skipped_count FROM subscriptionsearchbatch WHERE id = 1")
|
|
).scalar_one() == 0
|
|
|
|
migration.downgrade()
|
|
downgraded = {
|
|
column["name"]
|
|
for column in sa.inspect(connection).get_columns("subscriptionsearchbatch")
|
|
}
|
|
assert "skipped_count" not in downgraded
|
|
|
|
migration.upgrade()
|
|
assert connection.execute(
|
|
sa.text("SELECT skipped_count FROM subscriptionsearchbatch WHERE id = 1")
|
|
).scalar_one() == 0
|
|
engine.dispose()
|