feat: enable validated pinned native Add and replacement routes

This commit is contained in:
阿白叔 committed 2026-11-03 12:29:42 +08:00
1 parent f21781f170
commit e915aaa865
6 files changed
+60 -12

No files matched your search

+3
View File
@@ -61,6 +61,9 @@ def test_add_dialog_default_auto_verify_and_source_identity_rows(qtbot, tmp_path
assert all(r.auto_verify and r.source.suffix == '.prj' for r in requests)
dialog.auto_verify.setChecked(False)
assert not any(r.auto_verify for r in dialog.requests())
dialog._progress({'stage': 'prepare_identity', 'block': 'One'})
assert '正在核对来源工程内容' in dialog.status_label.text()
assert 'prepare_identity' not in dialog.status_label.text()
def test_restart_shows_unfinished_without_starting_worker(qtbot, tmp_path):
+34 -1
View File
@@ -177,7 +177,40 @@ def test_add_route_readiness_is_separate_from_conservative_capability_gate(tmp_p
adapter = native.NativeManagementAdapter(mentor_home=tmp_path)
assert adapter.route_capabilities()['add'].supported
assert not adapter.capabilities()['add'].supported
assert '身份' in adapter.capabilities()['add'].reason
assert 'icdb2ascii' in adapter.capabilities()['add'].reason
@pytest.mark.parametrize('bad', [None, 'CleanWGLib.exe', 'LibraryManager.exe', 'LMCDLL70.dll',
'LMCDocAddin70.dll', 'icdb2ascii.exe', 'icdb2csv.exe', 'edifExporter.exe'])
def test_public_crud_requires_pinned_core_and_every_identity_exporter(tmp_path, monkeypatch, bad):
import hashlib
import cbb_refresh_verify.native_management as native
import cbb_refresh_verify.native_engineering_identity as identity
core = {relative: hashlib.sha256(Path(relative).name.encode()).hexdigest() for relative in native._BINARY_PROOF}
exporters = {name: hashlib.sha256(name.encode()).hexdigest() for name in identity.EXPORTER_PROOF}
monkeypatch.setattr(native, '_BINARY_PROOF', core)
monkeypatch.setattr(identity, 'EXPORTER_PROOF', exporters)
for relative in core:
path = tmp_path/relative; path.parent.mkdir(parents=True, exist_ok=True); path.write_bytes(path.name.encode())
for name in exporters:
path = tmp_path/('wv/win32/bin' if name == 'edifExporter.exe' else 'iCDB/win32/bin')/name
path.parent.mkdir(parents=True, exist_ok=True); path.write_bytes(name.encode())
if bad:
next(tmp_path.rglob(bad)).write_bytes(b'changed binary')
caps = native.NativeManagementAdapter(mentor_home=tmp_path).capabilities()
assert caps['add'].supported is (bad is None)
assert caps['update'].supported is (bad is None)
if bad in exporters: assert caps['remove'].supported
@pytest.mark.parametrize('operation', ['add', 'update', 'remove'])
@pytest.mark.parametrize('flow,partition', [(2, 'Logical-Physical'), (1, 'Unsupported')])
def test_public_crud_scope_refuses_unproven_flow_or_partition(tmp_path, operation, flow, partition):
from cbb_refresh_verify.management import ManagementRequest, Catalog
from cbb_refresh_verify.native_management import NativeManagementAdapter
request = ManagementRequest(operation, tmp_path/'lib.lmc', 'Block', partition=partition)
with pytest.raises(ValueError):
NativeManagementAdapter(mentor_home=tmp_path).preflight(request, Catalog(request.library, flow, ()))
def test_owned_fixture_add_passes_existing_library_and_source_to_worker(tmp_path, monkeypatch):