Skip to content

Commit

Permalink
Break out PartDesign tests into own folder
Browse files Browse the repository at this point in the history
  • Loading branch information
kkremitzki committed Jul 11, 2017
1 parent 1b56637 commit 4eb5945
Show file tree
Hide file tree
Showing 11 changed files with 788 additions and 524 deletions.
8 changes: 8 additions & 0 deletions src/Mod/PartDesign/App/CMakeLists.txt
Expand Up @@ -153,6 +153,14 @@ SET(PartDesign_Scripts
Scripts/RadialCopy.py
Scripts/Parallelepiped.py
Scripts/Spring.py
PartDesignTests/__init__.py
PartDesignTests/TestDatum.py
PartDesignTests/TestPad.py
PartDesignTests/TestPocket.py
PartDesignTests/TestRevolve.py
PartDesignTests/TestLoft.py
PartDesignTests/TestPipe.py
PartDesignTests/TestMirrored.py
fcgear/__init__.py
fcgear/fcgear.py
fcgear/fcgeardialog.py
Expand Down
14 changes: 14 additions & 0 deletions src/Mod/PartDesign/CMakeLists.txt
Expand Up @@ -30,6 +30,20 @@ INSTALL(
DESTINATION
Mod/PartDesign/Scripts
)

INSTALL(
FILES
PartDesignTests/__init__.py
PartDesignTests/TestDatum.py
PartDesignTests/TestPad.py
PartDesignTests/TestPocket.py
PartDesignTests/TestRevolve.py
PartDesignTests/TestLoft.py
PartDesignTests/TestPipe.py
PartDesignTests/TestMirrored.py
DESTINATION
Mod/PartDesign/PartDesignTests
)

INSTALL(
FILES
Expand Down
77 changes: 77 additions & 0 deletions src/Mod/PartDesign/PartDesignTests/TestDatum.py
@@ -0,0 +1,77 @@
# (c) Juergen Riegel (FreeCAD@juergen-riegel.net) 2011 LGPL *
# *
# This file is part of the FreeCAD CAx development system. *
# *
# This program is free software; you can redistribute it and/or modify *
# it under the terms of the GNU Lesser General Public License (LGPL) *
# as published by the Free Software Foundation; either version 2 of *
# the License, or (at your option) any later version. *
# for detail see the LICENCE text file. *
# *
# FreeCAD is distributed in the hope that it will be useful, *
# but WITHOUT ANY WARRANTY; without even the implied warranty of *
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# GNU Library General Public License for more details. *
# *
# You should have received a copy of the GNU Library General Public *
# License along with FreeCAD; if not, write to the Free Software *
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# USA *
#**************************************************************************
import unittest

import FreeCAD

App = FreeCAD

class TestDatumPoint(unittest.TestCase):
def setUp(self):
self.Doc = FreeCAD.newDocument("PartDesignTestDatumPoint")

def testOriginDatumPoint(self):
self.Body = self.Doc.addObject('PartDesign::Body','Body')
self.DatumPoint = self.Doc.addObject('PartDesign::Point','DatumPoint')
self.DatumPoint.Support = [(self.Doc.XY_Plane,'')]
self.DatumPoint.MapMode = 'ObjectOrigin'
self.Body.addObject(self.DatumPoint)
self.Doc.recompute()

def tearDown(self):
#closing doc
FreeCAD.closeDocument("PartDesignTestDatumPoint")
#print ("omit closing document for debugging")

class TestDatumLine(unittest.TestCase):
def setUp(self):
self.Doc = FreeCAD.newDocument("PartDesignTestDatumLine")

def testXAxisDatumLine(self):
self.Body = self.Doc.addObject('PartDesign::Body','Body')
self.DatumLine = self.Doc.addObject('PartDesign::Line','DatumLine')
self.DatumLine.Support = [(self.Doc.XY_Plane,'')]
self.DatumLine.MapMode = 'ObjectX'
self.Body.addObject(self.DatumLine)
self.Doc.recompute()

def tearDown(self):
#closing doc
FreeCAD.closeDocument("PartDesignTestDatumLine")
#print ("omit closing document for debugging")

class TestDatumPlane(unittest.TestCase):
def setUp(self):
self.Doc = FreeCAD.newDocument("PartDesignTestDatumPlane")

def testXYDatumPlane(self):
self.Body = self.Doc.addObject('PartDesign::Body','Body')
self.DatumPlane = self.Doc.addObject('PartDesign::Plane','DatumPlane')
self.DatumPlane.Support = [(self.Doc.XY_Plane,'')]
self.DatumPlane.MapMode = 'FlatFace'
self.Body.addObject(self.DatumPlane)
self.Doc.recompute()

def tearDown(self):
#closing doc
FreeCAD.closeDocument("PartDesignTestDatumPlane")
#print ("omit closing document for debugging")

83 changes: 83 additions & 0 deletions src/Mod/PartDesign/PartDesignTests/TestLoft.py
@@ -0,0 +1,83 @@
# (c) Juergen Riegel (FreeCAD@juergen-riegel.net) 2011 LGPL *
# *
# This file is part of the FreeCAD CAx development system. *
# *
# This program is free software; you can redistribute it and/or modify *
# it under the terms of the GNU Lesser General Public License (LGPL) *
# as published by the Free Software Foundation; either version 2 of *
# the License, or (at your option) any later version. *
# for detail see the LICENCE text file. *
# *
# FreeCAD is distributed in the hope that it will be useful, *
# but WITHOUT ANY WARRANTY; without even the implied warranty of *
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# GNU Library General Public License for more details. *
# *
# You should have received a copy of the GNU Library General Public *
# License along with FreeCAD; if not, write to the Free Software *
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# USA *
#**************************************************************************
import unittest

import FreeCAD
import TestSketcherApp

class TestLoft(unittest.TestCase):
def setUp(self):
self.Doc = FreeCAD.newDocument("PartDesignTestLoft")

def testSimpleAdditiveLoftCase(self):
self.Body = self.Doc.addObject('PartDesign::Body','Body')
self.ProfileSketch = self.Doc.addObject('Sketcher::SketchObject', 'ProfileSketch')
self.Body.addObject(self.ProfileSketch)
TestSketcherApp.CreateRectangleSketch(self.ProfileSketch, (0, 0), (1, 1))
self.Doc.recompute()
self.LoftSketch = self.Doc.addObject('Sketcher::SketchObject', 'LoftSketch')
self.Body.addObject(self.LoftSketch)
self.LoftSketch.MapMode = 'FlatFace'
self.LoftSketch.Support = (self.Doc.XZ_Plane, [''])
self.Doc.recompute()
TestSketcherApp.CreateRectangleSketch(self.LoftSketch, (0, 1), (1, 1))
self.Doc.recompute()
self.AdditiveLoft = self.Doc.addObject("PartDesign::AdditiveLoft","AdditiveLoft")
self.Body.addObject(self.AdditiveLoft)
self.AdditiveLoft.Profile = self.ProfileSketch
self.AdditiveLoft.Sections = [self.LoftSketch]
self.Doc.recompute()
self.assertAlmostEqual(self.AdditiveLoft.Shape.Volume, 1)

def testSimpleSubtractiveLoftCase(self):
self.Body = self.Doc.addObject('PartDesign::Body','Body')
self.PadSketch = self.Doc.addObject('Sketcher::SketchObject', 'SketchPad')
self.Body.addObject(self.PadSketch)
TestSketcherApp.CreateRectangleSketch(self.PadSketch, (0, 0), (1, 1))
self.Doc.recompute()
self.Pad = self.Doc.addObject("PartDesign::Pad", "Pad")
self.Body.addObject(self.Pad)
self.Pad.Profile = self.PadSketch
self.Pad.Length = 2
self.Doc.recompute()
self.ProfileSketch = self.Doc.addObject('Sketcher::SketchObject', 'ProfileSketch')
self.Body.addObject(self.ProfileSketch)
TestSketcherApp.CreateRectangleSketch(self.ProfileSketch, (0, 0), (1, 1))
self.Doc.recompute()
self.LoftSketch = self.Doc.addObject('Sketcher::SketchObject', 'LoftSketch')
self.Body.addObject(self.LoftSketch)
self.LoftSketch.MapMode = 'FlatFace'
self.LoftSketch.Support = (self.Doc.XZ_Plane, [''])
self.Doc.recompute()
TestSketcherApp.CreateRectangleSketch(self.LoftSketch, (0, 1), (1, 1))
self.Doc.recompute()
self.SubtractiveLoft = self.Doc.addObject("PartDesign::SubtractiveLoft","SubtractiveLoft")
self.Body.addObject(self.SubtractiveLoft)
self.SubtractiveLoft.Profile = self.ProfileSketch
self.SubtractiveLoft.Sections = [self.LoftSketch]
self.Doc.recompute()
self.assertAlmostEqual(self.SubtractiveLoft.Shape.Volume, 1)

def tearDown(self):
#closing doc
FreeCAD.closeDocument("PartDesignTestLoft")
#print ("omit closing document for debugging")

93 changes: 93 additions & 0 deletions src/Mod/PartDesign/PartDesignTests/TestMirrored.py
@@ -0,0 +1,93 @@
# (c) Juergen Riegel (FreeCAD@juergen-riegel.net) 2011 LGPL *
# *
# This file is part of the FreeCAD CAx development system. *
# *
# This program is free software; you can redistribute it and/or modify *
# it under the terms of the GNU Lesser General Public License (LGPL) *
# as published by the Free Software Foundation; either version 2 of *
# the License, or (at your option) any later version. *
# for detail see the LICENCE text file. *
# *
# FreeCAD is distributed in the hope that it will be useful, *
# but WITHOUT ANY WARRANTY; without even the implied warranty of *
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# GNU Library General Public License for more details. *
# *
# You should have received a copy of the GNU Library General Public *
# License along with FreeCAD; if not, write to the Free Software *
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# USA *
#**************************************************************************
import unittest

import FreeCAD
import TestSketcherApp

class TestMirrored(unittest.TestCase):
def setUp(self):
self.Doc = FreeCAD.newDocument("PartDesignTestMirrored")

def testMirroredSketchCase(self):
"""
Creates a unit cube cornered at the origin and mirrors it about the Y axis.
This operation should create a rectangular prism with volume 2.0.
"""
self.Body = self.Doc.addObject('PartDesign::Body','Body')
self.Rect = self.Doc.addObject('Sketcher::SketchObject','Rect')
self.Body.addObject(self.Rect)
TestSketcherApp.CreateRectangleSketch(self.Rect, (0, 0), (1, 1))
self.Doc.recompute()
self.Pad = self.Doc.addObject("PartDesign::Pad","Pad")
self.Pad.Profile = self.Rect
self.Pad.Length = 1
self.Body.addObject(self.Pad)
self.Doc.recompute()
self.Mirrored = self.Doc.addObject("PartDesign::Mirrored","Mirrored")
self.Mirrored.Originals = [self.Pad]
self.Mirrored.MirrorPlane = (self.Rect, ["V_Axis"])
self.Body.addObject(self.Mirrored)
self.Doc.recompute()
self.assertAlmostEqual(self.Mirrored.Shape.Volume, 2.0)

def testMirroredPrimitiveCase(self):
"""
Tests the same mirroring scenario as in the sketch case,
but is designed to ensure the same end result occurs with
a different base object.
"""
self.Body = self.Doc.addObject('PartDesign::Body','Body')
self.Box = self.Doc.addObject('PartDesign::AdditiveBox','Box')
self.Box.Length=1
self.Box.Width=1
self.Box.Height=1
self.Body.addObject(self.Box)
self.Doc.recompute()
self.Mirrored = self.Doc.addObject("PartDesign::Mirrored", "Mirrored")
self.Mirrored.Originals = [self.Box]
self.Mirrored.MirrorPlane = (self.Doc.XY_Plane, [""])
self.Body.addObject(self.Mirrored)
self.Doc.recompute()
self.assertAlmostEqual(self.Mirrored.Shape.Volume, 2.0)

def testMirroredOffsetFailureCase(self):
self.Body = self.Doc.addObject('PartDesign::Body','Body')
self.Rect = self.Doc.addObject('Sketcher::SketchObject','Rect')
self.Body.addObject(self.Rect)
TestSketcherApp.CreateRectangleSketch(self.Rect, (0, 1), (1, 1))
self.Doc.recompute()
self.Pad = self.Doc.addObject("PartDesign::Pad","Pad")
self.Pad.Profile = self.Rect
self.Pad.Length = 1
self.Body.addObject(self.Pad)
self.Doc.recompute()
self.Mirrored = self.Doc.addObject("PartDesign::Mirrored","Mirrored")
self.Mirrored.Originals = [self.Pad]
self.Mirrored.MirrorPlane = (self.Rect, ["H_Axis"])
self.Body.addObject(self.Mirrored)
self.Doc.recompute()
self.assertEqual(self.Mirrored.State, ["Invalid"])

def tearDown(self):
#closing doc
FreeCAD.closeDocument("PartDesignTestMirrored")
#print ("omit closing document for debugging")

0 comments on commit 4eb5945

Please sign in to comment.