fix(sam21): broader httpx catch + tighter test assertions

Catch httpx.RequestError so DecodingError etc. trigger the bbox fallback
instead of propagating raw. Lock the intrinsics dict shape in the
happy-path test, drop unused imports.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Adriano Dal PastroandClaude Opus 4.7 committed 2026-05-11 14:42:18 +02:00
1 parent 75da9add84
commit 0bc1e02f11
2 files changed
+6 -3

No files matched your search

+5 -2
View File
@@ -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