feat: replace automatic ICDB maintenance with batch inspection
This commit is contained in:
1 parent
beb2b06fdf
commit
53118bae19
15 files changed
+397
-67
No files matched your search
@@ -0,0 +1,181 @@
|
||||
"""Batch ICDB inspection never opens PCB or dispatches Repair."""
|
||||
from dataclasses import replace
|
||||
import json
|
||||
|
||||
import pytest
|
||||
|
||||
from test_maintenance_entry import case, no_native_launch
|
||||
from test_maintenance_diagnosis import inspection
|
||||
|
||||
|
||||
@pytest.mark.parametrize('scenario,status,category,safe', [
|
||||
('healthy', 'CHECKED', '', True),
|
||||
('fault', 'FAIL', 'ICDB_REPAIR_REQUIRED', True),
|
||||
('busy', 'BLOCKED', 'ICDB_DATABASE_IN_USE', True),
|
||||
('unknown', 'FAIL', 'ICDB_INSPECTION_UNCONFIRMED', True),
|
||||
('unexpected_repair', 'FAIL', 'ICDB_INSPECTION_UNCONFIRMED', True),
|
||||
('missing_exit_proof', 'FAIL', 'ICDB_INSPECTION_UNCONFIRMED', False),
|
||||
('not_launched', 'FAIL', 'ICDB_INSPECTION_UNCONFIRMED', True),
|
||||
('unreleased', 'FAIL', 'ICDB_INSPECTION_UNCONFIRMED', False),
|
||||
('cancelled', 'CANCELLED', '', True),
|
||||
])
|
||||
def test_batch_check_only_loads_native_inspection(case, monkeypatch, scenario, status, category, safe):
|
||||
from cbb_refresh_verify import verify_runner as runner, native_repair, maintenance_entry as entry
|
||||
from test_native_occupancy import output
|
||||
request, _, address = case
|
||||
calls = []
|
||||
monkeypatch.setattr(runner, '_run_verify_serialized', lambda *a, **k: pytest.fail('check opened PCB'))
|
||||
monkeypatch.setattr(entry, 'assert_native_idle', lambda: pytest.fail('check used host-wide owner gate'))
|
||||
def native(target, root, **kw):
|
||||
assert kw['inspection_only'] is True and not kw.get('maintenance_context')
|
||||
calls.append('inspect')
|
||||
record = inspection(target, fault=scenario == 'fault')
|
||||
if scenario == 'busy':
|
||||
record.update(status='IN_USE', output=output(target.project, target.database, busy=True))
|
||||
if scenario in ('unknown', 'unreleased'):
|
||||
record.update(status='UNCONFIRMED', output='No conclusive native response')
|
||||
if scenario == 'unreleased': record['release']['native_exited'] = False
|
||||
if scenario == 'cancelled': record.update(status='CANCELLED')
|
||||
if scenario == 'unexpected_repair': record.update(status='REPAIRED', repair_requested=True)
|
||||
if scenario == 'missing_exit_proof': return {}
|
||||
if scenario == 'not_launched': return {'status': 'BLOCKED', 'native_started': False}
|
||||
return record
|
||||
monkeypatch.setattr(native_repair, 'run_native_repair', native)
|
||||
result = runner.run_verify(replace(request, auto_repair=True))
|
||||
assert calls == ['inspect']
|
||||
assert (result.status, result.error_category, result.safe_to_continue) == (status, category, safe)
|
||||
assert result.library_flag == 'UNKNOWN' and result.recovery_attempts == ()
|
||||
assert address.read_bytes() == b'old server address - preserved'
|
||||
record = json.loads(result.evidence_path.read_text('utf-8'))
|
||||
assert record['operation'] == 'icdb_batch_check' and record['automatic_repair'] is False
|
||||
|
||||
|
||||
@pytest.mark.parametrize('case_type', ['no_layout', 'no_pcb', 'no_icdb', 'ambiguous_repair_targets'])
|
||||
def test_inspection_does_not_require_repair_admission(case, monkeypatch, case_type):
|
||||
from cbb_refresh_verify import verify_runner as runner, native_repair
|
||||
request, project, address = case
|
||||
if case_type == 'no_layout': (project.parent/'PCB/Layout/LayoutDB.lyt').unlink()
|
||||
if case_type == 'no_pcb': (project.parent/'PCB/IP101GR.pcb').unlink()
|
||||
if case_type == 'no_icdb': (project.parent/'database/icdb.dat').unlink()
|
||||
if case_type == 'ambiguous_repair_targets':
|
||||
address.unlink()
|
||||
(project.parent/'PCB/pcb.prj').write_text('KEY iCDBDir "database"\n')
|
||||
db = project.parent/'PCB/database'; db.mkdir(); (db/'icdb.dat').touch()
|
||||
calls = []
|
||||
def native(target, *a, **kw):
|
||||
assert kw['inspection_only'] is True and target.project == project
|
||||
calls.append('inspect')
|
||||
return inspection(target)
|
||||
monkeypatch.setattr(native_repair, 'run_native_repair', native)
|
||||
result = runner.run_verify(request)
|
||||
assert calls == ['inspect']
|
||||
assert result.recovery_attempts == ()
|
||||
|
||||
|
||||
@pytest.mark.parametrize('before_launch', [True, False])
|
||||
def test_cancellation_never_dispatches_repair_or_reports_a_clean_check(case, monkeypatch, before_launch):
|
||||
from threading import Event
|
||||
from cbb_refresh_verify import verify_runner as runner, native_repair
|
||||
request, _, _ = case
|
||||
stop = Event(); calls = []
|
||||
if before_launch: stop.set()
|
||||
def native(target, *a, **kw):
|
||||
assert kw['inspection_only'] is True
|
||||
calls.append('inspect'); stop.set()
|
||||
return inspection(target)
|
||||
monkeypatch.setattr(native_repair, 'run_native_repair', native)
|
||||
result = runner.run_verify(request, stop=stop)
|
||||
assert result.status == 'CANCELLED' and result.safe_to_continue
|
||||
assert calls == ([] if before_launch else ['inspect'])
|
||||
|
||||
|
||||
def test_released_icdb_fault_continues_the_check_batch(case, monkeypatch):
|
||||
from cbb_refresh_verify import verify_runner as runner, native_repair
|
||||
request, _, _ = case
|
||||
calls = []
|
||||
def native(target, root, **kw):
|
||||
assert kw['inspection_only'] is True
|
||||
calls.append('inspect')
|
||||
return inspection(target, fault=len(calls) == 1)
|
||||
monkeypatch.setattr(native_repair, 'run_native_repair', native)
|
||||
monkeypatch.setattr(runner, '_run_verify_serialized', lambda *a, **k: pytest.fail('check opened PCB'))
|
||||
results = runner.run_batch([request, request])
|
||||
assert calls == ['inspect', 'inspect']
|
||||
assert [result.status for result in results] == ['FAIL', 'CHECKED']
|
||||
|
||||
|
||||
def test_inspection_ignores_other_pcb_and_skips_exclusive_repair_probe(tmp_path, monkeypatch):
|
||||
import win32con
|
||||
from test_native_repair import repair_worker_fixture
|
||||
from test_native_occupancy import output
|
||||
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('cbb_refresh_verify.mentor_adapter.pcb_processes', lambda: [(999, 'other.pcb', '')])
|
||||
monkeypatch.setattr('cbb_refresh_verify.native_repair.check_repair_access',
|
||||
lambda *a: pytest.fail('inspection used exclusive Repair admission'))
|
||||
monkeypatch.setattr(ui, '_repair_command', lambda *a: pytest.fail('inspection resolved Repair command'))
|
||||
monkeypatch.setattr(ui, '_native_output', lambda *_: output(data['project'], data['database'], busy=True))
|
||||
assert ui.repair_worker_main(job) == 0
|
||||
assert actions == [(100, win32con.WM_CLOSE)]
|
||||
|
||||
|
||||
def test_ui_check_summary_reports_findings_and_never_claims_repair(qtbot, tmp_path, monkeypatch):
|
||||
from test_ui_filters import load_window
|
||||
from cbb_refresh_verify.verify_runner import VerifyResult
|
||||
from PySide6.QtWidgets import QMessageBox
|
||||
requests, prompts = [], []
|
||||
window = load_window(qtbot, tmp_path, monkeypatch,
|
||||
verifier=lambda req: (requests.append(req) or VerifyResult('FAIL',
|
||||
error_category='ICDB_REPAIR_REQUIRED', stderr='发现 ICDB 问题,未执行修复。')),
|
||||
status_refresher=lambda names, _: {name: 'PENDING' for name in names})
|
||||
monkeypatch.setattr(QMessageBox, 'question', lambda *a, **k: (prompts.append(a[2]) or QMessageBox.Yes))
|
||||
window.search_edit.setText('Beta')
|
||||
window.icdb_repair_button.click(); qtbot.waitUntil(lambda: not window.busy)
|
||||
assert requests[0].maintenance and not requests[0].auto_repair
|
||||
assert '批量检查' in window.icdb_repair_button.text()
|
||||
assert not any('手动备份' in text for text in prompts)
|
||||
assert window.summary.windowTitle() == 'ICDB 批量检查结果'
|
||||
assert '发现问题 1' in window.summary.text()
|
||||
assert '修复并校验通过' not in window.summary.detailedText()
|
||||
|
||||
|
||||
@pytest.mark.parametrize('category,label', [('ICDB_DATABASE_IN_USE', '占用 1'),
|
||||
('ICDB_INSPECTION_UNCONFIRMED', '无法确认 1')])
|
||||
def test_busy_or_unknown_inspection_is_not_labelled_as_database_damage(qtbot, tmp_path, monkeypatch, category, label):
|
||||
from test_ui_filters import load_window
|
||||
from cbb_refresh_verify.verify_runner import VerifyResult
|
||||
window = load_window(qtbot, tmp_path, monkeypatch,
|
||||
verifier=lambda _: VerifyResult('FAIL', error_category=category, stderr='暂未完成检查。'),
|
||||
status_refresher=lambda names, _: {name: 'PENDING' for name in names})
|
||||
window.search_edit.setText('Beta')
|
||||
window.icdb_repair_button.click(); qtbot.waitUntil(lambda: not window.busy)
|
||||
assert label in window.summary.text()
|
||||
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):
|
||||
from test_ui_filters import load_window
|
||||
from cbb_refresh_verify.models import CbbRecord
|
||||
from cbb_refresh_verify.verify_runner import VerifyResult
|
||||
calls = []
|
||||
window = load_window(qtbot, tmp_path, monkeypatch,
|
||||
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.batch_button.isEnabled() and not window.backup_restore_button.isEnabled()
|
||||
window.icdb_repair_button.click(); qtbot.waitUntil(lambda: not window.busy)
|
||||
assert calls == ['Missing']
|
||||
|
||||
|
||||
def test_check_reports_describe_inspection_without_pcb_verification(case, tmp_path):
|
||||
from cbb_refresh_verify.verify_runner import write_batch_report, failure_report_path, VerifyResult
|
||||
request, _, _ = case
|
||||
report = write_batch_report([request], [VerifyResult('FAIL',
|
||||
error_category='ICDB_REPAIR_REQUIRED', stderr='发现 ICDB 问题,未执行修复。')], tmp_path/'reports')
|
||||
full = report.read_text('utf-8-sig')
|
||||
failed = failure_report_path(report).read_text('utf-8-sig')
|
||||
assert 'ICDB 批量检查' in full and 'Project Integration' not in full
|
||||
assert 'ICDB 检查异常' in failed and '发现问题: 1' in failed
|
||||
assert 'ICDB已修复待校验' not in failed
|
||||
@@ -56,7 +56,7 @@ def test_maintenance_guard_does_not_scan_other_cbb_projects(case, monkeypatch):
|
||||
|
||||
def test_repair_finishes_without_calling_verify(case, monkeypatch):
|
||||
from cbb_refresh_verify import native_repair, verify_runner as runner
|
||||
from test_maintenance_entry import patch_verification_after_fault
|
||||
from test_maintenance_entry import patch_verification_after_fault, run_legacy_maintenance
|
||||
from test_native_repair import complete_native_success
|
||||
req, _, address = case
|
||||
def repair(target, *a, **kw):
|
||||
@@ -65,7 +65,7 @@ def test_repair_finishes_without_calling_verify(case, monkeypatch):
|
||||
monkeypatch.setattr(native_repair, 'run_native_repair', repair)
|
||||
monkeypatch.setattr(native_repair, 'repair_release_state', lambda req, target, result: result['release'])
|
||||
patch_verification_after_fault(monkeypatch, runner, lambda *a, **k: pytest.fail('maintenance started CBB verification'))
|
||||
result = runner.run_verify(req)
|
||||
result = run_legacy_maintenance(req)
|
||||
assert result.status == 'REPAIRED' and result.safe_to_continue
|
||||
assert result.library_flag == 'UNKNOWN'
|
||||
assert result.recovery_attempts[0]['validation_passed'] is False
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Native occupancy must precede repair even when old addresses remain."""
|
||||
import pytest
|
||||
from test_maintenance_entry import case, no_native_launch, startup_failure
|
||||
from test_maintenance_entry import case, no_native_launch, startup_failure, run_legacy_maintenance
|
||||
from test_native_occupancy import output
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ def test_diagnosed_native_inspection_holds_lock_after_opening_pcb(case, monkeypa
|
||||
return inspection(target)
|
||||
monkeypatch.setattr(native_repair, 'run_native_repair', native)
|
||||
monkeypatch.setattr(runner, '_run_verify_serialized', startup)
|
||||
result = runner.run_verify(request)
|
||||
result = run_legacy_maintenance(request)
|
||||
assert result.status == 'CHECKED' and result.recovery_attempts == ()
|
||||
assert result.library_flag == 'UNKNOWN'
|
||||
assert result.safe_to_continue is True
|
||||
@@ -51,7 +51,7 @@ def test_unconfirmed_native_inspection_never_repairs(case, monkeypatch, fault):
|
||||
if fault == 'not_exited': record['release']['native_exited'] = False
|
||||
return record
|
||||
monkeypatch.setattr(native_repair, 'run_native_repair', native)
|
||||
result = runner.run_verify(request)
|
||||
result = run_legacy_maintenance(request)
|
||||
assert result.status == 'BLOCKED' and not result.recovery_attempts
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ def test_native_fault_repairs_once_without_running_separate_verification(case, m
|
||||
monkeypatch.setattr(native_repair, 'run_native_repair', native)
|
||||
monkeypatch.setattr(native_repair, 'repair_release_state', lambda req, target, result: result['release'])
|
||||
monkeypatch.setattr(runner, '_run_verify_serialized', verify)
|
||||
result = runner.run_verify(request)
|
||||
result = run_legacy_maintenance(request)
|
||||
assert calls == ['open', 'inspect', 'repair']
|
||||
assert result.status == 'REPAIRED' and len(result.recovery_attempts) == 1
|
||||
assert result.library_flag == 'UNKNOWN' and not result.recovery_attempts[0]['validation_passed']
|
||||
@@ -59,6 +59,16 @@ def startup_failure(request):
|
||||
f"Machine:[fixture-server] Path:[{database}] session:[fixture-current-session]"))
|
||||
|
||||
|
||||
def run_legacy_maintenance(request, **kwargs):
|
||||
"""Keep explicit recovery helper coverage separate from the batch-check API."""
|
||||
from cbb_refresh_verify import verify_runner as runner, maintenance_entry as entry
|
||||
if not request.maintenance:
|
||||
return runner.run_verify(request, **kwargs)
|
||||
return entry.run_diagnosed_maintenance(request,
|
||||
diagnose=lambda probe: runner.run_verify(probe, **kwargs),
|
||||
progress=kwargs.get('progress'), stop=kwargs.get('stop'))
|
||||
|
||||
|
||||
def patch_verification_after_fault(monkeypatch, runner, verify):
|
||||
"""Inject only native process boundaries; production interprets the Output."""
|
||||
from cbb_refresh_verify import native_repair
|
||||
@@ -108,7 +118,7 @@ def test_diagnosed_maintenance_enters_official_repair_once(case, monkeypatch, pc
|
||||
assert req.lmc_file == request.lmc_file and req.block_name == request.block_name
|
||||
return runner.VerifyResult('PASS', library_flag='GREEN')
|
||||
patch_verification_after_fault(monkeypatch, runner, verify)
|
||||
result = runner.run_verify(request)
|
||||
result = run_legacy_maintenance(request)
|
||||
assert calls == ['repair'] and result.status == 'REPAIRED'
|
||||
assert result.recovery_attempts[0]['validation_passed'] is False
|
||||
assert result.library_flag == 'UNKNOWN'
|
||||
@@ -220,7 +230,7 @@ def test_ordinary_verify_calls_native_verifier_despite_existing_address(case, mo
|
||||
calls = []
|
||||
monkeypatch.setattr(runner, '_run_verify_serialized', lambda *a, **k:
|
||||
(calls.append('verify') or runner.VerifyResult('FAIL', stderr='native ICDB problem')))
|
||||
result = runner.run_verify(replace(request, maintenance=False))
|
||||
result = run_legacy_maintenance(replace(request, maintenance=False))
|
||||
assert calls == ['verify'] and result.status == 'FAIL' and result.safe_to_continue
|
||||
assert address.read_bytes() == b'old server address - preserved'
|
||||
|
||||
@@ -249,7 +259,7 @@ def test_maintenance_guard_blocks_before_native(case, monkeypatch, obstacle):
|
||||
monkeypatch.setattr(entry, 'address_snapshot', mutate)
|
||||
monkeypatch.setattr(native_repair, 'run_native_repair', lambda *a, **k: pytest.fail('guard bypass'))
|
||||
try:
|
||||
result = runner.run_verify(request)
|
||||
result = run_legacy_maintenance(request)
|
||||
assert result.status == 'BLOCKED' and not result.safe_to_continue
|
||||
assert result.error_stage == 'preflight'
|
||||
finally:
|
||||
@@ -298,7 +308,7 @@ def test_nonrepair_outcomes_never_verify_or_count_success(case, monkeypatch, sta
|
||||
'status': status, 'release': {'safe_to_continue': False}, 'detail': 'native result'})
|
||||
monkeypatch.setattr(native_repair, 'repair_release_state', lambda *a: {'safe_to_continue': False})
|
||||
patch_verification_after_fault(monkeypatch, runner, lambda *a, **k: pytest.fail('unsafe or nonrepair outcome reopened'))
|
||||
result = runner.run_verify(request)
|
||||
result = run_legacy_maintenance(request)
|
||||
assert result.status != 'PASS' and not result.safe_to_continue
|
||||
assert result.recovery_attempts[0]['status'] == status
|
||||
|
||||
@@ -312,7 +322,7 @@ def test_native_success_cannot_bypass_remaining_address(case, monkeypatch):
|
||||
# Native release queries remain mocked, actual address/exclusive checks stay real.
|
||||
monkeypatch.setattr('cbb_refresh_verify.mentor_adapter.pcb_processes', lambda: [])
|
||||
monkeypatch.setattr('cbb_refresh_verify.mentor_adapter._process_details', lambda name: [])
|
||||
result = runner.run_verify(request)
|
||||
result = run_legacy_maintenance(request)
|
||||
assert result.status != 'PASS' and not result.safe_to_continue
|
||||
|
||||
|
||||
@@ -408,7 +418,7 @@ def test_failed_content_does_not_block_other_items_after_actual_release(case, mo
|
||||
monkeypatch.setattr(native_repair, 'run_native_repair', repair)
|
||||
monkeypatch.setattr(native_repair, 'repair_release_state', lambda req, target, result: result['release'])
|
||||
patch_verification_after_fault(monkeypatch, runner, lambda *a, **k: pytest.fail('nonrepair outcome reopened'))
|
||||
result = runner.run_verify(request)
|
||||
result = run_legacy_maintenance(request)
|
||||
assert result.status != 'PASS'
|
||||
assert result.safe_to_continue is expected_safe
|
||||
assert result.recovery_attempts[0]['status'] == status
|
||||
@@ -427,7 +437,7 @@ def test_successful_icdb_repair_then_version_choice_reports_partial_completion(c
|
||||
patch_verification_after_fault(monkeypatch, runner, lambda *a, **k: runner.VerifyResult('FAIL',
|
||||
error_category='PCB_VERSION_CHOICE_REQUIRED', stderr='PCB版本待选:最后用户保存/自动保存 2026/9/24 23:06',
|
||||
safe_to_continue=False, evidence_path=request.evidence_dir/'verify/result.json'))
|
||||
result = runner.run_verify(request)
|
||||
result = run_legacy_maintenance(request)
|
||||
assert result.status == 'REPAIRED' and result.safe_to_continue
|
||||
assert '待单独校验' in result.stdout
|
||||
assert result.recovery_attempts[0]['native_status'] == 'REPAIRED'
|
||||
@@ -448,7 +458,7 @@ def test_user_chosen_pcb_history_is_not_reported_as_lossless_repair(case, monkey
|
||||
'choice': 'last_user_saved', 'date': '2026/9/24 23:06', 'confirm_sent': True, 'historical_restore': True}))
|
||||
return runner.VerifyResult('PASS', library_flag='GREEN', evidence_path=root/'result.json')
|
||||
patch_verification_after_fault(monkeypatch, runner, verify)
|
||||
result = runner.run_verify(request)
|
||||
result = run_legacy_maintenance(request)
|
||||
assert result.status == 'REPAIRED' and result.library_flag == 'UNKNOWN'
|
||||
assert result.recovery_attempts[0]['status'] == 'REPAIRED_UNVERIFIED'
|
||||
assert not (request.evidence_dir/'verify').exists()
|
||||
@@ -4,7 +4,7 @@ import json
|
||||
|
||||
import pytest
|
||||
|
||||
from test_maintenance_entry import case, no_native_launch
|
||||
from test_maintenance_entry import case, no_native_launch, run_legacy_maintenance
|
||||
|
||||
|
||||
def fault_text(database):
|
||||
@@ -35,7 +35,7 @@ def test_healthy_startup_skips_project_backup_even_with_old_address(case, monkey
|
||||
calls = []
|
||||
install_probe(monkeypatch, runner.VerifyResult('PASS', safe_to_continue=True), calls)
|
||||
forbid_backup(monkeypatch)
|
||||
result = runner.run_verify(replace(request, native_lm_verify=True))
|
||||
result = run_legacy_maintenance(replace(request, native_lm_verify=True))
|
||||
assert calls == ['open']
|
||||
assert result.status == 'CHECKED' and result.library_flag == 'UNKNOWN'
|
||||
assert result.recovery_attempts == () and result.safe_to_continue
|
||||
@@ -52,7 +52,7 @@ def test_generic_startup_errors_remain_failures_without_backup(case, monkeypatch
|
||||
failed = runner.VerifyResult('FAIL', stderr=message, safe_to_continue=True)
|
||||
install_probe(monkeypatch, failed, calls)
|
||||
forbid_backup(monkeypatch)
|
||||
result = runner.run_verify(request)
|
||||
result = run_legacy_maintenance(request)
|
||||
assert calls == ['open'] and result == failed
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ def test_unmatched_or_unreleased_icdb_fault_never_enters_backup(case, monkeypatc
|
||||
calls = []
|
||||
install_probe(monkeypatch, failed, calls)
|
||||
forbid_backup(monkeypatch)
|
||||
result = runner.run_verify(request)
|
||||
result = run_legacy_maintenance(request)
|
||||
assert calls == ['open'] and result.status == failed.status
|
||||
assert not result.recovery_attempts
|
||||
assert result.safe_to_continue is failed.safe_to_continue
|
||||
@@ -91,7 +91,7 @@ def test_only_current_matching_fault_enters_native_maintenance(case, monkeypatch
|
||||
calls.append('maintenance')
|
||||
return runner.VerifyResult('REPAIRED')
|
||||
monkeypatch.setattr(entry, 'run_existing_address_maintenance', maintain)
|
||||
result = runner.run_verify(request)
|
||||
result = run_legacy_maintenance(request)
|
||||
assert calls == ['open', 'maintenance'] and result.status == 'REPAIRED'
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ def test_old_saved_diagnosis_does_not_turn_generic_startup_failure_into_repair(c
|
||||
failure = runner.VerifyResult('FAIL', stderr='License unavailable', evidence_path=root/'result.json')
|
||||
install_probe(monkeypatch, failure, calls)
|
||||
forbid_backup(monkeypatch)
|
||||
assert runner.run_verify(request) == failure
|
||||
assert run_legacy_maintenance(request) == failure
|
||||
assert calls == ['open']
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ def test_unsafe_startup_success_is_not_reported_as_healthy(case, monkeypatch):
|
||||
request, _, _ = case
|
||||
install_probe(monkeypatch, runner.VerifyResult('PASS', safe_to_continue=False), [])
|
||||
forbid_backup(monkeypatch)
|
||||
result = runner.run_verify(request)
|
||||
result = run_legacy_maintenance(request)
|
||||
assert result.status == 'FAIL' and not result.safe_to_continue
|
||||
|
||||
|
||||
@@ -161,7 +161,7 @@ def test_report_write_failure_does_not_block_a_released_healthy_project(case, mo
|
||||
if path.name == 'maintenance-result.json': raise PermissionError('report unavailable')
|
||||
return write(path, *args, **kwargs)
|
||||
monkeypatch.setattr(Path, 'write_text', unavailable)
|
||||
result = runner.run_verify(request)
|
||||
result = run_legacy_maintenance(request)
|
||||
assert result.status == 'CHECKED' and result.safe_to_continue
|
||||
assert result.evidence_path == evidence and evidence.read_text() == '{}'
|
||||
|
||||
@@ -180,6 +180,6 @@ def test_cancelled_startup_diagnosis_never_requests_repair(case, monkeypatch, be
|
||||
return startup_failure(req)
|
||||
monkeypatch.setattr(runner, '_run_verify_serialized', probe)
|
||||
forbid_backup(monkeypatch)
|
||||
result = runner.run_verify(request, stop=stop)
|
||||
result = run_legacy_maintenance(request, stop=stop)
|
||||
assert result.status == 'CANCELLED' and result.safe_to_continue
|
||||
assert calls == ([] if before_open else ['open'])
|
||||
@@ -78,7 +78,7 @@ def test_maintenance_summary_exposes_first_failure_reason(qtbot, tmp_path):
|
||||
assert detail not in window.summary.text()
|
||||
assert str(tmp_path) not in window.summary.text()
|
||||
assert detail not in window.status_label.text()
|
||||
assert '失败/受阻 1' in window.summary.text()
|
||||
assert '无法确认 1' in window.summary.text()
|
||||
|
||||
|
||||
def test_safe_maintenance_reloads_authoritative_catalog_after_worker_finishes(qtbot, tmp_path, monkeypatch):
|
||||
|
||||
@@ -19,7 +19,7 @@ def test_management_prompts_for_manual_backup_and_cancel_starts_nothing(qtbot, t
|
||||
assert '完整备份与检查点' not in seen[0]
|
||||
|
||||
|
||||
@pytest.mark.parametrize('action', ['verify_all', 'verify_selected', 'repair_icdb_all'])
|
||||
@pytest.mark.parametrize('action', ['verify_all', 'verify_selected'])
|
||||
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
|
||||
|
||||
+4
-3
@@ -78,7 +78,7 @@ def test_global_icdb_failure_preserves_untargeted_ready_and_stops_queue(qtbot, t
|
||||
assert window.cbb_table.item(1, 2).text() == '未知 / 需确认'
|
||||
assert window.cbb_table.item(2, 3).text().startswith('SKIPPED')
|
||||
|
||||
def test_global_icdb_progress_and_repair_summary(qtbot, tmp_path, monkeypatch):
|
||||
def test_global_icdb_progress_and_check_summary(qtbot, tmp_path, monkeypatch):
|
||||
from PySide6.QtWidgets import QMessageBox
|
||||
confirmations = []
|
||||
def confirm(*args, **kwargs):
|
||||
@@ -97,8 +97,9 @@ def test_global_icdb_progress_and_repair_summary(qtbot, tmp_path, monkeypatch):
|
||||
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 维护结果'
|
||||
assert '无法确认 1' in window.status_label.text()
|
||||
assert '恢复备份待复核' not in window.status_label.text()
|
||||
assert window.summary.windowTitle() == 'ICDB 批量检查结果'
|
||||
reports = list((tmp_path/'reports').glob('icdb-*.json'))
|
||||
assert len(reports) == 1
|
||||
|
||||
|
||||
Reference in new issue
Block a user