CAM: Add tests loading a helical path created with v0.21
This demonstrates a regression introduced with PR #14364, where documents containing helix operations cannot be recomputed any more (see #15643). This is in preparation for a fix and to ensure we don't break it again. The fixture has been created with the official mac build of FreeCAD-0.21.1
This commit is contained in:
BIN
src/Mod/CAM/CAMTests/Fixtures/OpHelix_v0-21.FCStd
Normal file
BIN
src/Mod/CAM/CAMTests/Fixtures/OpHelix_v0-21.FCStd
Normal file
Binary file not shown.
@@ -185,3 +185,14 @@ class PathTestBase(unittest.TestCase):
|
||||
self.assertEqual(len(pts0), len(pts1))
|
||||
for i in range(len(pts0)):
|
||||
self.assertCoincide(pts0[i], pts1[i])
|
||||
|
||||
def assertSuccessfulRecompute(self, doc, *objs, msg=None):
|
||||
"""Asserts that the given objects can be successfully recomputed."""
|
||||
if len(objs) == 0:
|
||||
doc.recompute()
|
||||
objs = doc.Objects
|
||||
else:
|
||||
doc.recompute(objs)
|
||||
failed_objects = [o.Name for o in objs if "Invalid" in o.State]
|
||||
if len(failed_objects) > 0:
|
||||
self.fail(msg or f"Recompute failed for {failed_objects}")
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
|
||||
import pathlib
|
||||
|
||||
import Draft
|
||||
import FreeCAD
|
||||
import Path
|
||||
@@ -27,6 +29,8 @@ import Path.Main.Job as PathJob
|
||||
import Path.Op.Helix as PathHelix
|
||||
import CAMTests.PathTestUtils as PathTestUtils
|
||||
|
||||
FIXTURE_PATH = pathlib.Path(__file__).parent / "Fixtures"
|
||||
|
||||
Path.Log.setLevel(Path.Log.Level.INFO, Path.Log.thisModule())
|
||||
# Path.Log.trackModule(Path.Log.thisModule())
|
||||
|
||||
@@ -126,3 +130,47 @@ class TestPathHelix(PathTestUtils.PathTestBase):
|
||||
self.assertRoughly(
|
||||
round(pos.Length / 10, 0), proxy.holeDiameter(op, model, sub)
|
||||
)
|
||||
|
||||
def testRecomputeHelixFromV021(self):
|
||||
"""Verify that we can still open and recompute a Helix created with older FreeCAD"""
|
||||
self.tearDown()
|
||||
self.doc = FreeCAD.openDocument(str(FIXTURE_PATH / "OpHelix_v0-21.FCStd"))
|
||||
created_with = f"created with {self.doc.getProgramVersion()}"
|
||||
|
||||
def check(helix, direction, start_side, cut_mode):
|
||||
with self.subTest(f"{helix.Name}: {direction}, {start_side}, {cut_mode}"):
|
||||
# no recompute yet, i.e. check original as precondition
|
||||
self.assertEqual(
|
||||
helix.Direction,
|
||||
direction,
|
||||
msg=f"Direction does not match fixture for helix {created_with}",
|
||||
)
|
||||
self.assertEqual(
|
||||
helix.StartSide,
|
||||
start_side,
|
||||
msg=f"StartSide does not match fixture for helix {created_with}",
|
||||
)
|
||||
|
||||
# now see whether we can recompute the object from the old document
|
||||
helix.enforceRecompute()
|
||||
self.assertSuccessfulRecompute(
|
||||
self.doc, helix, msg=f"Cannot recompute helix {created_with}"
|
||||
)
|
||||
self.assertEqual(
|
||||
helix.Direction,
|
||||
direction,
|
||||
msg=f"Direction changed after recomputing helix {created_with}",
|
||||
)
|
||||
self.assertEqual(
|
||||
helix.StartSide,
|
||||
start_side,
|
||||
msg=f"StartSide changed after recomputing helix {created_with}",
|
||||
)
|
||||
# self.assertEqual(helix.CutMode, cut_mode,
|
||||
# msg=f"CutMode not correctly derived for helix {created_with}")
|
||||
|
||||
# object names and expected values defined in the fixture
|
||||
check(self.doc.Helix, "CW", "Inside", "Conventional")
|
||||
check(self.doc.Helix001, "CW", "Outside", "Climb")
|
||||
check(self.doc.Helix002, "CCW", "Inside", "Climb")
|
||||
check(self.doc.Helix003, "CCW", "Outside", "Conventional")
|
||||
|
||||
@@ -349,6 +349,10 @@ SET(Tests_SRCS
|
||||
CAMTests/Tools/Shape/test-path-tool-bit-shape-00.fcstd
|
||||
)
|
||||
|
||||
SET(Tests_Fixtures
|
||||
CAMTests/Fixtures/OpHelix_v0-21.FCStd
|
||||
)
|
||||
|
||||
SET(PathImages_Ops
|
||||
Images/Ops/chamfer.svg
|
||||
)
|
||||
@@ -411,6 +415,7 @@ ADD_CUSTOM_TARGET(PathScripts ALL
|
||||
SET(test_files
|
||||
${Path_Scripts}
|
||||
${Tests_SRCS}
|
||||
${Tests_Fixtures}
|
||||
)
|
||||
|
||||
ADD_CUSTOM_TARGET(Tests ALL
|
||||
@@ -536,6 +541,13 @@ INSTALL(
|
||||
Mod/CAM/CAMTests
|
||||
)
|
||||
|
||||
INSTALL(
|
||||
FILES
|
||||
${Tests_Fixtures}
|
||||
DESTINATION
|
||||
Mod/CAM/CAMTests/Fixtures
|
||||
)
|
||||
|
||||
INSTALL(
|
||||
DIRECTORY
|
||||
CAMTests/Tools
|
||||
|
||||
Reference in New Issue
Block a user