19 lines
1.6 KiB
Python
19 lines
1.6 KiB
Python
from pathlib import Path
|
|
import hashlib, json, sys
|
|
root = Path(__file__).resolve().parent
|
|
bundle = Path(json.loads((root/'extraction-check.json').read_text(encoding='utf-8'))['bundle'])
|
|
before = bundle/'examples/release1'
|
|
after = root/'working/saved'
|
|
expected = {p.relative_to(before).as_posix():p.read_bytes() for p in before.rglob('*') if p.is_file()}
|
|
name='oa/activities/activity_oa_restore_work.arcadia'
|
|
needle=b'oa_activity oa_assess "Assess pressure alarm" id "61f7bbfb-74a4-5540-9182-2583dfb27a49"'
|
|
assert expected[name].count(needle)==1
|
|
expected[name]=expected[name].replace(needle,needle.replace(b'"Assess pressure alarm"',b'"Assess pressure alarm QA LEFT XYRIGHT"'))
|
|
expected['qa-saved.arcadia']=expected.pop('project.arcadia')
|
|
actual={p.relative_to(after).as_posix():p.read_bytes() for p in after.rglob('*') if p.is_file()}
|
|
diff=[p for p in sorted(set(expected)|set(actual)) if expected.get(p)!=actual.get(p)]
|
|
report={'status':'PASS' if not diff else 'FAIL', 'files':len(actual), 'source_files':sum(p.endswith('.arcadia') for p in actual), 'oracle':'Complete pristine37-file project with entry relocated to qa-saved.arcadia and exactlyone declared Activity-name literal; seven non-source companions separately copied before SaveAs,30 sourcefiles written by application.', 'differences':diff, 'sha256':{p:hashlib.sha256(v).hexdigest() for p,v in actual.items()}}
|
|
with (root/('native-source-destination-'+sys.argv[1]+'.json')).open('x',encoding='utf-8') as f: json.dump(report,f,indent=2)
|
|
print(json.dumps({k:v for k,v in report.items() if k!='sha256'},indent=2))
|
|
assert not diff, diff
|