fix: cancel orphaned PCB before its license completes
This commit is contained in:
1 parent
e4fc37a291
commit
becaf2e8e4
2 files changed
+29
-9
No files matched your search
@@ -179,7 +179,7 @@ def test_cancelled_prewrite_can_dismiss_exact_late_load_failure(qtbot, tmp_path,
|
||||
assert (root/'result.json').read_bytes() == original
|
||||
|
||||
|
||||
@pytest.mark.parametrize('obstacle', [None, 'tip', 'slow_tip', 'cancelled_tip', 'previously_dismissed_tip',
|
||||
@pytest.mark.parametrize('obstacle', [None, 'tip', 'slow_tip', 'cancelled_tip', 'previously_dismissed_tip', 'license',
|
||||
'read_write', 'unknown_prompt', 'save',
|
||||
'uncertain_phase', 'live_supervisor', 'live_worker',
|
||||
'wrong_pcb', 'possible_write', 'loaded', 'unproved_loaded'])
|
||||
@@ -249,10 +249,11 @@ def test_restarted_verify_closes_exact_prewrite_orphan(tmp_path, monkeypatch, ob
|
||||
monkeypatch.setattr(residual_sessions, '_recorded_process_exited',
|
||||
lambda identity: obstacle != 'live_supervisor' and identity == supervisor)
|
||||
|
||||
if obstacle in ('tip', 'slow_tip', 'cancelled_tip', 'previously_dismissed_tip', 'read_write', 'unknown_prompt'):
|
||||
frame = windows[0]
|
||||
if obstacle in ('tip', 'slow_tip', 'cancelled_tip', 'previously_dismissed_tip', 'license', 'read_write', 'unknown_prompt'):
|
||||
frame = windows.pop() if obstacle == 'license' else windows[0]
|
||||
frame['enabled'] = False
|
||||
windows.append(dict(hwnd=200, title='Tip of the Day' if obstacle.endswith('tip') else 'Expedition PCB',
|
||||
title = {'license': ''}.get(obstacle, 'Tip of the Day' if obstacle.endswith('tip') else 'Expedition PCB')
|
||||
windows.append(dict(hwnd=200, title=title,
|
||||
desktop=job['desktop'], children=[], enabled=True, **{'class': '#32770'}))
|
||||
|
||||
def post(window, hwnd, pid, message):
|
||||
@@ -262,6 +263,8 @@ def test_restarted_verify_closes_exact_prewrite_orphan(tmp_path, monkeypatch, ob
|
||||
if hwnd == 201:
|
||||
windows.pop()
|
||||
frame['enabled'] = obstacle != 'slow_tip'
|
||||
if obstacle == 'license':
|
||||
state['native_alive'] = False
|
||||
else:
|
||||
state['native_alive'] = False
|
||||
|
||||
@@ -272,7 +275,18 @@ def test_restarted_verify_closes_exact_prewrite_orphan(tmp_path, monkeypatch, ob
|
||||
monkeypatch.setattr(residual_sessions, '_dismiss_startup_tip', dismiss_tip)
|
||||
monkeypatch.setattr(residual_sessions, '_post_window_message', post)
|
||||
monkeypatch.setattr(residual_sessions, '_window_desktop', lambda *_: nullcontext())
|
||||
monkeypatch.setattr(failed_session, '_startup_snapshot', lambda *_: 'exact shutdown prompt')
|
||||
if obstacle == 'license':
|
||||
from cbb_refresh_verify.dialog_models import ControlSnapshot, DialogPhase, WindowSnapshot
|
||||
license_prompt = WindowSnapshot(200, 12, 'ExpeditionPCB.exe', 'pcb', '#32770', '',
|
||||
DialogPhase.PCB_STARTING, (
|
||||
ControlSnapshot(210, 5225, 'Button', 'Select the desired product license', enabled=True),
|
||||
ControlSnapshot(211, 1522, 'GXWND', ''),
|
||||
ControlSnapshot(212, 1, 'Button', 'OK', enabled=True),
|
||||
ControlSnapshot(201, 2, 'Button', 'Cancel', enabled=True),
|
||||
))
|
||||
monkeypatch.setattr(failed_session, '_startup_snapshot', lambda *_: license_prompt)
|
||||
else:
|
||||
monkeypatch.setattr(failed_session, '_startup_snapshot', lambda *_: 'exact shutdown prompt')
|
||||
monkeypatch.setattr(failed_session, '_tip_target', lambda _: SimpleNamespace(handle=201))
|
||||
monkeypatch.setattr(failed_session, '_cancel_target', lambda _: ('read_write_access',
|
||||
SimpleNamespace(handle=201)) if obstacle == 'read_write' else None)
|
||||
@@ -289,9 +303,9 @@ def test_restarted_verify_closes_exact_prewrite_orphan(tmp_path, monkeypatch, ob
|
||||
assert residual_sessions.finish_owned_idle_session(path)
|
||||
assert state['posts'] == [(201, 12, 245), (100, 12, 16)]
|
||||
return
|
||||
assert recovered is (obstacle in (None, 'tip', 'cancelled_tip', 'read_write', 'loaded'))
|
||||
expected_posts = [(201, 12, 245)] if obstacle in ('tip', 'cancelled_tip', 'read_write') else []
|
||||
if recovered:
|
||||
assert recovered is (obstacle in (None, 'tip', 'cancelled_tip', 'license', 'read_write', 'loaded'))
|
||||
expected_posts = [(201, 12, 245)] if obstacle in ('tip', 'cancelled_tip', 'license', 'read_write') else []
|
||||
if recovered and obstacle != 'license':
|
||||
expected_posts.append((100, 12, 16))
|
||||
assert state['posts'] == expected_posts
|
||||
if recovered:
|
||||
|
||||
Reference in new issue
Block a user