"""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