Expose product length calculation through MCP

This commit is contained in:
2026-09-25 21:21:20 +02:00
parent 580e9caa5e
commit e6a7d4da72
10 changed files with 357 additions and 7 deletions
+32
View File
@@ -9,6 +9,7 @@ from roll_calculation import (
_canonical_name,
article_production_site,
calculate_material_weight,
calculate_product_length,
calculate_roll,
get_article,
modify_calculation,
@@ -212,6 +213,37 @@ class RollCalculationTests(unittest.TestCase):
item["field"] for item in result["invalid"]
])
def test_product_length_characterizes_article_218500_with_ranges_and_weight(self):
result = calculate_product_length(
target_roll_diameter_mm=600,
core_diameter_mm=140,
thickness_mm=4.311611,
thickness_stddev_mm=0.249999,
width_m=6.0,
area_weight_g_m2=495.395833,
)
self.assertEqual(result["status"], "success")
calculation = result["calculation"]
self.assertAlmostEqual(calculation["minimum_product_length_m"], 55.5634372661)
self.assertAlmostEqual(calculation["average_product_length_m"], 62.0068774341)
self.assertAlmostEqual(calculation["maximum_product_length_m"], 70.1407868061)
self.assertAlmostEqual(
calculation["material_weights_kg"]["average_kg"], 184.3076921892
)
def test_product_length_rejects_target_diameter_not_larger_than_core(self):
result = calculate_product_length(
target_roll_diameter_mm=140,
core_diameter_mm=140,
thickness_mm=4,
)
self.assertEqual(result["status"], "invalid_parameter")
self.assertEqual(
result["invalid"][0]["field"], "target_roll_diameter_mm"
)
def test_diameter_only_calculation_does_not_require_width(self):
result = self.calculate_fixture(
{