fix: acknowledge diagnostic prompt ownership before native close
This commit is contained in:
1 parent
de81bbf293
commit
4402486baa
5 files changed
+232
-16
No files matched your search
@@ -1,14 +1,25 @@
|
||||
import importlib
|
||||
import importlib.util
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def diagnostic():
|
||||
def diagnostic(monkeypatch):
|
||||
assert importlib.util.find_spec('cbb_refresh_verify.diagnostic_open') is not None, 'diagnostic open module is missing'
|
||||
return importlib.import_module('cbb_refresh_verify.diagnostic_open')
|
||||
module = importlib.import_module('cbb_refresh_verify.diagnostic_open')
|
||||
check = module.check_target_window
|
||||
def acknowledged(job, pid, *, emit, **kwargs):
|
||||
def parent(**event):
|
||||
emit(**event)
|
||||
if event['stage'] == 'diagnostic_close_requested':
|
||||
(Path(job['root'])/'diagnostic-close-ack.json').write_text(json.dumps(
|
||||
{key:value for key,value in event.items() if key != 'stage'}))
|
||||
return check(job, pid, emit=parent, **kwargs)
|
||||
monkeypatch.setattr(module, 'check_target_window', acknowledged)
|
||||
return module
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -17,8 +28,9 @@ def job(tmp_path):
|
||||
pcb = project / 'PCB/IP101GR.pcb'
|
||||
pcb.parent.mkdir(parents=True)
|
||||
pcb.write_bytes(b'pcb')
|
||||
(tmp_path/'evidence').mkdir()
|
||||
return {'project': str(project / 'IP101GR.prj'), 'pcb': str(pcb), 'root': str(tmp_path / 'evidence'),
|
||||
'desktop': 'CbbDiagnosticTest', 'timeout': .03}
|
||||
'desktop': 'CbbDiagnosticTest', 'operation_id': 'verify-fixture', 'timeout': .03}
|
||||
|
||||
|
||||
def write_logs(job, *, pid=42, foreign=False, success=True):
|
||||
|
||||
Reference in new issue
Block a user