Files
cbb-refresh-verify-795/tests/test_packaging_status_bridge.py
T
阿白叔 11a2b2e46e Import CBB refresh verify r4 stability baseline
Preserve tested Verify source, authoritative READY checks, bounded bridge retries, diagnostics and failure-only reporting. Include 336-test suite and packaging assets; exclude live Mentor samples, field logs, backups and distributions.
2026-09-29 15:05:20 +08:00

78 lines
2.6 KiB
Python

from pathlib import Path
import json
import subprocess
from cbb_refresh_verify.status_bridge import default_bridge_path
def test_packaged_layout_contains_status_bridge_asset():
spec = Path("packaging/CbbRefreshVerify.spec").read_text(encoding="utf-8")
assert "tools/status_bridge/bin" in spec
assert Path("tools/status_bridge/bin/CbbStatusBridge32.exe").is_file()
def test_packaged_layout_contains_read_only_verify_probe_asset():
spec = Path("packaging/CbbRefreshVerify.spec").read_text(encoding="utf-8")
assert "VerifyProbe32.exe" in spec
assert Path("tools/status_bridge/bin/VerifyProbe32.exe").is_file()
def test_frozen_bridge_lookup_includes_internal_onedir_root():
text = Path("src/cbb_refresh_verify/status_bridge.py").read_text(encoding="utf-8")
assert "_MEIPASS" in text
def test_default_bridge_path_does_not_claim_ready_without_bridge(tmp_path, monkeypatch):
monkeypatch.setenv("CBB_STATUS_BRIDGE", str(tmp_path / "missing.exe"))
path = default_bridge_path()
assert not path.exists()
def test_main_window_default_worker_count_is_one():
text = Path("src/cbb_refresh_verify/ui/main_window.py").read_text(encoding="utf-8")
assert "setMaxThreadCount(1)" in text
def test_main_window_defaults_to_authoritative_bridge_status():
text = Path("src/cbb_refresh_verify/ui/main_window.py").read_text(encoding="utf-8")
assert "authoritative_status=True" in text
def test_spec_keeps_dynamic_main_window_import_in_frozen_package():
spec = Path("packaging/CbbRefreshVerify.spec").read_text(encoding="utf-8")
assert "cbb_refresh_verify.ui.main_window" in spec
def test_main_window_module_imports_without_optional_replacement_package():
import os
import subprocess
import sys
env = os.environ.copy()
env["PYTHONPATH"] = str(Path("src").resolve())
result = subprocess.run(
[sys.executable, "-c", "import cbb_refresh_verify.ui.main_window"],
env=env, capture_output=True, text=True, timeout=15,
)
assert result.returncode == 0, result.stderr
def test_compiled_bridge_json_codec_round_trips_unc_path():
bridge = Path('tools/status_bridge/bin/CbbStatusBridge32.exe').resolve()
request = {
'request_id': 'codec-1',
'lmc_file': r'\\192.168.0.252\eda\Mentor_lib\mentor_lib.lmc',
'block_name': 'CBB_TEST',
}
result = subprocess.run(
[str(bridge), '--codec-test'],
input=json.dumps(request, ensure_ascii=False) + '\n',
capture_output=True,
text=True,
encoding='utf-8',
timeout=10,
)
assert result.returncode == 0, result.stdout + result.stderr
assert json.loads(result.stdout) == request