perf: replace automatic backups with manual backup reminders
This commit is contained in:
1 parent
7527800128
commit
c85696080d
26 files changed
+385
-102
No files matched your search
@@ -0,0 +1,51 @@
|
||||
from pathlib import Path
|
||||
import pytest
|
||||
from PySide6.QtWidgets import QMessageBox
|
||||
|
||||
|
||||
@pytest.mark.parametrize('operation', ['add', 'update', 'remove'])
|
||||
def test_management_prompts_for_manual_backup_and_cancel_starts_nothing(qtbot, tmp_path, monkeypatch, operation):
|
||||
from cbb_refresh_verify.management import ManagementRequest
|
||||
from cbb_refresh_verify.ui.management_dialog import ManagementDialog
|
||||
source = tmp_path/'Block.prj'; source.touch()
|
||||
seen, calls = [], []
|
||||
monkeypatch.setattr(QMessageBox, 'question', lambda *a, **k: (seen.append(a[2]) or QMessageBox.No))
|
||||
dialog = ManagementDialog([ManagementRequest(operation, tmp_path/'lib.lmc', 'Block', source=source)],
|
||||
runner=lambda *a, **k: calls.append(a))
|
||||
qtbot.addWidget(dialog)
|
||||
dialog.execute_button.click()
|
||||
assert not calls and not dialog.busy
|
||||
assert len(seen) == 1 and '手动备份' in seen[0] and '不会自动备份' in seen[0]
|
||||
assert '完整备份与检查点' not in seen[0]
|
||||
|
||||
|
||||
@pytest.mark.parametrize('action', ['verify_all', 'verify_selected', 'repair_icdb_all'])
|
||||
def test_batch_prompts_once_for_manual_backup_and_cancel_does_not_start(qtbot, tmp_path, monkeypatch, action):
|
||||
from cbb_refresh_verify.ui.main_window import MainWindow
|
||||
from cbb_refresh_verify.models import CbbRecord, LibraryReadResult
|
||||
window = MainWindow(reader=lambda _: LibraryReadResult((CbbRecord('Block', 'LP'),)), data_root=tmp_path)
|
||||
qtbot.addWidget(window)
|
||||
window.lmc_edit.setText('library.lmc'); window.load_library()
|
||||
qtbot.waitUntil(lambda: not window.busy)
|
||||
window.select_visible_button.click()
|
||||
seen, calls = [], []
|
||||
monkeypatch.setattr(window, '_run', lambda *a, **k: calls.append(a))
|
||||
monkeypatch.setattr(QMessageBox, 'question', lambda *a, **k: (seen.append(a[2]) or QMessageBox.No))
|
||||
getattr(window, action)()
|
||||
assert not calls
|
||||
assert len(seen) == 1 and '手动备份' in seen[0] and '不会自动备份' in seen[0]
|
||||
|
||||
|
||||
def test_restore_prompts_for_manual_backup_before_starting_worker(qtbot, tmp_path, monkeypatch):
|
||||
from cbb_refresh_verify.verify_runner import VerifyRequest, VerifyResult
|
||||
from cbb_refresh_verify.ui.backup_recovery_dialog import BackupRecoveryDialog
|
||||
calls, seen = [], []
|
||||
source = tmp_path/'Block.prj'; source.touch()
|
||||
monkeypatch.setattr(QMessageBox, 'question', lambda *a, **k: (seen.append(a[2]) or QMessageBox.No))
|
||||
dialog = BackupRecoveryDialog(['Block'], lambda n: VerifyRequest(tmp_path/'lib.lmc', n, tmp_path/'out'),
|
||||
recoverer=lambda *a, **k: (calls.append(a) or VerifyResult('PASS')))
|
||||
qtbot.addWidget(dialog)
|
||||
dialog.source_edit.setText(str(source)); dialog.restore_button.click()
|
||||
qtbot.waitUntil(lambda: not dialog.busy)
|
||||
assert not calls
|
||||
assert len(seen) == 1 and '手动备份' in seen[0] and '不会自动备份' in seen[0]
|
||||
Reference in new issue
Block a user