diff --git a/client/services/api_client.py b/client/services/api_client.py index de6e0ac..4d3604a 100644 --- a/client/services/api_client.py +++ b/client/services/api_client.py @@ -131,5 +131,11 @@ class APIClient: "detail": f"Errore di connessione al server: {str(e)}" } + # --- Domain helpers --- + + def get_station_recipes(self, station_code: str) -> dict[str, Any]: + """Return the list of active recipes assigned to the given station.""" + return self.get(f"/api/stations/by-code/{station_code}/recipes") + api_client = APIClient() diff --git a/client/tests/test_api_client_stations.py b/client/tests/test_api_client_stations.py new file mode 100644 index 0000000..1d9ae07 --- /dev/null +++ b/client/tests/test_api_client_stations.py @@ -0,0 +1,15 @@ +"""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}]