31 lines
1.5 KiB
Python
31 lines
1.5 KiB
Python
from threading import Event
|
|
|
|
import pytest
|
|
|
|
from cbb_refresh_verify.operation_queue import BatchTaskContext,TaskHandoff,hold_native_handoff
|
|
from cbb_refresh_verify.ui.residual_release_dialog import ResidualReleaseDialog
|
|
|
|
|
|
def test_pure_residual_inspection_remains_available_during_native_finalizer(qtbot,tmp_path,monkeypatch):
|
|
library=tmp_path/'lib.lmc';library.touch()
|
|
context=BatchTaskContext(str(library),native_policy='external')
|
|
entered,finish=Event(),Event();reads=[]
|
|
def finalize():
|
|
try:hold_native_handoff(None,tmp_path/'session.json')
|
|
except TaskHandoff:entered.set();assert finish.wait(5)
|
|
monkeypatch.setattr('cbb_refresh_verify.library_lock.inspect_residual_sessions',lambda path:
|
|
reads.append(path) or dict(library=str(library),sessions=[],previous_records=[]))
|
|
monkeypatch.setattr('cbb_refresh_verify.session_record.discover_sessions',lambda *a,**kw:[])
|
|
monkeypatch.setattr('cbb_refresh_verify.session_record.retained_session_states',lambda *a:[])
|
|
dialog=None
|
|
try:
|
|
with pytest.raises(TaskHandoff):context.run(finalize)
|
|
assert entered.is_set()
|
|
dialog=ResidualReleaseDialog(library,tmp_path/'evidence');qtbot.addWidget(dialog)
|
|
qtbot.waitUntil(lambda:not dialog.busy,timeout=3000)
|
|
assert reads==[library] and dialog.plan is not None,dialog.message.text()
|
|
assert dialog.library==library and dialog.confirm_button.isEnabled()
|
|
finally:
|
|
finish.set();context.close(timeout_seconds=2)
|
|
if dialog is not None:dialog.close()
|