from fastapi.testclient import TestClient from main import app client = TestClient(app) def test_bread_proportions(): """Basic test of the /calculate endpoint.""" response = client.post( "/calculate", json = { "flour": 500, "hydration": 63, "sourdough_hydration": 100, "salt_percent": 1.6 } ) assert response.status_code == 200 data = response.json() assert "flour" in data assert "water" in data assert "sourdough" in data assert "salt" in data def test_bread_proportions_values(): """Test of the calculated values.""" response = client.post( "/calculate", json={ "flour": 1000, "hydration": 62, "sourdough_hydration": 50, "sourdough_percent": 20 } ) data = response.json() assert data["flour"] == 900.0 assert data["water"] == 520.0 assert data["sourdough"] == 200.0 assert data["salt"] == 16.0