fix: persist canceled batch reports while native cleanup continues

This commit is contained in:
阿白叔 committed 2026-11-25 18:28:10 +08:00
1 parent becaf2e8e4
commit 7d9a107921
2 files changed
+36 -2

No files matched your search

+33
View File
@@ -492,6 +492,39 @@ def test_result_release_and_resume_buttons_run_only_unexecuted_items(controls, q
assert [request.block_name for request in controls.runs] == ['Beta','Gamma']
def test_cancelled_batch_report_is_saved_during_native_handoff(controls, qtbot, monkeypatch):
from cbb_refresh_verify.operation_queue import BatchTaskContext, TaskHandoff
from cbb_refresh_verify.ui import main_window
window = controls.window
finish_native = Event()
native_finished = Event()
def pending_native():
finish_native.wait(8)
native_finished.set()
def cancelled_batch(requests, **_):
handoff = BatchTaskContext(str(controls.library))
with pytest.raises(TaskHandoff):
handoff.run(pending_native, timeout_seconds=.1)
return [VerifyResult('CANCELLED', safe_to_continue=False),
*[VerifyResult('SKIPPED') for _ in requests[1:]]]
monkeypatch.setattr(main_window, 'run_batch', cancelled_batch)
try:
with modal_click(qtbot, QMessageBox.Yes):
press(qtbot, window.batch_button)
qtbot.waitUntil(lambda: not window.busy)
reports = list((window.data_root/'reports').glob('batch-*.log'))
assert len(reports) == 1
assert 'Beta\tCANCELLED' in reports[0].read_text(encoding='utf-8-sig')
assert not native_finished.is_set()
finally:
finish_native.set()
assert native_finished.wait(3)
@pytest.mark.parametrize('entry', ['icdb_copy', 'icdb_release', 'batch_copy', 'batch_close'])
def test_result_recovery_and_release_entries_stay_bound_to_failed_cbb(controls, qtbot, entry):
from dataclasses import replace