65 lines
1.7 KiB
Python
65 lines
1.7 KiB
Python
import json
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from dx_productivity.bridge.probe_host import main, write_probe_marker
|
|
|
|
|
|
def test_probe_marker_is_versioned_json(tmp_path: Path) -> None:
|
|
output = tmp_path / "compatibility.json"
|
|
|
|
write_probe_marker(output, "named", {"selected_query": True})
|
|
|
|
assert output.read_text(encoding="utf-8") == (
|
|
'{"format_version":1,"route":"named","selected_query":true}\n'
|
|
)
|
|
|
|
|
|
def test_probe_cli_merges_capability_payload(tmp_path: Path) -> None:
|
|
output = tmp_path / "compatibility.json"
|
|
|
|
exit_code = main(
|
|
[
|
|
"--output",
|
|
str(output),
|
|
"--route",
|
|
"named",
|
|
"--payload-json",
|
|
'{"yield_method":"Scripting.DoEvents","retained_reference":true}',
|
|
]
|
|
)
|
|
|
|
assert exit_code == 0
|
|
assert json.loads(output.read_text(encoding="utf-8"))["yield_method"] == (
|
|
"Scripting.DoEvents"
|
|
)
|
|
|
|
|
|
def test_probe_cli_rejects_non_object_payload(tmp_path: Path) -> None:
|
|
with pytest.raises(ValueError, match="JSON object"):
|
|
main(
|
|
[
|
|
"--output",
|
|
str(tmp_path / "compatibility.json"),
|
|
"--route",
|
|
"named",
|
|
"--payload-json",
|
|
"[]",
|
|
]
|
|
)
|
|
|
|
|
|
def test_startup_probe_uses_packaged_executable_and_records_portable_path() -> None:
|
|
text = Path("integration/dxdesigner795/CompatibilityProbe.vbs").read_text(
|
|
encoding="ascii"
|
|
)
|
|
|
|
assert "DxDesignerTools.exe" in text
|
|
assert '"script_path_source"' in text
|
|
assert '"portable_root_valid"' in text
|
|
assert "DXTOOLS_HOME" not in text
|
|
assert "py -3.12" not in text
|
|
assert "D:\\NET_CHECK" not in text
|
|
assert text.isascii()
|