fix: allow native inspection and backup entry after batch errors
This commit is contained in:
1 parent
aea6192ef9
commit
1acfbd6374
5 files changed
+65
-12
No files matched your search
@@ -199,10 +199,14 @@ def _inspect_project(job, process, emit):
|
||||
while process.poll() is None and time.monotonic() < deadline + 3:
|
||||
windows = [w for w in _windows(process.pid) if not (
|
||||
w['title'] == '' and w['class'] in ('UAC_InputIndicatorOverlayWnd', 'UAC Input Indicator'))]
|
||||
mains = [w for w in windows if w['class'].startswith('Afx:')
|
||||
and w['title'].casefold() == ('iCDB Project Backup - '+str(project)).casefold()]
|
||||
main = mains[0] if len(mains) == 1 else None
|
||||
shells = [w for w in windows if w['class'].startswith('Afx:') and w['title'] == 'iCDB Project Backup']
|
||||
exact = [w for w in windows if w['class'].startswith('Afx:')
|
||||
and w['title'].casefold() == ('iCDB Project Backup - '+str(project)).casefold()]
|
||||
# EE7.9 can keep the generic shell title while loading the requested PRJ.
|
||||
# Its Output still binds the project; waiting only for the decorated title
|
||||
# turns a valid session into a false timeout.
|
||||
mains = exact or shells
|
||||
main = mains[0] if len(mains) == 1 else None
|
||||
unknown = [w for w in windows if w is not main and w not in shells]
|
||||
if unknown:
|
||||
result.update(status='UNCONFIRMED', unknown_dialogs=unknown)
|
||||
|
||||
@@ -312,8 +312,9 @@ class MainWindow(QWidget):
|
||||
# are optional and only enable the extra contents check.
|
||||
ready = not self.busy and self.loaded_path == self.lmc_edit.text() and self.cbb_table.rowCount() > 0
|
||||
selected = self.selected_records()
|
||||
native_target = self._native_backup_target()
|
||||
self.native_backup_button.setEnabled(ready and self._native_backup_session is None
|
||||
and len(selected) == 1 and selected[0].status != 'READY')
|
||||
and native_target is not None)
|
||||
ready = ready and not self._native_backup_same_library()
|
||||
self.batch_button.setEnabled(ready and bool(self._eligible_names()))
|
||||
self.selected_batch_button.setEnabled(ready and bool(self._eligible_names(checked_only=True)))
|
||||
@@ -521,7 +522,19 @@ class MainWindow(QWidget):
|
||||
|
||||
def _maintenance_names(self):
|
||||
records = self.selected_records() or self.visible_records()
|
||||
return [record.name for record in records if record.status != 'READY']
|
||||
return [record.name for record in records
|
||||
if record.status != 'READY' and record.name not in self.skipped_names]
|
||||
|
||||
def _native_backup_target(self):
|
||||
selected = self.selected_records()
|
||||
if selected:
|
||||
return selected[0] if len(selected) == 1 and selected[0].status != 'READY' else None
|
||||
row = self.cbb_table.currentRow()
|
||||
if row < 0 or self.cbb_table.isRowHidden(row):
|
||||
return None
|
||||
item = self.cbb_table.item(row, 0)
|
||||
record = self._records_by_name.get(item.text()) if item is not None else None
|
||||
return record if record is not None and record.status != 'READY' else None
|
||||
|
||||
def _check_visible(self, state):
|
||||
self.cbb_table.blockSignals(True)
|
||||
@@ -740,12 +753,12 @@ class MainWindow(QWidget):
|
||||
def open_native_backup(self):
|
||||
if self.busy or not self.loaded_path or self._native_backup_session is not None:
|
||||
return
|
||||
selected = self.selected_records()
|
||||
if len(selected) != 1 or selected[0].status == 'READY':
|
||||
target = self._native_backup_target()
|
||||
if target is None:
|
||||
self.status_label.setText('请勾选一个非 READY CBB。')
|
||||
return
|
||||
from cbb_refresh_verify.native_backup import launch_native_backup
|
||||
request = self._request(selected[0].name)
|
||||
request = self._request(target.name)
|
||||
launcher = self.native_backup_launcher or launch_native_backup
|
||||
self._global_icdb_run = False
|
||||
self._reimport_offers = ()
|
||||
|
||||
@@ -154,7 +154,7 @@ def test_busy_or_unknown_inspection_is_not_labelled_as_database_damage(qtbot, tm
|
||||
assert 'ICDB 问题' not in window.cbb_table.item(window._row_by_name['Beta'], 3).text()
|
||||
|
||||
|
||||
def test_missing_pcb_can_be_checked_without_enabling_verify_or_restore(qtbot, tmp_path, monkeypatch):
|
||||
def test_missing_pcb_is_skipped_from_icdb_batch_check_and_restore(qtbot, tmp_path, monkeypatch):
|
||||
from test_ui_filters import load_window
|
||||
from cbb_refresh_verify.models import CbbRecord
|
||||
from cbb_refresh_verify.verify_runner import VerifyResult
|
||||
@@ -163,10 +163,23 @@ def test_missing_pcb_can_be_checked_without_enabling_verify_or_restore(qtbot, tm
|
||||
records=(CbbRecord('Missing', 'Power', status='PENDING'),),
|
||||
verifier=lambda req: (calls.append(req.block_name) or VerifyResult('CHECKED')),
|
||||
status_refresher=lambda names, _: {name: 'PENDING' for name in names})
|
||||
assert window.icdb_repair_button.isEnabled()
|
||||
assert not window.icdb_repair_button.isEnabled()
|
||||
assert not window.batch_button.isEnabled() and not window.backup_restore_button.isEnabled()
|
||||
window.icdb_repair_button.click(); qtbot.waitUntil(lambda: not window.busy)
|
||||
assert calls == ['Missing']
|
||||
assert calls == []
|
||||
|
||||
|
||||
def test_missing_project_rows_are_excluded_from_icdb_batch_check(qtbot, tmp_path, monkeypatch):
|
||||
from test_ui_filters import load_window
|
||||
from cbb_refresh_verify.models import CbbRecord
|
||||
from cbb_refresh_verify.verify_runner import VerifyResult
|
||||
window = load_window(qtbot, tmp_path, monkeypatch,
|
||||
records=(CbbRecord('Missing', 'Power', status='PENDING'),
|
||||
CbbRecord('Good', 'Power', status='PENDING')),
|
||||
verifier=lambda req: VerifyResult('CHECKED'),
|
||||
status_refresher=lambda names, _: {name: 'PENDING' for name in names})
|
||||
window.skipped_names.add('Missing')
|
||||
window._update()
|
||||
assert window._maintenance_names() == ['Good']
|
||||
|
||||
|
||||
def test_check_reports_describe_inspection_without_pcb_verification(case, tmp_path):
|
||||
|
||||
@@ -136,6 +136,16 @@ def test_native_backup_selection_requires_one_visible_non_ready_item(qtbot, tmp_
|
||||
window = load_window(qtbot, tmp_path, monkeypatch,
|
||||
native_backup_launcher=lambda _: pytest.fail('unexpected launch'))
|
||||
assert not window.native_backup_button.isEnabled()
|
||||
|
||||
|
||||
def test_native_backup_can_use_current_non_ready_row_without_checkbox(qtbot, tmp_path, monkeypatch):
|
||||
from test_ui_filters import load_window
|
||||
window = load_window(qtbot, tmp_path, monkeypatch,
|
||||
native_backup_launcher=lambda _: pytest.fail('unexpected launch'))
|
||||
row = window._row_by_name['Beta']
|
||||
window.cbb_table.setCurrentCell(row, 0)
|
||||
window._update()
|
||||
assert window.native_backup_button.isEnabled()
|
||||
window.search_edit.setText('Alpha'); window.select_visible_button.click()
|
||||
assert not window.native_backup_button.isEnabled()
|
||||
window.search_edit.clear(); window.select_visible_button.click()
|
||||
|
||||
@@ -53,6 +53,19 @@ def test_inspection_mode_only_observes_and_closes_its_tool(tmp_path, monkeypatch
|
||||
assert actions == [(100, win32con.WM_CLOSE)]
|
||||
|
||||
|
||||
def test_generic_project_backup_shell_is_accepted_as_the_single_target_window(tmp_path, monkeypatch):
|
||||
import json
|
||||
from test_native_repair import repair_worker_fixture
|
||||
ui, root, job, actions = repair_worker_fixture(tmp_path, monkeypatch, 'active')
|
||||
data = json.loads(job.read_text('utf-8')); data['inspection_only'] = True
|
||||
job.write_text(json.dumps(data), encoding='utf-8')
|
||||
monkeypatch.setattr(ui, '_native_output', lambda windows: (
|
||||
f'Loading project file [{data["project"]}].\nChecking if project is in use.\n'
|
||||
"Project is not in use. Full iCDB Project Backup's functionality is available.\n"
|
||||
'Backup information loaded correctly.'))
|
||||
assert ui.repair_worker_main(job) == 0
|
||||
|
||||
|
||||
def test_only_check_never_counts_as_repair_success():
|
||||
from cbb_refresh_verify.icdb_maintenance import maintenance_counts
|
||||
from cbb_refresh_verify.verify_runner import VerifyResult
|
||||
|
||||
Reference in new issue
Block a user