Preserve offline geometry, marking, replay and evaluation pipelines with source manifests and synthetic tests. Research qualification does not activate these methods as production navigation.
33 lines
1.6 KiB
Python
33 lines
1.6 KiB
Python
from pathlib import Path
|
|
import json,tempfile
|
|
from survey_index import surveyed_ids
|
|
|
|
|
|
def run():
|
|
with tempfile.TemporaryDirectory(prefix='survey-index-')as tmp:
|
|
root=Path(tmp);e=root/'evidence';e.mkdir();(e/'road-prompt').mkdir()
|
|
names=['tile-001-002','primary-000','camera.alpha'];rows=[]
|
|
for name in names+['tile-stray']:
|
|
p=root/name;p.mkdir();(p/'job.json').write_text('{}');(p/'top.geometry.npz').write_bytes(b'fixture')
|
|
(e/(name+'.normal.npz')).write_bytes(b'fixture');(e/'road-prompt'/(name+'.normal.npz')).write_bytes(b'fixture')
|
|
rows=[dict(id=n,status='surveyed')for n in names]+[dict(id='not-rendered',status='planned')]
|
|
def save(records):(root/'tile-index.json').write_text(json.dumps(dict(tiles=records)))
|
|
save(rows);assert surveyed_ids(root,evidence=e)==sorted(names)
|
|
# Legacy callers receive the same complete addresses without stripping
|
|
# and later reconstructing an assumed filename prefix.
|
|
save(rows[:1]);assert surveyed_ids(root)==['tile-001-002']
|
|
for records in [[],rows+[rows[0]],[dict(id='../escape',status='surveyed')]]:
|
|
save(records)
|
|
try:surveyed_ids(root)
|
|
except ValueError:pass
|
|
else:raise AssertionError('Invalid manifest accepted')
|
|
save(rows);(e/'road-prompt'/'primary-000.normal.npz').unlink()
|
|
try:surveyed_ids(root,evidence=e)
|
|
except ValueError:pass
|
|
else:raise AssertionError('Missing evidence silently skipped')
|
|
print('SURVEY_INDEX_CONTRACT_OK',flush=True)
|
|
|
|
|
|
def test_manifest_identity_contract():run()
|
|
if __name__=='__main__':run()
|