Expose product length calculation through MCP
This commit is contained in:
@@ -8,12 +8,14 @@ import mcp_server
|
||||
from roll_calculation import (
|
||||
ArticleRepository,
|
||||
calculate_material_weight,
|
||||
calculate_product_length,
|
||||
calculate_roll,
|
||||
get_article,
|
||||
)
|
||||
from rollcalc_mcp_tools import (
|
||||
analyze_transport_capacity_result,
|
||||
calculate_material_weight_result,
|
||||
calculate_product_length_result,
|
||||
calculate_roll_diameter_result,
|
||||
get_article_result,
|
||||
search_articles_result,
|
||||
@@ -87,6 +89,23 @@ class McpAdapterTests(unittest.TestCase):
|
||||
self.assertEqual(result["weight_scope"], "material_only")
|
||||
self.assertAlmostEqual(result["material_weight_kg"], 1455.0239028)
|
||||
|
||||
def test_product_length_adapter_delegates_with_article_218500_values(self):
|
||||
arguments = {
|
||||
"target_roll_diameter_mm": 600.0,
|
||||
"core_diameter_mm": 140.0,
|
||||
"thickness_mm": 4.311611,
|
||||
"thickness_stddev_mm": 0.249999,
|
||||
"width_m": 6.0,
|
||||
"area_weight_g_m2": 495.395833,
|
||||
}
|
||||
|
||||
result = calculate_product_length_result(**arguments)
|
||||
|
||||
self.assertEqual(result, calculate_product_length(**arguments))
|
||||
self.assertAlmostEqual(
|
||||
result["calculation"]["average_product_length_m"], 62.0068774341
|
||||
)
|
||||
|
||||
def test_calculate_roll_diameter_delegates_for_normal_weighted_and_invalid_cases(self):
|
||||
for arguments in (
|
||||
{
|
||||
@@ -178,6 +197,7 @@ class McpAdapterTests(unittest.TestCase):
|
||||
"get_article",
|
||||
"search_articles",
|
||||
"calculate_material_weight",
|
||||
"calculate_product_length",
|
||||
"calculate_roll_diameter",
|
||||
"analyze_transport_capacity",
|
||||
],
|
||||
@@ -188,6 +208,7 @@ class McpAdapterTests(unittest.TestCase):
|
||||
tools = instance._tool_manager._tools
|
||||
search_tool = tools["search_articles"]
|
||||
material_weight_tool = tools["calculate_material_weight"]
|
||||
product_length_tool = tools["calculate_product_length"]
|
||||
roll_schema = tools["calculate_roll_diameter"].parameters
|
||||
transport_tool = tools["analyze_transport_capacity"]
|
||||
transport_schema = transport_tool.parameters
|
||||
@@ -202,6 +223,19 @@ class McpAdapterTests(unittest.TestCase):
|
||||
["roll_length_m", "width_m", "area_weight_g_m2"],
|
||||
)
|
||||
self.assertNotIn("core_diameter_mm", material_weight_schema["properties"])
|
||||
product_length_schema = product_length_tool.parameters
|
||||
self.assertEqual(
|
||||
product_length_schema["required"],
|
||||
[
|
||||
"target_roll_diameter_mm",
|
||||
"core_diameter_mm",
|
||||
"thickness_mm",
|
||||
],
|
||||
)
|
||||
self.assertEqual(
|
||||
product_length_schema["properties"]["target_roll_diameter_mm"]["type"],
|
||||
"number",
|
||||
)
|
||||
|
||||
self.assertNotIn("include_roll_weight", roll_schema["properties"])
|
||||
preset_schema = transport_schema["properties"]["transport_preset"]
|
||||
@@ -294,6 +328,16 @@ class McpAdapterTests(unittest.TestCase):
|
||||
self.assertIn("do not infer or default one", roll_description)
|
||||
self.assertIn("call calculate_material_weight instead", roll_description)
|
||||
|
||||
product_length_description = product_length_tool.description
|
||||
for text in (
|
||||
"required product/roll length for a target outer roll diameter",
|
||||
"do not infer a missing core diameter, thickness, width, area weight, or article",
|
||||
"minimum, average, and maximum length ranges",
|
||||
"material-weight ranges",
|
||||
"use calculate_roll_diameter for the reverse direction",
|
||||
):
|
||||
self.assertIn(text, product_length_description)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user