Files
WoW-Hybrid-gateway/tests/map_conversion_wdl_boundary_test.py
praxisandClaude Fable 5.2 7f2139d8d0 Offline test fixtures
883 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

61 lines
3.5 KiB
Python

"""Verify the WDL batch interface against the owning qualified family output."""
import hashlib
import json
from pathlib import Path
import shutil
import sys
import tempfile
import unittest
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / 'ops'))
import map_conversion_batch as batch
class WdlBatchBoundary(unittest.TestCase):
def test_owned_source_wdl_batch_dedup_and_explicit_policy(self):
evidence = ROOT / 'docs/evidence/content-data/wdl-native-presentation-profile-20261026/assessment.json'
assessment = json.loads(evidence.read_text())
owned = json.loads((ROOT / assessment['full_output_and_binding_receipt']).read_text())['outputs'][0]
source = Path(owned['Source_file']); expected = ROOT / owned['output']
witness = ROOT / assessment['original_REA_witness']
def ref(path):
body = path.read_bytes()
return {'path': str(path.resolve()), 'sha256': hashlib.sha256(body).hexdigest(), 'bytes': len(body)}
source_ref = ref(source)
self.assertEqual(source_ref['sha256'], owned['Source_sha256'])
request = {'kind': 'map-conversion-batch-v1', 'payloads': {'source': source_ref},
'contracts': {'wdl': {'operation': 'wdl-native-profile', 'admission': 'private-candidate',
'receipt': ref(evidence), 'accepted_status': assessment['status'],
'api': 'wdl_source_height_native_profile_candidate', 'provenance': [ref(witness)]}},
'jobs': [{'id': name, 'kind': 'wdl', 'source': 'source',
'contracts': {'wdl-native-profile': 'wdl'},
'options': {'native_profile': assessment['policy']}} for name in ('a', 'b')]}
base = ROOT / 'runtime/continuation-20261029'
directory = Path(tempfile.mkdtemp(prefix='wdl-map-boundary-', dir=base))
self.addCleanup(shutil.rmtree, directory)
report = batch.convert_batch(request, directory / 'staged', base_directory=ROOT)
self.assertEqual([r['status'] for r in report['rows']], ['CONVERTED', 'CONVERTED'],
[r.get('reason') for r in report['rows']])
self.assertTrue(report['rows'][1]['conversion_reused'])
self.assertEqual(report['unique_operations_executed'], 1)
self.assertEqual(report['rows'][0]['outputs'][0]['role'], 'wdl')
self.assertEqual(report['rows'][0]['outputs'][0]['sha256'], ref(expected)['sha256'])
self.assertFalse(report['rows'][0]['runtime_verified'])
request['jobs'][0]['options'] = {}
request['jobs'][1]['options']['native_profile'] = 'unqualified-policy'
rejected = batch.plan_batch(request, base_directory=ROOT)
self.assertEqual([r['status'] for r in rejected['rows']], ['HELD', 'HELD'])
request['jobs'][0]['options'] = {'native_profile': assessment['policy']}
request['contracts']['wdl']['provenance'] = [ref(evidence)]
self.assertEqual(batch.plan_batch(request, base_directory=ROOT)['rows'][0]['status'], 'HELD')
preserved = {'kind': 'map-conversion-batch-v1', 'payloads': {'source': source_ref, 'native': source_ref},
'contracts': {}, 'jobs': [{'id': 'preserve', 'kind': 'wdl', 'source': 'source', 'native': 'native'}]}
row = batch.convert_batch(preserved, directory / 'preserved', base_directory=ROOT)['rows'][0]
self.assertEqual(row['status'], 'REUSED')
self.assertEqual(row['outputs'][0]['sha256'], source_ref['sha256'])
if __name__ == '__main__':
unittest.main()