|
|
|
@ -504,6 +504,49 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
self.assertEqual([first], routed_wires)
|
|
|
|
self.assertEqual([first], routed_wires)
|
|
|
|
self.assertEqual(0, len([obj for obj in doc.Objects if obj.Name == "Wire"]))
|
|
|
|
self.assertEqual(0, len([obj for obj in doc.Objects if obj.Name == "Wire"]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_eplan_connection_route_keeps_existing_wire_when_old_replacement_removal_fails(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")
|
|
|
|
|
|
|
|
start = _terminal(doc, terminal_objects, "TerminalStart", "terminal-start", app.Vector(0, 0, 0))
|
|
|
|
|
|
|
|
end = _terminal(doc, terminal_objects, "TerminalEnd", "terminal-end", app.Vector(100, 0, 0))
|
|
|
|
|
|
|
|
routing_network.create_route_carrier(
|
|
|
|
|
|
|
|
doc,
|
|
|
|
|
|
|
|
[app.Vector(0, 0, 20), app.Vector(100, 0, 20)],
|
|
|
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
|
|
|
kind="WireDuct",
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
first = auto_routing.route_eplan_connection_between_terminals(
|
|
|
|
|
|
|
|
doc,
|
|
|
|
|
|
|
|
start,
|
|
|
|
|
|
|
|
end,
|
|
|
|
|
|
|
|
wire_uuid="wire-1",
|
|
|
|
|
|
|
|
)["wire"]
|
|
|
|
|
|
|
|
original_remove = auto_routing._remove_routing_connection_objects
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def failing_remove(target_doc, objects):
|
|
|
|
|
|
|
|
if first in list(objects or []):
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
return original_remove(target_doc, objects)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto_routing._remove_routing_connection_objects = failing_remove
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
with self.assertRaises(auto_routing.AutoRoutingError):
|
|
|
|
|
|
|
|
auto_routing.route_eplan_connection_between_terminals(
|
|
|
|
|
|
|
|
doc,
|
|
|
|
|
|
|
|
start,
|
|
|
|
|
|
|
|
end,
|
|
|
|
|
|
|
|
wire_uuid="wire-1",
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
finally:
|
|
|
|
|
|
|
|
auto_routing._remove_routing_connection_objects = original_remove
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
routed_wires = list(wiring_objects.iter_routed_wire_objects(doc))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.assertEqual([first], routed_wires)
|
|
|
|
|
|
|
|
|
|
|
|
def test_route_carrier_styles_make_generated_objects_distinguishable(self):
|
|
|
|
def test_route_carrier_styles_make_generated_objects_distinguishable(self):
|
|
|
|
_install_fake_freecad()
|
|
|
|
_install_fake_freecad()
|
|
|
|
terminal_objects, _wiring_objects, routing_network, _auto_routing = _reload_modules()
|
|
|
|
terminal_objects, _wiring_objects, routing_network, _auto_routing = _reload_modules()
|
|
|
|
|