|
|
|
|
@ -1288,6 +1288,62 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
self.assertEqual("terminal-start", report["error_samples"][0]["end_terminal_uuid"])
|
|
|
|
|
self.assertIn("different", report["error_samples"][0]["error"])
|
|
|
|
|
|
|
|
|
|
def test_route_eplan_connections_counts_route_statuses_for_summary(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, routing_network, auto_routing = _reload_modules()
|
|
|
|
|
app = sys.modules["FreeCAD"]
|
|
|
|
|
doc = FakeDocument()
|
|
|
|
|
terminal_objects.ensure_root_group(doc, "project-1")
|
|
|
|
|
_terminal(doc, terminal_objects, "RouteStart", "route-start", app.Vector(0, 0, 0))
|
|
|
|
|
_terminal(doc, terminal_objects, "RouteEnd", "route-end", app.Vector(100, 0, 0))
|
|
|
|
|
_terminal(doc, terminal_objects, "CollisionStart", "collision-start", app.Vector(0, 100, 0))
|
|
|
|
|
_terminal(doc, terminal_objects, "CollisionEnd", "collision-end", app.Vector(100, 100, 0))
|
|
|
|
|
routing_network.create_route_carrier(
|
|
|
|
|
doc,
|
|
|
|
|
[app.Vector(0, 0, 20), app.Vector(100, 0, 20)],
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
kind="WireDuct",
|
|
|
|
|
)
|
|
|
|
|
routing_network.create_route_carrier(
|
|
|
|
|
doc,
|
|
|
|
|
[app.Vector(0, 100, 100), app.Vector(100, 100, 100)],
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
kind="WireDuct",
|
|
|
|
|
)
|
|
|
|
|
obstacle = doc.addObject("Part::Feature", "CollisionObstacle")
|
|
|
|
|
obstacle.Shape = FakeShape(FakeBoundBox(40, 60, 90, 110, 90, 110))
|
|
|
|
|
payload = {
|
|
|
|
|
"project_uuid": "project-1",
|
|
|
|
|
"wires": [
|
|
|
|
|
{
|
|
|
|
|
"wire_id": "wire-ok",
|
|
|
|
|
"start_terminal_uuid": "route-start",
|
|
|
|
|
"end_terminal_uuid": "route-end",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"wire_id": "wire-collision",
|
|
|
|
|
"start_terminal_uuid": "collision-start",
|
|
|
|
|
"end_terminal_uuid": "collision-end",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"wire_id": "wire-error",
|
|
|
|
|
"start_terminal_uuid": "route-start",
|
|
|
|
|
"end_terminal_uuid": "route-start",
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
report = auto_routing.route_eplan_connections_from_payload(doc, payload)
|
|
|
|
|
message = auto_routing.format_eplan_connection_route_report(report)
|
|
|
|
|
|
|
|
|
|
self.assertEqual(1, report["route_status_counts"]["Routed"])
|
|
|
|
|
self.assertEqual(1, report["route_status_counts"]["CollisionWarning"])
|
|
|
|
|
self.assertEqual(1, report["route_status_counts"]["Error"])
|
|
|
|
|
self.assertIn("结果状态", message)
|
|
|
|
|
self.assertIn("正常 1 条", message)
|
|
|
|
|
self.assertIn("碰撞告警 1 条", message)
|
|
|
|
|
self.assertIn("错误 1 条", message)
|
|
|
|
|
|
|
|
|
|
def test_route_eplan_connections_lane_index_is_per_terminal_pair(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, routing_network, auto_routing = _reload_modules()
|
|
|
|
|
@ -1445,6 +1501,24 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
self.assertIn("首个错误:没有可用的线槽/路由路径网络", message)
|
|
|
|
|
self.assertIn("缺失示例:terminal-a -> terminal-b", message)
|
|
|
|
|
|
|
|
|
|
def test_route_eplan_connections_report_ignores_non_numeric_status_counts(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
_terminal_objects, _wiring_objects, _routing_network, auto_routing = _reload_modules()
|
|
|
|
|
report = {
|
|
|
|
|
"routed": 1,
|
|
|
|
|
"collision_warnings": 0,
|
|
|
|
|
"skipped_missing_terminal": 0,
|
|
|
|
|
"route_status_counts": {
|
|
|
|
|
"Routed": "1",
|
|
|
|
|
"ExternalStatus": "not-a-number",
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
message = auto_routing.format_eplan_connection_route_report(report)
|
|
|
|
|
|
|
|
|
|
self.assertIn("正常 1 条", message)
|
|
|
|
|
self.assertNotIn("ExternalStatus", message)
|
|
|
|
|
|
|
|
|
|
def test_bind_wire_task_terminals_from_payload_does_not_create_wires(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, wiring_objects, _routing_network, auto_routing = _reload_modules()
|
|
|
|
|
|