fix: close owner probe cleanly when its request disappears
This commit is contained in:
1 parent
f4f5e939eb
commit
3223889dc7
2 files changed
+39
-1
No files matched your search
@@ -90,3 +90,33 @@ def test_full_snapshot_helper_does_not_filter_unknown_descendants(tmp_path, monk
|
||||
assert len(queries) == 1 and 'WHERE' not in queries[0]
|
||||
row = json.loads(job.with_name('result.json').read_text('utf-8'))['owners'][0]
|
||||
assert row['name'] == 'custom-native-child.exe' and row['created'] == 'creation-time'
|
||||
|
||||
|
||||
@pytest.mark.parametrize('contents', [None, b'broken-json', b'[]', b'\xff'])
|
||||
def test_readonly_helper_quietly_rejects_unavailable_request(tmp_path, contents):
|
||||
from cbb_refresh_verify.application import main
|
||||
|
||||
request = tmp_path/'request.json'
|
||||
if contents is not None:
|
||||
request.write_bytes(contents)
|
||||
assert main(['--owner-probe', str(request)]) == 1
|
||||
assert not request.with_name('result.json').exists()
|
||||
|
||||
|
||||
def test_readonly_helper_quietly_exits_when_supervisor_removes_probe(tmp_path, monkeypatch):
|
||||
from cbb_refresh_verify.owner_probe import owner_probe_main
|
||||
from types import SimpleNamespace
|
||||
import win32com.client
|
||||
|
||||
probe = tmp_path/'probe'
|
||||
probe.mkdir()
|
||||
request = probe/'request.json'
|
||||
request.write_text('{"names":["ExpeditionPCB.exe"]}', encoding='utf-8')
|
||||
|
||||
def enumerate_then_clean(_):
|
||||
request.unlink()
|
||||
probe.rmdir()
|
||||
return []
|
||||
|
||||
monkeypatch.setattr(win32com.client, 'GetObject', lambda _: SimpleNamespace(ExecQuery=enumerate_then_clean))
|
||||
assert owner_probe_main(request) == 1
|
||||
Reference in new issue
Block a user