29 lines
1008 B
Python
29 lines
1008 B
Python
from pathlib import Path
|
|
import sys
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
sys.path.insert(0, str(ROOT / "app"))
|
|
|
|
from routers import devices
|
|
from routers.qrcode import _build_qr_content, _render_qr_png_bytes
|
|
|
|
|
|
def test_pairing_qr_encodes_server_and_token():
|
|
content = _build_qr_content("cunkebao", "工作手机", "wss://wpsdk.quwanzhi.com/ws/device", pairing_token="pair-token")
|
|
assert "wpsdk.quwanzhi.com" in content
|
|
assert "pair-token" in content
|
|
assert _render_qr_png_bytes(content).startswith(b"\x89PNG")
|
|
|
|
|
|
def test_device_routes_expose_guarded_delete():
|
|
routes = {(route.path, tuple(sorted(route.methods or []))) for route in devices.router.routes}
|
|
assert ("/devices/{device_id}", ("DELETE",)) in routes
|
|
|
|
|
|
def test_device_page_exposes_bind_and_offline_delete_actions():
|
|
hub = (ROOT / "app" / "static" / "hub.html").read_text()
|
|
assert "openBindQRCode()" in hub
|
|
assert "扫码绑定" in hub
|
|
assert "deleteOfflineDevice" in hub
|
|
assert "扫描 ADB" in hub
|