test(release): validate batch-owned native inventory cleanup in EXE acceptance

This commit is contained in:
阿白叔 committed 2026-10-23 14:02:00 +08:00
1 parent 9c4ccc5bf5
commit bc91b98385
2 files changed
+44 -4

No files matched your search

@@ -33,6 +33,30 @@ def test_bom_resource_verifier_accepts_cli_only_reads_without_cad(native_bom_evi
assert verifier.verify_bom_resources(root)=={'cad_sessions':0,'ready_native_cli_reads':2}
@pytest.mark.parametrize('fault', [None, 'pending', 'unbound', 'workers_open'])
def test_bom_resource_verifier_checks_batch_release_and_operation_binding(native_bom_evidence, fault):
verifier, root, rows = native_bom_evidence
operations = {}
for i, row in enumerate(rows):
path = root / f'data/tasks/{i}/quick-run-history/native-inventory-ok/native-inventory.json'
row['cleanup'].update(scope='operation', workers_closed=True, desktop_retained_by_batch=True)
path.write_text(json.dumps(row))
operations[str(path.parent.resolve())] = {'workers_closed': fault != 'workers_open',
'binding': {'session_id': 'batch', 'generation': 1, 'attempt_id': str(i)}}
if fault == 'unbound':
operations.clear()
path = root / 'data/batch-resources/batch/session.json'
path.parent.mkdir(parents=True)
path.write_text(json.dumps(dict(state='blocked' if fault == 'pending' else 'released',
session_id='batch', generation=1, native_operations=operations,
cleanup=dict(desktop_handle_closed=True, desktop_confirmation={'released':True}, errors=[]))))
if fault:
with pytest.raises(AssertionError):
verifier.verify_bom_resources(root)
else:
assert verifier.verify_bom_resources(root)['ready_native_cli_reads'] == 2
@pytest.mark.parametrize('fault',['uncertain','fallback_active_job','fallback_retained_workspace'])
def test_bom_resource_verifier_rejects_bad_earlier_attempt_despite_clean_retries(native_bom_evidence,fault):
verifier,root,rows=native_bom_evidence