fix: admit linked legacy ICDB projects and explain blocked actions

This commit is contained in:
阿白叔 committed 2026-11-03 13:51:05 +08:00
1 parent 5eac654c36
commit d36b6bcad0
8 files changed
+138 -18

No files matched your search

+39 -1
View File
@@ -46,10 +46,13 @@ def case(tmp_path, monkeypatch):
if owner: owner['handle'].Close()
def test_explicit_maintenance_enters_official_repair_once_without_lostsession_fabrication(case, monkeypatch):
@pytest.mark.parametrize('pcb_config', ['standard', 'legacy_template'])
def test_explicit_maintenance_enters_official_repair_once_without_lostsession_fabrication(case, monkeypatch, pcb_config):
from cbb_refresh_verify import verify_runner as runner, native_repair
from test_native_repair import complete_native_success
request, project, address = case
if pcb_config == 'legacy_template':
(project.parent/'PCB/pcb.prj').rename(project.parent/'PCB/template.prj')
calls = []
def repair(target, root, **kwargs):
calls.append('repair')
@@ -79,6 +82,40 @@ def test_explicit_maintenance_enters_official_repair_once_without_lostsession_fa
assert 'session' not in record['maintenance_context']
@pytest.mark.parametrize('back_reference', ['', 'KEY ProjectFile "../other.prj"\n',
'KEY ProjectFile "../IP101GR.prj"\nKEY ProjectFile "../IP101GR.prj"\n'])
def test_legacy_maintenance_requires_unambiguous_pcb_back_reference(case, back_reference):
from cbb_refresh_verify.maintenance_entry import select_maintenance_target
request, project, _ = case
(project.parent/'PCB/pcb.prj').rename(project.parent/'PCB/template.prj')
(project.parent/'PCB/IP101GR.pcb').write_text(back_reference)
with pytest.raises(ValueError, match='MAINTENANCE_TARGET_UNCONFIRMED'):
select_maintenance_target(request)
def test_legacy_target_does_not_guess_template_for_physical_address(case):
from cbb_refresh_verify.maintenance_entry import select_maintenance_target
request, project, address = case
(project.parent/'PCB/pcb.prj').rename(project.parent/'PCB/template.prj')
address.unlink()
physical = project.parent/'PCB/database/cdbsvr/sAddress.adr'
physical.parent.mkdir(parents=True); physical.write_bytes(b'physical owner')
with pytest.raises(ValueError, match='SHARED_DATABASE_REPAIR_UNSUPPORTED'):
select_maintenance_target(request)
def test_optional_pcb_project_appearance_invalidates_maintenance_proof(case):
from cbb_refresh_verify.maintenance_entry import maintenance_target_guard
request, project, _ = case
config = project.parent/'PCB/pcb.prj'
config.rename(config.with_name('template.prj'))
with maintenance_target_guard(request) as proof:
before = proof['context']
config.write_text('KEY CentralLibrary "different.lmc"\n')
with pytest.raises(ValueError, match='MAINTENANCE_SOURCE_CHANGED'):
with maintenance_target_guard(request, before): pass
def test_ordinary_verify_still_blocks_existing_address_without_repair(case, monkeypatch):
from cbb_refresh_verify import verify_runner as runner, native_repair
request, _, address = case
@@ -114,6 +151,7 @@ def test_maintenance_guard_blocks_before_native(case, monkeypatch, obstacle):
try:
result = runner.run_verify(request)
assert result.status == 'BLOCKED' and not result.safe_to_continue
assert result.error_stage == 'preflight'
finally:
if handle: handle.Close()