Add machine-aware maximum product length
This commit is contained in:
@@ -139,6 +139,53 @@ class CalculationApiTests(unittest.TestCase):
|
||||
self.assertEqual(result["feasibility"], "feasible_with_warnings")
|
||||
self.assertEqual(result["warning_constraints"], ["roll_diameter_mm"])
|
||||
|
||||
def test_machine_maximum_length_endpoint_is_authenticated_and_structured(self):
|
||||
response = self.client.post(
|
||||
"/api/calculations/machine-max-product-length",
|
||||
json={
|
||||
"machine": "K7",
|
||||
"core_diameter_mm": 133,
|
||||
"thickness_mm": 4.311611,
|
||||
"thickness_stddev_mm": 0.249999,
|
||||
"product_width_m": 6,
|
||||
"area_weight_g_m2": 495.395833,
|
||||
},
|
||||
headers=self.headers,
|
||||
)
|
||||
result = response.get_json()
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(result["status"], "success")
|
||||
self.assertEqual(
|
||||
result["production_maximums"]["nominal_governing_constraints"],
|
||||
["roll_diameter_nominal"],
|
||||
)
|
||||
|
||||
def test_machine_maximum_length_endpoint_preserves_domain_outcomes(self):
|
||||
incompatible = self.client.post(
|
||||
"/api/calculations/machine-max-product-length",
|
||||
json={"machine": "K7", "core_diameter_mm": 194, "thickness_mm": 4},
|
||||
headers=self.headers,
|
||||
)
|
||||
missing = self.client.post(
|
||||
"/api/calculations/machine-max-product-length",
|
||||
json={"machine": "K7", "core_diameter_mm": 133, "thickness_mm": 4},
|
||||
headers=self.headers,
|
||||
)
|
||||
invalid = self.client.post(
|
||||
"/api/calculations/machine-max-product-length",
|
||||
json={"machine": "K7", "unexpected": 1},
|
||||
headers=self.headers,
|
||||
)
|
||||
missing_required = self.client.post(
|
||||
"/api/calculations/machine-max-product-length",
|
||||
json={"machine": "K7", "core_diameter_mm": 133},
|
||||
headers=self.headers,
|
||||
)
|
||||
self.assertEqual(incompatible.get_json()["status"], "incompatible")
|
||||
self.assertEqual(missing.get_json()["status"], "needs_clarification")
|
||||
self.assertEqual(invalid.get_json()["status"], "invalid_parameter")
|
||||
self.assertEqual(missing_required.get_json()["status"], "invalid_parameter")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user