test: align native lifecycle fixtures with validated source identities

This commit is contained in:
阿白叔 committed 2026-11-17 02:24:32 +08:00
1 parent 2149e71b67
commit f964ff347c
3 files changed
+10 -5

No files matched your search

+1 -1
View File
@@ -64,7 +64,7 @@ while not (root/'lm-exit').exists(): time.sleep(.02)
patch.setattr(win32gui, 'EnumChildWindows', lambda h, fn, arg:
fn(301, arg) if h == 300 and mode == 'acknowledged' else None)
# Only the external native text-control setter is substituted.
patch.setattr(native, '_set_probe_field', lambda *args: None)
patch.setattr(native, '_set_probe_field', lambda hwnd, control, value, root, *, read_only=False: None)
def post(hwnd, *args):
if hwnd == 110: state['new'] = True
if hwnd == 210:
+3 -3
View File
@@ -97,7 +97,7 @@ def test_native_project_normalization_is_a_recorded_difference_not_import_failur
def worker(adapter, job, evidence):
result = original_worker(adapter, job, evidence)
if job['operation'] == 'add' and result.get('success'):
project = request.library.parent/'ReusableBlocksLP/Block/Work/Source.prj'
project = request.library.parent/'ReusableBlocksLP/Block/Work/Block.prj'
with project.open('a') as stream:
stream.write('SECTION VBPCBIndicators\nKEY VBPCBForwardAnno "0"\nKEY CADBackAnno "0"\nENDSECTION\n')
return result
@@ -106,7 +106,7 @@ def test_native_project_normalization_is_a_recorded_difference_not_import_failur
assert result.status == 'UPLOADED' and result.safe_to_continue, result.detail
comparison = json.loads((result.evidence_path.parent/'add/identity-comparison.json').read_text())
assert comparison['identity_matches'] and not comparison['assets_match']
assert 'Source.prj' in comparison['asset_differences']['modified']
assert 'Block.prj' in comparison['asset_differences']['modified']
@pytest.mark.parametrize('registered_top,expected', [('Block', 'UPLOADED'), ('Foreign', 'RECOVERY_REQUIRED')])
@@ -117,7 +117,7 @@ def test_native_top_block_may_match_registration_name_but_not_an_unrelated_name(
def worker(adapter, job, evidence):
result = original_worker(adapter, job, evidence)
if job['operation'] == 'add' and result.get('success'):
project = request.library.parent/'ReusableBlocksLP/Block/Work/Source.prj'
project = request.library.parent/'ReusableBlocksLP/Block/Work/Block.prj'
project.write_text(project.read_text().replace('KEY RootBlock "Top"', f'KEY RootBlock "{registered_top}"'))
return result
monkeypatch.setattr(native.NativeManagementAdapter, '_worker', worker)
+6 -1
View File
@@ -109,7 +109,12 @@ def test_real_file_error_preserves_failed_item_and_allows_an_independent_item(tr
return assets(source, expected_library)
monkeypatch.setattr(identity, 'asset_identity', read_assets)
adapter = _OwnedFixtureManagementAdapter(root, 'owned')
results = run_management_batch([request, replace(request, name='Other')], adapter=adapter,
from test_management import project
other_source = project(request.source.parent.parent/'other-source', name='Other')
for path in (other_source, other_source.parent/'PCB/pcb.prj'):
with path.open('a') as stream:
stream.write(f'KEY CentralLibrary "{request.library}"\n')
results = run_management_batch([request, replace(request, name='Other', source=other_source)], adapter=adapter,
idle_check=lambda *_: None)
assert [r.status for r in results] == ['RECOVERY_REQUIRED', 'UPLOADED']
assert all(r.safe_to_continue for r in results)