Add machine-aware maximum product length
This commit is contained in:
@@ -9,6 +9,7 @@ from roll_calculation import (
|
||||
_canonical_name,
|
||||
article_production_site,
|
||||
calculate_material_weight,
|
||||
calculate_material_length_for_weight,
|
||||
calculate_product_length,
|
||||
calculate_roll,
|
||||
get_article,
|
||||
@@ -196,6 +197,41 @@ class RollCalculationTests(unittest.TestCase):
|
||||
self.assertAlmostEqual(result["material_weight_kg"], 1455.0239028)
|
||||
self.assertNotIn("core_diameter_mm", result["inputs"])
|
||||
|
||||
def test_material_length_for_weight_is_material_only_and_round_trips(self):
|
||||
inverse = calculate_material_length_for_weight(
|
||||
target_material_weight_kg=700,
|
||||
width_m=6,
|
||||
area_weight_g_m2=495.395833,
|
||||
)
|
||||
|
||||
self.assertEqual(inverse["status"], "success")
|
||||
self.assertEqual(inverse["weight_scope"], "material_only")
|
||||
self.assertNotIn("core_diameter_mm", inverse["inputs"])
|
||||
round_trip = calculate_material_weight(
|
||||
roll_length_m=inverse["material_length_m"],
|
||||
width_m=6,
|
||||
area_weight_g_m2=495.395833,
|
||||
)
|
||||
self.assertAlmostEqual(round_trip["material_weight_kg"], 700)
|
||||
|
||||
def test_material_length_for_weight_rejects_non_positive_inputs(self):
|
||||
for changes in (
|
||||
{"target_material_weight_kg": 0},
|
||||
{"width_m": 0},
|
||||
{"area_weight_g_m2": 0},
|
||||
):
|
||||
with self.subTest(changes=changes):
|
||||
values = {
|
||||
"target_material_weight_kg": 700,
|
||||
"width_m": 6,
|
||||
"area_weight_g_m2": 495,
|
||||
}
|
||||
values.update(changes)
|
||||
self.assertEqual(
|
||||
calculate_material_length_for_weight(**values)["status"],
|
||||
"invalid_parameter",
|
||||
)
|
||||
|
||||
def test_roll_diameter_still_rejects_a_zero_core_diameter(self):
|
||||
result = calculate_roll(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user