24 lines
916 B
Python
24 lines
916 B
Python
import subprocess
|
|
import pytest
|
|
|
|
|
|
def test_wmi_timeout_is_unknown_not_idle(monkeypatch):
|
|
from cbb_refresh_verify.owner_probe import query_owners
|
|
def hang(command, **kw):
|
|
assert 0 < kw['timeout'] <= 10
|
|
raise subprocess.TimeoutExpired(command, kw['timeout'])
|
|
monkeypatch.setattr(subprocess, 'run', hang)
|
|
with pytest.raises(RuntimeError, match='OWNER_QUERY_TIMEOUT'):
|
|
query_owners(['ExpeditionPCB.exe'])
|
|
|
|
|
|
def test_malformed_wmi_response_is_not_empty_owner_list(monkeypatch):
|
|
from cbb_refresh_verify.owner_probe import query_owners
|
|
from pathlib import Path
|
|
def run(command, **kw):
|
|
Path(command[-1]).with_name('result.json').write_text('{}')
|
|
return subprocess.CompletedProcess(command, 0)
|
|
monkeypatch.setattr(subprocess, 'run', run)
|
|
with pytest.raises(RuntimeError, match='OWNER_QUERY_UNCONFIRMED'):
|
|
query_owners(['ExpeditionPCB.exe'])
|