fix: bind UI jobs and recovery actions to captured scope
This commit is contained in:
1 parent
601dd7b6b2
commit
cd7a5e0ca1
20 files changed
+1570
-297
No files matched your search
@@ -1,5 +1,5 @@
|
||||
"""Stale and repeated user actions around native queue admission."""
|
||||
from threading import Event
|
||||
from threading import Event, Thread
|
||||
from types import SimpleNamespace
|
||||
from pathlib import Path
|
||||
|
||||
@@ -12,6 +12,18 @@ from test_review326_queue_guidance import retain
|
||||
from test_ui_filters import load_window
|
||||
|
||||
|
||||
|
||||
def hold_native_queue(window):
|
||||
"""A live owner, rather than old retention metadata, keeps admission queued."""
|
||||
entered, release = Event(), Event()
|
||||
def action():
|
||||
entered.set()
|
||||
assert release.wait(10)
|
||||
worker = Thread(target=lambda:window.native_queue.run(action))
|
||||
worker.start()
|
||||
assert entered.wait(2)
|
||||
return release, worker
|
||||
|
||||
def test_verify_admission_hides_release_entry_before_action_finishes(qtbot, tmp_path, monkeypatch):
|
||||
window = load_window(qtbot, tmp_path, monkeypatch)
|
||||
window.show()
|
||||
@@ -81,6 +93,7 @@ def test_old_waiting_event_is_rechecked_against_current_release_state(qtbot, tmp
|
||||
def test_other_library_icdb_start_preserves_the_foreground_wait(qtbot, tmp_path, monkeypatch):
|
||||
window = load_window(qtbot, tmp_path, monkeypatch)
|
||||
window.show()
|
||||
queue_release, queue_worker = hold_native_queue(window)
|
||||
retain(monkeypatch, window.mentor_lmc_path)
|
||||
window._start(lambda: None, lambda _: None)
|
||||
try:
|
||||
@@ -90,6 +103,7 @@ def test_other_library_icdb_start_preserves_the_foreground_wait(qtbot, tmp_path,
|
||||
assert window.queue_release_button.isVisible()
|
||||
assert window._queue_wait_library == 'test.lmc'
|
||||
finally:
|
||||
queue_release.set(); queue_worker.join(2)
|
||||
sessions._retained_libraries.clear()
|
||||
window.native_queue.wake()
|
||||
qtbot.waitUntil(lambda: not window.busy)
|
||||
@@ -130,6 +144,7 @@ def test_repeated_click_and_close_reuse_one_panel_without_unlocking_the_task(qtb
|
||||
from cbb_refresh_verify import library_lock
|
||||
window = load_window(qtbot, tmp_path, monkeypatch)
|
||||
window.show()
|
||||
queue_release, queue_worker = hold_native_queue(window)
|
||||
retain(monkeypatch, window.mentor_lmc_path)
|
||||
monkeypatch.setattr(library_lock, 'inspect_residual_sessions',
|
||||
lambda library: dict(library=str(library), sessions=[]))
|
||||
@@ -150,6 +165,7 @@ def test_repeated_click_and_close_reuse_one_panel_without_unlocking_the_task(qtb
|
||||
reopened.close()
|
||||
assert window.busy
|
||||
finally:
|
||||
queue_release.set(); queue_worker.join(2)
|
||||
sessions._retained_libraries.clear()
|
||||
window.native_queue.wake()
|
||||
qtbot.waitUntil(lambda: not window.busy)
|
||||
@@ -159,6 +175,7 @@ def test_repeat_verify_then_stop_then_delayed_release_click_never_starts_work(qt
|
||||
calls = []
|
||||
window = load_window(qtbot, tmp_path, monkeypatch, verifier=lambda request: calls.append(request.block_name))
|
||||
window.show()
|
||||
queue_release, queue_worker = hold_native_queue(window)
|
||||
retain(monkeypatch, window.mentor_lmc_path)
|
||||
window.search_edit.setText('Beta')
|
||||
window.verify_all()
|
||||
@@ -167,15 +184,16 @@ def test_repeat_verify_then_stop_then_delayed_release_click_never_starts_work(qt
|
||||
for _ in range(5):
|
||||
qtbot.mouseClick(window.batch_button, Qt.LeftButton)
|
||||
window.verify_all()
|
||||
assert len(window.native_queue.pending) == 1
|
||||
assert len(window.native_queue.pending) == 2
|
||||
qtbot.mouseClick(window.stop_button, Qt.LeftButton)
|
||||
qtbot.waitUntil(lambda: not window.busy)
|
||||
for _ in range(5):
|
||||
window.check_library_release(queued=True)
|
||||
assert calls == []
|
||||
assert not window.native_queue.pending
|
||||
assert len(window.native_queue.pending) == 1
|
||||
assert getattr(window, 'release_dialog', None) is None
|
||||
finally:
|
||||
queue_release.set(); queue_worker.join(2)
|
||||
window.stop.set()
|
||||
sessions._retained_libraries.clear()
|
||||
window.native_queue.wake()
|
||||
@@ -186,11 +204,14 @@ def test_repeat_verify_then_stop_then_delayed_release_click_never_starts_work(qt
|
||||
def test_foreground_completion_and_background_cancel_keep_only_live_waits(qtbot, tmp_path, monkeypatch,
|
||||
foreground_finishes_first):
|
||||
window = load_window(qtbot, tmp_path, monkeypatch,
|
||||
verifier=lambda _: pytest.fail('A retained library must not start a native check'))
|
||||
verifier=lambda _: pytest.fail('An intentionally paused check must not execute'))
|
||||
window.show()
|
||||
queue_release, queue_worker = hold_native_queue(window)
|
||||
retain(monkeypatch, window.mentor_lmc_path)
|
||||
window._run(['Beta'], maintenance=True)
|
||||
window.icdb_task.pause()
|
||||
qtbot.waitUntil(lambda: window.queue_release_button.isVisible())
|
||||
queue_release.set(); queue_worker.join(2)
|
||||
window.mentor_lmc_path = Path('other.lmc')
|
||||
window.lmc_edit.setText('other.lmc')
|
||||
started, finish = Event(), Event()
|
||||
@@ -215,6 +236,7 @@ def test_foreground_completion_and_background_cancel_keep_only_live_waits(qtbot,
|
||||
if not foreground_finishes_first:
|
||||
assert window.busy
|
||||
finally:
|
||||
queue_release.set(); queue_worker.join(2)
|
||||
finish.set()
|
||||
window.icdb_task.cancel()
|
||||
sessions._retained_libraries.clear()
|
||||
|
||||
Reference in new issue
Block a user