feat(right_arm): endpoint /snapshot/{front,wrist}
This commit is contained in:
1 parent
dd2053cc47
commit
22e13435b1
2 files changed
+52
No files matched your search
@@ -60,3 +60,36 @@ def test_activate_sets_robot_active_g1_and_side_right():
|
||||
body = r.json()
|
||||
assert body["robot_active"] == "g1"
|
||||
assert body["side"] == "right"
|
||||
|
||||
|
||||
def test_snapshot_front_returns_jpeg():
|
||||
fake_jpeg = b"\xff\xd8\xff" + b"\x00" * 100 # magic JPEG bytes
|
||||
with patch("presa_mano.api.right_arm_routes._deps.front_camera") as factory:
|
||||
cam = MagicMock()
|
||||
cam.rgb_jpeg.return_value = fake_jpeg
|
||||
factory.return_value = cam
|
||||
r = client.get("/api/right_arm/snapshot/front")
|
||||
assert r.status_code == 200
|
||||
assert r.headers["content-type"].startswith("image/jpeg")
|
||||
assert r.content == fake_jpeg
|
||||
|
||||
|
||||
def test_snapshot_wrist_returns_jpeg():
|
||||
fake_jpeg = b"\xff\xd8\xff" + b"\x00" * 50
|
||||
with patch("presa_mano.api.right_arm_routes._deps.nuwa") as factory:
|
||||
cam = MagicMock()
|
||||
cam.rgb_jpeg.return_value = fake_jpeg
|
||||
factory.return_value = cam
|
||||
r = client.get("/api/right_arm/snapshot/wrist")
|
||||
assert r.status_code == 200
|
||||
assert r.headers["content-type"].startswith("image/jpeg")
|
||||
assert r.content == fake_jpeg
|
||||
|
||||
|
||||
def test_snapshot_front_502_on_failure():
|
||||
with patch("presa_mano.api.right_arm_routes._deps.front_camera") as factory:
|
||||
cam = MagicMock()
|
||||
cam.rgb_jpeg.side_effect = RuntimeError("connection refused")
|
||||
factory.return_value = cam
|
||||
r = client.get("/api/right_arm/snapshot/front")
|
||||
assert r.status_code == 502
|
||||
Reference in new issue
Block a user