192d4b590c
Route POST /measure/api/vision/grab (proxy verso il servizio camera), get_station_by_code, pulsante «Acquisisci dalla camera», grab() in vision_execute.js, campi camera_url e camera_source nell'admin stazioni, traduzioni it/en, extra_hosts host.docker.internal nel compose di sviluppo. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
25 lines
1.1 KiB
Python
25 lines
1.1 KiB
Python
"""Tests for the station-related helpers in api_client."""
|
|
from unittest.mock import patch
|
|
|
|
from services.api_client import APIClient
|
|
|
|
|
|
def test_get_station_recipes_calls_correct_endpoint():
|
|
client = APIClient()
|
|
with patch.object(client, "get") as mock_get:
|
|
mock_get.return_value = [{"id": 1, "code": "R1", "name": "R1", "active": True}]
|
|
result = client.get_station_recipes("ST-001")
|
|
# The helper must call the underlying .get() with the exact endpoint path.
|
|
called_args, called_kwargs = mock_get.call_args
|
|
assert called_args[0] == "/api/stations/by-code/ST-001/recipes"
|
|
assert result == [{"id": 1, "code": "R1", "name": "R1", "active": True}]
|
|
|
|
|
|
def test_get_station_by_code_calls_correct_endpoint():
|
|
client = APIClient()
|
|
with patch.object(client, "get") as mock_get:
|
|
mock_get.return_value = {"id": 1, "code": "ST-001", "camera_url": None}
|
|
result = client.get_station_by_code("ST-001")
|
|
assert mock_get.call_args[0][0] == "/api/stations/by-code/ST-001"
|
|
assert result["code"] == "ST-001"
|