Files
orisys-app/shared/tests/test_finger_chain_calibration.py
ykcheungab 48624dec99 让 Finger 视频分析使用所选的力标定文件。
分析链不再在打开前拒绝标定,而是把文件作为 cal_path 交给 FingerRuntime,并用操作者确认的设备编号核对文件里的 SN。标定传递测试与对话框 SN 校验通过。
2026-10-08 15:12:08 +08:00

56 lines
1.6 KiB
Python

"""A chosen Finger calibration is handed to the runtime, not refused before it opens."""
from __future__ import annotations
from orisys_app_shared.analysis.service import ChainSpec, _OpenChain
class _Runtime:
tactile = object()
capture = None
opened: dict = {}
@classmethod
def open(cls, **kwargs):
cls.opened = dict(kwargs)
return cls()
def read_source(self):
return False, None
def process_frame(self, frame):
return None
def test_a_finger_chain_passes_the_chosen_file_and_device(monkeypatch, tmp_path):
import orisys.finger as finger
monkeypatch.setattr(finger, "FingerRuntime", _Runtime)
_Runtime.opened = {}
calibration = tmp_path / "DD02-14.json"
calibration.write_text("{}", encoding="utf-8")
video = tmp_path / "clip.mp4"
video.write_bytes(b"")
spec = ChainSpec(
sensor_type="finger",
calibration=calibration,
device_id="DD02-14",
)
_OpenChain(spec, video, tmp_path).open()
assert _Runtime.opened["cal_path"] == str(calibration)
assert _Runtime.opened["device_id"] == "DD02-14"
assert _Runtime.opened["video"] == str(video)
def test_a_finger_chain_without_a_file_does_not_invent_one(monkeypatch, tmp_path):
import orisys.finger as finger
monkeypatch.setattr(finger, "FingerRuntime", _Runtime)
_Runtime.opened = {}
video = tmp_path / "clip.mp4"
video.write_bytes(b"")
spec = ChainSpec(sensor_type="finger")
_OpenChain(spec, video, tmp_path).open()
assert "cal_path" not in _Runtime.opened
assert "device_id" not in _Runtime.opened