PD: Add tests loading InvoluteGears created with v0.20
This is in preparation for new features, to ensure we don't break existing documents created with FreeCAD-0.20. The fixtures have been created with the official mac build of FreeCAD-0.20.1 using mostly default parametrization -- only the number of teeth has been reduced in order to keep the file size low.
This commit is contained in:
@@ -55,6 +55,11 @@ set(PartDesign_TestScripts
|
||||
PartDesignTests/TestInvoluteGear.py
|
||||
)
|
||||
|
||||
set(PartDesign_TestFixtures
|
||||
PartDesignTests/Fixtures/InvoluteGear_v0-20.FCStd
|
||||
PartDesignTests/Fixtures/InternalInvoluteGear_v0-20.FCStd
|
||||
)
|
||||
|
||||
set(PartDesign_GearScripts
|
||||
fcgear/__init__.py
|
||||
fcgear/fcgear.py
|
||||
@@ -85,6 +90,7 @@ add_custom_target(PartDesignScripts ALL SOURCES
|
||||
${PartDesign_Scripts}
|
||||
${PartDesign_OtherScripts}
|
||||
${PartDesign_TestScripts}
|
||||
${PartDesign_TestFixtures}
|
||||
${PartDesign_GearScripts}
|
||||
${PartDesign_SprocketScripts}
|
||||
)
|
||||
@@ -95,6 +101,7 @@ fc_target_copy_resource(PartDesignScripts
|
||||
${PartDesign_Scripts}
|
||||
${PartDesign_OtherScripts}
|
||||
${PartDesign_TestScripts}
|
||||
${PartDesign_TestFixtures}
|
||||
${PartDesign_GearScripts}
|
||||
${PartDesign_SprocketScripts}
|
||||
)
|
||||
@@ -119,7 +126,14 @@ INSTALL(
|
||||
DESTINATION
|
||||
Mod/PartDesign/PartDesignTests
|
||||
)
|
||||
|
||||
|
||||
INSTALL(
|
||||
FILES
|
||||
${PartDesign_TestFixtures}
|
||||
DESTINATION
|
||||
Mod/PartDesign/PartDesignTests/Fixtures
|
||||
)
|
||||
|
||||
INSTALL(
|
||||
FILES
|
||||
${PartDesign_GearScripts}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -20,11 +20,14 @@
|
||||
#***************************************************************************
|
||||
|
||||
import unittest
|
||||
import pathlib
|
||||
|
||||
import FreeCAD
|
||||
from Part import makeCircle, Precision
|
||||
import InvoluteGearFeature
|
||||
|
||||
FIXTURE_PATH = pathlib.Path(__file__).parent / "Fixtures"
|
||||
|
||||
class TestInvoluteGear(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.Doc = FreeCAD.newDocument("PartDesignTestInvoluteGear")
|
||||
@@ -108,6 +111,36 @@ class TestInvoluteGear(unittest.TestCase):
|
||||
self.assertSuccessfulRecompute()
|
||||
self.assertSolid(pocket.Shape)
|
||||
|
||||
def testRecomputeExternalGearFromV020(self):
|
||||
FreeCAD.closeDocument(self.Doc.Name) # this was created in setUp(self)
|
||||
self.Doc = FreeCAD.openDocument(str(FIXTURE_PATH / "InvoluteGear_v0-20.FCStd"))
|
||||
created_with = f"created with {self.Doc.getProgramVersion()}"
|
||||
gear = self.Doc.InvoluteGear # from fixture
|
||||
fixture_length = 187.752 # from fixture, rounded to micrometer
|
||||
length_delta = 0.001
|
||||
self.assertClosedWire(gear.Shape) # no recompute yet, i.e. check original
|
||||
self.assertAlmostEqual(fixture_length, gear.Shape.Length, delta=length_delta,
|
||||
msg=f"Total wire length does not match fixture for gear {created_with}")
|
||||
gear.enforceRecompute()
|
||||
self.assertSuccessfulRecompute(gear, msg=f"Cannot recompute gear {created_with}")
|
||||
self.assertAlmostEqual(fixture_length, gear.Shape.Length, delta=length_delta,
|
||||
msg=f"Total wire length changed after recomputing gear {created_with}")
|
||||
|
||||
def testRecomputeInternalGearFromV020(self):
|
||||
FreeCAD.closeDocument(self.Doc.Name) # this was created in setUp(self)
|
||||
self.Doc = FreeCAD.openDocument(str(FIXTURE_PATH / "InternalInvoluteGear_v0-20.FCStd"))
|
||||
created_with = f"created with {self.Doc.getProgramVersion()}"
|
||||
gear = self.Doc.InvoluteGear # from fixture
|
||||
fixture_length = 165.408 # from fixture, rounded to micrometer
|
||||
length_delta = 0.001
|
||||
self.assertClosedWire(gear.Shape) # no recompute yet, i.e. check original
|
||||
self.assertAlmostEqual(fixture_length, gear.Shape.Length, delta=length_delta,
|
||||
msg=f"Total wire length does not match fixture for gear {created_with}")
|
||||
gear.enforceRecompute()
|
||||
self.assertSuccessfulRecompute(gear, msg=f"Cannot recompute gear {created_with}")
|
||||
self.assertAlmostEqual(fixture_length, gear.Shape.Length, delta=length_delta,
|
||||
msg=f"Total wire length changed after recomputing gear {created_with}")
|
||||
|
||||
def assertSuccessfulRecompute(self, *objs, msg=None):
|
||||
if (len(objs) == 0):
|
||||
self.Doc.recompute()
|
||||
|
||||
Reference in New Issue
Block a user