OPEN SOURCE
software/tests/test_repair_review.py
Read on this site and download the files you need.
Nichijoyaku was created using AI. A complete review by human biblical-language and biblical-studies specialists has not been established. Read alongside established translations and original-language resources.
← Back to the open-source guide
1import pytest2from src.output.alignment import digest3from src.output.repair_review import merge_repairs456def fixtures():7review={'records':{'b:1:2':{'decision':'mixed','mapped_targets':['b:1:1']}}}8packets=[{'target':'b:1:1','candidates':[{'source':'b:1:2','text':'partial'}],'source_spans':[], 'held_sources':['b:1:2']}]9decisions=[{'target':'b:1:1','text':'complete','selected_sources':[],'reason':'Restore missing clause','boundary_issue':''}]10checks=[{'target':'b:1:1','status':'pass','text_sha256':digest('complete'),'reviewer':'editor'}]11return review,packets,decisions,checks121314def test_import_preserves_raw_ambiguity_and_requires_exact_verified_text():15r,p,d,c=fixtures();result=merge_repairs(r,p,d,c,'evidence')16assert r['records']['b:1:2']['decision']=='mixed'17assert result['records']['b:1:2']['decision']=='mapped'18assert result['records']['b:1:2']['pre_repair_review']['decision']=='mixed'19assert result['target_repairs']['b:1:1']['text']=='complete'20d[0]['text']='different'21with pytest.raises(ValueError,match='passing verification'):merge_repairs(r,p,d,c,'evidence')222324def test_selection_and_boundary_review():25r,p,d,c=fixtures();d[0].update(text='partial',selected_sources=['b:1:2'],boundary_issue='boundary question');c[0]['text_sha256']=digest('partial')26with pytest.raises(ValueError,match='Unresolved source boundary'):merge_repairs(r,p,d,c,'evidence')27c[0]['boundary_resolution']='Checked against mapped word spans'28assert merge_repairs(r,p,d,c,'evidence')['target_repairs']['b:1:1']['selected_sources']==['b:1:2']29for chosen in [['b:1:3'],['b:1:2','b:1:2']]:30d[0]['selected_sources']=chosen31with pytest.raises(ValueError,match='does not match'):merge_repairs(r,p,d,c,'evidence')323334def test_reject_partial_duplicate_or_changed_inputs():35r,p,d,c=fixtures()36with pytest.raises(ValueError,match='Duplicate review'):merge_repairs(r,p+p,d,c,'evidence')37with pytest.raises(ValueError,match='Incomplete'):merge_repairs(r,p,d,[],'evidence')38r['records']['b:1:2']['mapped_targets']=['b:1:3']39with pytest.raises(ValueError,match='Held record mapping changed'):merge_repairs(r,p,d,c,'evidence')404142def test_evidence_bundle_is_bound_to_original_review(tmp_path):43import json44import hashlib45from src.output.repair_review import import_bundle46r,p,d,c=fixtures();r['usage']={'earlier':'round'}47rp=tmp_path/'before.json';rp.write_text(json.dumps(r));bp=tmp_path/'bundle.json';out=tmp_path/'after.json'48bundle={'input_review_sha256':hashlib.sha256(rp.read_bytes()).hexdigest(),'packets':p,'decisions':d,'verification':c,'source_files':{},'usage':{'transport':'claude -p'}}49bp.write_text(json.dumps(bundle))50assert import_bundle(rp,bp,out)==151result=json.loads(out.read_text());assert result['usage']['repair_round']['transport']=='claude -p'52assert result['target_repairs']['b:1:1']['evidence_sha256']==hashlib.sha256(bp.read_bytes()).hexdigest()53for target in [rp,bp]:54with pytest.raises(ValueError,match='overwrite its evidence'):import_bundle(rp,bp,target)55rp.write_text('{}')56with pytest.raises(ValueError,match='different input review'):import_bundle(rp,bp,out)57