"""Gated end-to-end smoke test for the real MoveNet ONNX model. Skipped unless the model is bundled AND onnxruntime is installed, so the default CI/dev suite (no model, no onnxruntime) stays green. On a build/pilot machine that ran ``python -m edge.tools.fetch_movenet``, this exercises the full adapter path: frame -> onnxruntime inference -> COCO-17 remap -> list[Person]. """ import os import numpy as np import pytest MODEL = os.path.join(os.path.dirname(__file__), "..", "..", "models", "movenet_lightning.onnx") @pytest.mark.skipif(not os.path.exists(MODEL), reason="MoveNet model not bundled") def test_real_movenet_runs(): pytest.importorskip("onnxruntime") from edge.adapters.movenet_pose import MoveNetPoseAdapter adapter = MoveNetPoseAdapter(MODEL) persons = adapter.infer(np.full((480, 640, 3), 128, np.uint8)) # Runs end-to-end; a flat gray frame may yield 0 persons — the contract is # only that it returns a list and, when non-empty, each Person has 17 keypoints. assert isinstance(persons, list) for person in persons: assert len(person.keypoints) == 17 @pytest.mark.skipif(not os.path.exists(MODEL), reason="MoveNet model not bundled") def test_model_signature_is_what_the_adapter_feeds_and_reads(): """모델을 갈아끼웠을 때 조용히 틀리는 경우를 막는다. 레이아웃이 다른 변환본(NCHW·float32·[1,17,3])도 onnxruntime 에는 그냥 로드된다. 그러면 어댑터는 예외 없이 돌면서 엉뚱한 좌표를 내놓고, 낙상 판정은 "동작하는데 안 맞는" 상태가 된다. 파일이 바뀌었는지가 아니라 **계약이 맞는지**를 본다. """ ort = pytest.importorskip("onnxruntime") session = ort.InferenceSession(MODEL, providers=["CPUExecutionProvider"]) inp = session.get_inputs()[0] assert inp.shape == [1, 192, 192, 3], f"어댑터는 192x192 NHWC 를 넣는다: {inp.shape}" assert inp.type == "tensor(int32)", f"어댑터는 int32 로 넣는다: {inp.type}" out = session.get_outputs()[0] assert out.shape == [1, 1, 17, 3], f"어댑터는 [1,1,17,3] (y,x,score) 를 읽는다: {out.shape}"