fix: allow replacement without an explicit target cell

This commit is contained in:
阿白叔 committed 2026-10-19 16:15:21 +08:00
1 parent 81a8547352
commit d12478efd8
10 files changed
+141 -68

No files matched your search

+31
View File
@@ -329,3 +329,34 @@ def test_standalone_recovery_allows_cold_catalog_preflight_before_worker(interru
return run_worker(command, timeout)
interrupted.preparer._process_runner = run
assert invoke(interrupted).state == 'restored_ok'
@pytest.mark.parametrize('queue_has_cell_column', [False, True])
def test_recovery_without_cell_retains_protection_until_verified_without_catalog(interrupted, queue_has_cell_column):
f = interrupted
f.rules = (SimpleNamespace(old_part_number='OLD', new_part_number='NEW', enabled=True, target_cell=''),)
lines = f.handoff.command_path.read_text(encoding='utf-8').splitlines()
header, row = lines[0].split('\t'), lines[1].split('\t')
index = header.index('target_cell')
if queue_has_cell_column:
row[index] = ''
else:
header.pop(index); row.pop(index)
f.handoff.command_path.write_text('\t'.join(header)+'\n'+'\t'.join(row)+'\n',encoding='utf-8')
f.snapshot.write_text(f.snapshot.read_text().replace('L\tCELL\n',''),encoding='utf-8')
metadata, components = read_snapshot(f.snapshot)
f.report['transaction'] = transaction_binding(f.snapshot, metadata, components,
['library', 'NEW', 'symbol', '', 'cap', 'label'], 'symbol')
f.snapshot.with_suffix('.tsv.native.json').write_text(json.dumps(f.report),encoding='utf-8')
f.catalog_reads.clear()
run_worker = worker_result(f)
def run(command, timeout):
assert not f.catalog_reads
worker = Path(command[3])
text = (worker/'command.tsv').read_text(encoding='utf-8')
assert 'target_cell' not in text.splitlines()[0]
assert 'recovery_library_path' not in text.splitlines()[0]
return run_worker(command, timeout)
f.preparer._process_runner = run
assert invoke(f).state == 'restored_ok'
assert not f.lock.exists() and not f.catalog_reads