feat: add ICDB maintenance and verified CBB backup recovery dialog
This commit is contained in:
1 parent
a851e47eca
commit
cdb8a6a28b
23 files changed
+1868
-23
No files matched your search
@@ -20,6 +20,90 @@ def test_application_palette_keeps_table_text_readable(qtbot):
|
||||
assert base.value() > 180
|
||||
|
||||
def fake_reader(_): return LibraryReadResult((CbbRecord('CBB1','Reusable Blocks'),))
|
||||
|
||||
def test_global_icdb_action_confirms_and_includes_ready_rows(qtbot, tmp_path, monkeypatch):
|
||||
from PySide6.QtWidgets import QMessageBox
|
||||
calls = []
|
||||
window = MainWindow(reader=lambda _: LibraryReadResult((
|
||||
CbbRecord('READY', 'LP', status='READY'), CbbRecord('PENDING', 'LP'))),
|
||||
verifier=lambda req: (calls.append(req.block_name) or VerifyResult('PASS')),
|
||||
data_root=tmp_path)
|
||||
qtbot.addWidget(window)
|
||||
window.lmc_edit.setText('lib.lmc'); window.load_library()
|
||||
qtbot.waitUntil(lambda: not window.busy)
|
||||
monkeypatch.setattr(QMessageBox, 'question', lambda *a, **k: QMessageBox.No)
|
||||
window.icdb_repair_button.click()
|
||||
assert calls == []
|
||||
monkeypatch.setattr(QMessageBox, 'question', lambda *a, **k: QMessageBox.Yes)
|
||||
window.icdb_repair_button.click()
|
||||
qtbot.waitUntil(lambda: not window.busy)
|
||||
assert calls == ['READY', 'PENDING']
|
||||
|
||||
def test_global_icdb_action_disabled_without_library_or_while_busy(qtbot):
|
||||
window = MainWindow(reader=fake_reader)
|
||||
qtbot.addWidget(window)
|
||||
assert not window.icdb_repair_button.isEnabled()
|
||||
window.lmc_edit.setText('lib.lmc'); window.load_library()
|
||||
qtbot.waitUntil(lambda: not window.busy)
|
||||
assert window.icdb_repair_button.isEnabled()
|
||||
window.busy = True; window._update()
|
||||
assert not window.icdb_repair_button.isEnabled()
|
||||
|
||||
def test_global_icdb_failure_clears_ready_and_stops_queue(qtbot, tmp_path, monkeypatch):
|
||||
from PySide6.QtWidgets import QMessageBox
|
||||
calls = []
|
||||
window = MainWindow(reader=lambda _: LibraryReadResult((
|
||||
CbbRecord('A', 'LP', status='READY'), CbbRecord('B', 'LP'))),
|
||||
verifier=lambda req: (calls.append(req.block_name) or VerifyResult(
|
||||
'FAIL', stderr='unconfirmed', safe_to_continue=False)), data_root=tmp_path)
|
||||
qtbot.addWidget(window)
|
||||
window.lmc_edit.setText('lib.lmc'); window.load_library()
|
||||
qtbot.waitUntil(lambda: not window.busy)
|
||||
monkeypatch.setattr(QMessageBox, 'question', lambda *a, **k: QMessageBox.Yes)
|
||||
window.icdb_repair_button.click()
|
||||
qtbot.waitUntil(lambda: not window.busy)
|
||||
assert calls == ['A']
|
||||
assert 'A' not in window.ready_names
|
||||
assert window.cbb_table.item(0, 2).text() == '未知 / 需确认'
|
||||
assert window.cbb_table.item(1, 3).text().startswith('SKIPPED')
|
||||
|
||||
def test_global_icdb_progress_and_repair_summary(qtbot, tmp_path, monkeypatch):
|
||||
from PySide6.QtWidgets import QMessageBox
|
||||
confirmations = []
|
||||
def confirm(*args, **kwargs):
|
||||
confirmations.append(args[2])
|
||||
return QMessageBox.Yes
|
||||
monkeypatch.setattr(QMessageBox, 'question', confirm)
|
||||
window = MainWindow(reader=fake_reader, data_root=tmp_path,
|
||||
verifier=lambda _: VerifyResult('FAIL', safe_to_continue=False, recovery_attempts=(
|
||||
{'status': 'RESTORED_REVIEW_REQUIRED', 'detail': 'restored old backup'},)))
|
||||
qtbot.addWidget(window)
|
||||
window.lmc_edit.setText('lib.lmc'); window.load_library()
|
||||
qtbot.waitUntil(lambda: not window.busy)
|
||||
window.icdb_repair_button.click()
|
||||
qtbot.waitUntil(lambda: not window.busy)
|
||||
assert 'lib.lmc' in confirmations[0]
|
||||
assert 'Ready' in confirmations[0]
|
||||
assert window.icdb_progress.value() == 1
|
||||
assert window.icdb_progress.maximum() == 1
|
||||
assert '恢复备份待复核 1' in window.status_label.text()
|
||||
assert window.summary.windowTitle() == '全库 ICDB 检查与修复结果'
|
||||
reports = list((tmp_path/'reports').glob('icdb-*.json'))
|
||||
assert len(reports) == 1
|
||||
|
||||
def test_ready_row_missing_project_is_skipped_by_global_maintenance(qtbot, tmp_path):
|
||||
library = tmp_path/'library.lmc'
|
||||
library.touch()
|
||||
window = MainWindow(reader=lambda _: LibraryReadResult((CbbRecord('MISSING', 'LP', status='READY'),)),
|
||||
data_root=tmp_path)
|
||||
qtbot.addWidget(window)
|
||||
window.lmc_edit.setText(str(library)); window.load_library()
|
||||
qtbot.waitUntil(lambda: not window.busy)
|
||||
assert window.skipped_names == {'MISSING'}
|
||||
assert 'MISSING' not in window.ready_names
|
||||
assert not window.icdb_repair_button.isEnabled()
|
||||
assert window.cbb_table.item(0, 2).text().startswith('跳过')
|
||||
|
||||
def test_verify_requires_loaded_library_and_invalidates_on_path_change(qtbot):
|
||||
window=MainWindow(reader=fake_reader, verifier=lambda _: VerifyResult('PASS')); qtbot.addWidget(window)
|
||||
assert not window.batch_button.isEnabled()
|
||||
|
||||
Reference in new issue
Block a user