feat: 完成T-204旧字段回写

实现 Excel 旧标题与旧封面路径回写原文件,按 source_file_abs/source_sheet/source_row 定位行,支持输出列自动追加、xlsm 保留 VBA、文件占用中文错误提示与 export_copy 另存副本。

Tab① 增加回写旧数据按钮与 WriteBackWorker,后台调用 excel.write_back,锁文件时提示关闭后重试;补充 Excel 与 GUI 单测覆盖回写、锁文件、另存副本和 worker 调用。

同步 harness 文档:T-204 标记完成,新增 T-204b 记录采集完成自动回写缺口,扩展 T-205 覆盖 Chrome 未启动/未登录引导保护,并更新 current-state、routes、api、architecture、requirements 与 progress。
This commit is contained in:
chengma
2026-06-27 14:37:58 +08:00
parent 8fe979942c
commit b9d84e71ec
11 changed files with 503 additions and 29 deletions
+19
View File
@@ -24,6 +24,7 @@ from app.gui import (
MainWindow,
TAB_STYLE,
TAB_TITLES,
WriteBackWorker,
)
@@ -57,6 +58,10 @@ class GuiTests(TempDirMixin, unittest.TestCase):
self.assertIn("padding: 8px 18px", window.tabs.styleSheet())
self.assertIn("margin-right: 8px", window.tabs.styleSheet())
self.assertIsInstance(window.tabs.widget(0), CollectTab)
self.assertEqual(
"回写旧数据到 Excel",
window.tabs.widget(0).write_back_button.text(),
)
self.assert_removed(temp_dir)
@@ -382,6 +387,20 @@ class GuiTests(TempDirMixin, unittest.TestCase):
self.assert_removed(temp_dir)
def test_write_back_worker_calls_excel_write_back(self):
with mock.patch(
"app.gui.excel.write_back",
return_value={"ok": True, "batch_id": "batch-1", "files": 1, "rows": 2},
) as write_back:
summary = WriteBackWorker("batch-1", db_path="db.sqlite").execute()
self.assertEqual({"ok": True, "batch_id": "batch-1", "files": 1, "rows": 2}, summary)
write_back.assert_called_once_with(
"batch-1",
excel_path=None,
path="db.sqlite",
)
if __name__ == "__main__":
unittest.main()