fix: dismiss a late load-failure prompt after prewrite cancellation
This commit is contained in:
1 parent
3223889dc7
commit
48f38d1bdd
2 files changed
+95
-10
No files matched your search
@@ -139,3 +139,41 @@ def test_discovery_hides_only_completed_read_only_catalog(tmp_path, monkeypatch,
|
||||
|
||||
found = session_record.discover_sessions(tmp_path)
|
||||
assert bool(found) == (not hidden)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('proved', [True, False])
|
||||
def test_cancelled_prewrite_can_dismiss_exact_late_load_failure(qtbot, tmp_path, monkeypatch, proved):
|
||||
import json
|
||||
from contextlib import nullcontext
|
||||
from types import SimpleNamespace
|
||||
from test_owned_idle_cleanup import owned_fixture
|
||||
from cbb_refresh_verify import failed_session, residual_sessions
|
||||
|
||||
root, job, result, windows, state = owned_fixture(tmp_path, monkeypatch)
|
||||
result.update(status='CANCELLED', error_category='TASK_HANDOFF', write_outcome=None)
|
||||
(root/'result.json').write_text(json.dumps(result), encoding='utf-8')
|
||||
frame = windows[0]
|
||||
frame['documents'] = [99]
|
||||
windows.append(dict(hwnd=200, title='Expedition PCB', desktop=job['desktop'], children=[],
|
||||
enabled=True, **{'class': '#32770'}))
|
||||
baseline = {'started_ns': 123}
|
||||
monkeypatch.setattr(failed_session, 'cancelled_prewrite_startup', lambda *a: baseline if proved else None)
|
||||
monkeypatch.setattr(residual_sessions, '_window_desktop', lambda *a, **kw: nullcontext())
|
||||
monkeypatch.setattr(failed_session, '_startup_snapshot', lambda *a: 'exact load failure')
|
||||
monkeypatch.setattr(failed_session, '_cancel_target',
|
||||
lambda _: ('database_load_log', SimpleNamespace(handle=201)))
|
||||
def post(window, hwnd, pid, message):
|
||||
state['posts'].append((hwnd, pid, message))
|
||||
if hwnd == 201:
|
||||
windows.pop()
|
||||
frame['documents'].clear()
|
||||
else:
|
||||
state['native_alive'] = False
|
||||
ticks = [0.]
|
||||
monkeypatch.setattr(residual_sessions.time, 'monotonic', lambda: ticks[0])
|
||||
monkeypatch.setattr(residual_sessions.time, 'sleep', lambda delay: ticks.__setitem__(0, ticks[0]+delay))
|
||||
monkeypatch.setattr(residual_sessions, '_post_window_message', post)
|
||||
original = (root/'result.json').read_bytes()
|
||||
assert residual_sessions.finish_owned_idle_session(root/'session.json') is proved
|
||||
assert state['posts'] == ([(201, 12, 245), (100, 12, 16)] if proved else [])
|
||||
assert (root/'result.json').read_bytes() == original
|
||||
Reference in new issue
Block a user