Files
cbb-refresh-verify-795/tests/test_late_release_continuation.py
T

29 lines
1.5 KiB
Python

import json
from dataclasses import asdict
from pathlib import Path
import pytest
from cbb_refresh_verify.verify_runner import VerifyRequest,VerifyResult,run_batch
@pytest.mark.parametrize('released',[True,False])
def test_batch_rechecks_owned_failure_before_skipping_next_item(tmp_path,monkeypatch,released):
from cbb_refresh_verify import library_lock,session_record
library=tmp_path/'lib.lmc';library.touch()
root=tmp_path/'failure';root.mkdir()
session_record.write_session_record(root/'session.json',dict(operation_id='test',library=str(library),block='A'))
outcome=VerifyResult('FAIL',stderr='original failure',safe_to_continue=False,
evidence_path=root/'result.json',session_record_path=root/'session.json')
calls=[]
monkeypatch.setattr(session_record,'inspect_session_record',lambda *a,**k:dict(status='UNCONFIRMED'))
def proof(*a,**k):
if not released:raise library_lock.LibraryBusy('shared database still occupied')
return dict(status='RELEASE_CONFIRMED',library=str(library),data_recovery_confirmed=False)
monkeypatch.setattr(library_lock,'release_retained_library',proof)
def verify(req):
calls.append(req.block_name)
return outcome if req.block_name=='A' else VerifyResult('PASS')
results=run_batch([VerifyRequest(library,n,tmp_path/'evidence') for n in ('A','B')],verifier=verify)
assert results[0].status=='FAIL' and results[0].stderr=='original failure'
assert results[0].safe_to_continue is released
assert calls==(['A','B'] if released else ['A'])