diff --git a/src/presa_mano/clients/sam21.py b/src/presa_mano/clients/sam21.py index f19e3af..f3388dd 100644 --- a/src/presa_mano/clients/sam21.py +++ b/src/presa_mano/clients/sam21.py @@ -63,7 +63,7 @@ class Sam21Client: try: with httpx.Client(timeout=self.timeout_s) as c: r = c.post(url, json=body) - except (httpx.ConnectError, httpx.TimeoutException, httpx.NetworkError) as e: + except httpx.RequestError as e: raise Sam21Unavailable(f"sam21 unreachable: {e}") from e # Try to parse the envelope even on non-2xx, because SAM21 always diff --git a/tests/test_sam21_client.py b/tests/test_sam21_client.py index 1ce411d..5a3d459 100644 --- a/tests/test_sam21_client.py +++ b/tests/test_sam21_client.py @@ -1,8 +1,7 @@ """Unit tests for Sam21Client.""" from __future__ import annotations -import json -from unittest.mock import MagicMock, patch +from unittest.mock import patch import httpx import numpy as np @@ -56,6 +55,10 @@ def test_segment_pointcloud_happy_path(): assert body["return_mask"] is False assert isinstance(body["rgb_png_base64"], str) and len(body["rgb_png_base64"]) > 0 assert isinstance(body["depth_png_base64"], str) and len(body["depth_png_base64"]) > 0 + assert body["intrinsics"] == { + "fx": 600.0, "fy": 600.0, "cx": 320.0, "cy": 240.0, + "width": 640, "height": 480, + } # Output is in meters: mm/1000. assert out.shape == (2, 3) assert out.dtype == np.float64