chore: snapshot in-progress question-gen work before preflight fixes

This commit is contained in:
2026-07-16 04:12:21 -04:00
parent 11a5545f57
commit a4c429b247
39 changed files with 738 additions and 283 deletions
+8
View File
@@ -1,4 +1,5 @@
"""修复管线断点续跑 progress 管理测试。"""
from __future__ import annotations
import asyncio
@@ -10,6 +11,7 @@ import pytest
def test_load_progress_missing_file(tmp_path):
"""progress 文件不存在时返回空集合。"""
from tools.repair_trees import load_progress
result = load_progress(tmp_path / "nonexistent.json")
assert result == set()
@@ -17,6 +19,7 @@ def test_load_progress_missing_file(tmp_path):
def test_load_progress_valid_file(tmp_path):
"""正常读取已有 progress 文件。"""
from tools.repair_trees import load_progress
path = tmp_path / "progress.json"
path.write_text(json.dumps({"finished_video_ids": ["vid_a", "vid_b"]}))
result = load_progress(path)
@@ -26,6 +29,7 @@ def test_load_progress_valid_file(tmp_path):
def test_load_progress_corrupted_file(tmp_path):
"""损坏的 JSON 文件返回空集合(不抛异常)。"""
from tools.repair_trees import load_progress
path = tmp_path / "progress.json"
path.write_text("{invalid json")
result = load_progress(path)
@@ -36,6 +40,7 @@ def test_load_progress_corrupted_file(tmp_path):
async def test_save_progress_atomic(tmp_path):
"""save_progress 原子写入,并发调用不丢失更新。"""
from tools.repair_trees import save_progress
path = tmp_path / "progress.json"
lock = asyncio.Lock()
await save_progress(path, lock, "vid_a")
@@ -48,6 +53,7 @@ async def test_save_progress_atomic(tmp_path):
async def test_save_progress_concurrent(tmp_path):
"""16 路并发 save_progress 不丢失更新。"""
from tools.repair_trees import save_progress
path = tmp_path / "progress.json"
lock = asyncio.Lock()
tasks = [save_progress(path, lock, f"vid_{i}") for i in range(16)]
@@ -59,6 +65,7 @@ async def test_save_progress_concurrent(tmp_path):
def test_should_skip_finished():
"""已在 finished 集合中的视频应跳过。"""
from tools.repair_trees import should_skip_video
finished = {"vid_a", "vid_b"}
assert should_skip_video("vid_a", finished, reaggregate_all=False) is True
assert should_skip_video("vid_c", finished, reaggregate_all=False) is False
@@ -67,5 +74,6 @@ def test_should_skip_finished():
def test_should_skip_reaggregate_all_forces_rerun():
"""--reaggregate-all 标志强制不跳过。"""
from tools.repair_trees import should_skip_video
finished = {"vid_a"}
assert should_skip_video("vid_a", finished, reaggregate_all=True) is False