test: scope the passive release assertion to its library
This commit is contained in:
1 parent
0c02ff6966
commit
d45a29503d
1 file changed
+19
-4
@@ -178,19 +178,34 @@ def test_residual_dialog_refresh_shows_runtime_blocker_without_releasing(qtbot,
|
||||
|
||||
def test_passive_handoff_reports_final_unconfirmed_state_without_proof(tmp_path, child, monkeypatch):
|
||||
from threading import Event
|
||||
from cbb_refresh_verify import library_lock as locks
|
||||
|
||||
path = record(tmp_path, [dict(role='worker', **sessions.process_identity(child.pid))])
|
||||
library = tmp_path/'lib.lmc'
|
||||
monkeypatch.setattr(sessions, '_retained_libraries', {})
|
||||
monkeypatch.setattr('cbb_refresh_verify.library_lock.release_retained_library',
|
||||
lambda *a, **kw: pytest.fail('startup observer released the library'))
|
||||
release = locks.release_retained_library
|
||||
unexpected = []
|
||||
|
||||
def check_release(target, *args, **kwargs):
|
||||
if Path(target) == library:
|
||||
unexpected.append(target)
|
||||
raise OSError('Passive observation attempted to release the library')
|
||||
return release(target, *args, **kwargs)
|
||||
|
||||
monkeypatch.setattr(locks, 'release_retained_library', check_release)
|
||||
terminal = Event()
|
||||
sessions.handoff_session(path, evidence_root=tmp_path, observe_only=True,
|
||||
progress=lambda value: terminal.set() if value['status'] == 'UNCONFIRMED' else None)
|
||||
thread = sessions._observers[str(path.absolute()).casefold()][0]
|
||||
child.terminate(); child.wait(5)
|
||||
assert terminal.wait(3)
|
||||
states = sessions.retained_session_states(tmp_path/'lib.lmc')
|
||||
thread.join(3)
|
||||
assert not thread.is_alive()
|
||||
assert not unexpected
|
||||
states = sessions.retained_session_states(library)
|
||||
assert len(states) == 1 and states[0]['status'] == 'UNCONFIRMED'
|
||||
assert states[0]['detail']
|
||||
assert not sessions.library_available(tmp_path/'lib.lmc')
|
||||
assert not sessions.library_available(library)
|
||||
|
||||
|
||||
def test_explicit_release_marks_discovered_history_without_an_in_memory_observer(tmp_path, monkeypatch):
|
||||
|
||||
Reference in new issue
Block a user