Pre-publication review draft
日常訳NICHIJOYAKU日本語 ↗

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

software/tests/test_repair_review.py57 linesDownload this file ↓

This is the same source included in the download. Each line number is a link you can save or share.

File verification detailsSHA-256 0d8e8607cae2810107b8c34b461c4c5272caea135f52d96c636844ab9c48983f
1import pytest2from src.output.alignment import digest3from src.output.repair_review import merge_repairs456def fixtures():7    review={'records':{'b:1:2':{'decision':'mixed','mapped_targets':['b:1:1']}}}8    packets=[{'target':'b:1:1','candidates':[{'source':'b:1:2','text':'partial'}],'source_spans':[], 'held_sources':['b:1:2']}]9    decisions=[{'target':'b:1:1','text':'complete','selected_sources':[],'reason':'Restore missing clause','boundary_issue':''}]10    checks=[{'target':'b:1:1','status':'pass','text_sha256':digest('complete'),'reviewer':'editor'}]11    return review,packets,decisions,checks121314def test_import_preserves_raw_ambiguity_and_requires_exact_verified_text():15    r,p,d,c=fixtures();result=merge_repairs(r,p,d,c,'evidence')16    assert r['records']['b:1:2']['decision']=='mixed'17    assert result['records']['b:1:2']['decision']=='mapped'18    assert result['records']['b:1:2']['pre_repair_review']['decision']=='mixed'19    assert result['target_repairs']['b:1:1']['text']=='complete'20    d[0]['text']='different'21    with pytest.raises(ValueError,match='passing verification'):merge_repairs(r,p,d,c,'evidence')222324def test_selection_and_boundary_review():25    r,p,d,c=fixtures();d[0].update(text='partial',selected_sources=['b:1:2'],boundary_issue='boundary question');c[0]['text_sha256']=digest('partial')26    with pytest.raises(ValueError,match='Unresolved source boundary'):merge_repairs(r,p,d,c,'evidence')27    c[0]['boundary_resolution']='Checked against mapped word spans'28    assert merge_repairs(r,p,d,c,'evidence')['target_repairs']['b:1:1']['selected_sources']==['b:1:2']29    for chosen in [['b:1:3'],['b:1:2','b:1:2']]:30        d[0]['selected_sources']=chosen31        with pytest.raises(ValueError,match='does not match'):merge_repairs(r,p,d,c,'evidence')323334def test_reject_partial_duplicate_or_changed_inputs():35    r,p,d,c=fixtures()36    with pytest.raises(ValueError,match='Duplicate review'):merge_repairs(r,p+p,d,c,'evidence')37    with pytest.raises(ValueError,match='Incomplete'):merge_repairs(r,p,d,[],'evidence')38    r['records']['b:1:2']['mapped_targets']=['b:1:3']39    with 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):43    import json44    import hashlib45    from src.output.repair_review import import_bundle46    r,p,d,c=fixtures();r['usage']={'earlier':'round'}47    rp=tmp_path/'before.json';rp.write_text(json.dumps(r));bp=tmp_path/'bundle.json';out=tmp_path/'after.json'48    bundle={'input_review_sha256':hashlib.sha256(rp.read_bytes()).hexdigest(),'packets':p,'decisions':d,'verification':c,'source_files':{},'usage':{'transport':'claude -p'}}49    bp.write_text(json.dumps(bundle))50    assert import_bundle(rp,bp,out)==151    result=json.loads(out.read_text());assert result['usage']['repair_round']['transport']=='claude -p'52    assert result['target_repairs']['b:1:1']['evidence_sha256']==hashlib.sha256(bp.read_bytes()).hexdigest()53    for target in [rp,bp]:54        with pytest.raises(ValueError,match='overwrite its evidence'):import_bundle(rp,bp,target)55    rp.write_text('{}')56    with pytest.raises(ValueError,match='different input review'):import_bundle(rp,bp,out)57