Arch: Added test suite
This commit is contained in:
parent
efe6abb54f
commit
578fefc9b1
|
@ -22,6 +22,7 @@ SET(Arch_SRCS
|
||||||
ArchRoof.py
|
ArchRoof.py
|
||||||
importWebGL.py
|
importWebGL.py
|
||||||
ArchSpace.py
|
ArchSpace.py
|
||||||
|
TestArch.py
|
||||||
)
|
)
|
||||||
SOURCE_GROUP("" FILES ${Arch_SRCS})
|
SOURCE_GROUP("" FILES ${Arch_SRCS})
|
||||||
|
|
||||||
|
|
53
src/Mod/Arch/TestArch.py
Normal file
53
src/Mod/Arch/TestArch.py
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
# Unit test for the Arch module
|
||||||
|
|
||||||
|
#***************************************************************************
|
||||||
|
#* (c) Yorik van Havre <yorik@uncreated.net> 2013 *
|
||||||
|
#* *
|
||||||
|
#* 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 FreeCAD, os, unittest, FreeCADGui, Arch, Draft
|
||||||
|
|
||||||
|
class ArchTest(unittest.TestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
# setting a new document to hold the tests
|
||||||
|
if FreeCAD.ActiveDocument:
|
||||||
|
if FreeCAD.ActiveDocument.Name != "ArchTest":
|
||||||
|
FreeCAD.newDocument("ArchTest")
|
||||||
|
else:
|
||||||
|
FreeCAD.newDocument("ArchTest")
|
||||||
|
FreeCAD.setActiveDocument("ArchTest")
|
||||||
|
|
||||||
|
def testWall(self):
|
||||||
|
FreeCAD.Console.PrintLog ('Checking Arch Wall...\n')
|
||||||
|
l=Draft.makeLine(FreeCAD.Vector(0,0,0),FreeCAD.Vector(-2,0,0))
|
||||||
|
w = Arch.makeWall(l)
|
||||||
|
self.failUnless(w,"Arch Wall failed")
|
||||||
|
|
||||||
|
def testStructure(self):
|
||||||
|
FreeCAD.Console.PrintLog ('Checking Arch Structure...\n')
|
||||||
|
s = Arch.makeStructure(length=2,width=3,hright=5)
|
||||||
|
self.failUnless(s,"Arch Structure failed")
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
FreeCAD.closeDocument("ArchTest")
|
||||||
|
pass
|
||||||
|
|
|
@ -514,7 +514,11 @@ def makeCircle(radius, placement=None, face=True, startangle=None, endangle=None
|
||||||
is passed, its Curve must be a Part.Circle'''
|
is passed, its Curve must be a Part.Circle'''
|
||||||
import Part, DraftGeomUtils
|
import Part, DraftGeomUtils
|
||||||
if placement: typecheck([(placement,FreeCAD.Placement)], "makeCircle")
|
if placement: typecheck([(placement,FreeCAD.Placement)], "makeCircle")
|
||||||
obj = FreeCAD.ActiveDocument.addObject("Part::Part2DObjectPython","Circle")
|
if startangle != endangle:
|
||||||
|
n = "Arc"
|
||||||
|
else:
|
||||||
|
n = "Circle"
|
||||||
|
obj = FreeCAD.ActiveDocument.addObject("Part::Part2DObjectPython",n)
|
||||||
_Circle(obj)
|
_Circle(obj)
|
||||||
if isinstance(radius,Part.Edge):
|
if isinstance(radius,Part.Edge):
|
||||||
edge = radius
|
edge = radius
|
||||||
|
@ -888,6 +892,8 @@ def makeEllipse(majradius,minradius,placement=None,face=True,support=None):
|
||||||
a placement.'''
|
a placement.'''
|
||||||
obj = FreeCAD.ActiveDocument.addObject("Part::Part2DObjectPython","Ellipse")
|
obj = FreeCAD.ActiveDocument.addObject("Part::Part2DObjectPython","Ellipse")
|
||||||
_Ellipse(obj)
|
_Ellipse(obj)
|
||||||
|
if minradius > majradius:
|
||||||
|
majradius,minradius = minradius,majradius
|
||||||
obj.MajorRadius = majradius
|
obj.MajorRadius = majradius
|
||||||
obj.MinorRadius = minradius
|
obj.MinorRadius = minradius
|
||||||
obj.Support = support
|
obj.Support = support
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
|
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
|
||||||
#* USA *
|
#* USA *
|
||||||
#* *
|
#* *
|
||||||
#* Werner Mayer 2005 *
|
|
||||||
#***************************************************************************/
|
#***************************************************************************/
|
||||||
|
|
||||||
import FreeCAD, os, unittest, FreeCADGui, Draft
|
import FreeCAD, os, unittest, FreeCADGui, Draft
|
||||||
|
@ -38,34 +37,105 @@ class DraftTest(unittest.TestCase):
|
||||||
FreeCAD.setActiveDocument("DraftTest")
|
FreeCAD.setActiveDocument("DraftTest")
|
||||||
|
|
||||||
def testPivy(self):
|
def testPivy(self):
|
||||||
# first checking if pivy is working
|
|
||||||
FreeCAD.Console.PrintLog ('Checking Pivy...\n')
|
FreeCAD.Console.PrintLog ('Checking Pivy...\n')
|
||||||
from pivy import coin
|
from pivy import coin
|
||||||
c = coin.SoCube()
|
c = coin.SoCube()
|
||||||
FreeCADGui.ActiveDocument.ActiveView.getSceneGraph().addChild(c)
|
FreeCADGui.ActiveDocument.ActiveView.getSceneGraph().addChild(c)
|
||||||
self.failUnless(c,"Pivy is not working properly")
|
self.failUnless(c,"Pivy is not working properly")
|
||||||
|
|
||||||
|
# creation tools
|
||||||
|
|
||||||
|
def testLine(self):
|
||||||
|
FreeCAD.Console.PrintLog ('Checking Draft Line...\n')
|
||||||
|
Draft.makeLine(FreeCAD.Vector(0,0,0),FreeCAD.Vector(-2,0,0))
|
||||||
|
self.failUnless(FreeCAD.ActiveDocument.getObject("Line"),"Draft Line failed")
|
||||||
|
|
||||||
def testWire(self):
|
def testWire(self):
|
||||||
# testing the Wire tool
|
|
||||||
FreeCAD.Console.PrintLog ('Checking Draft Wire...\n')
|
FreeCAD.Console.PrintLog ('Checking Draft Wire...\n')
|
||||||
Draft.makeWire([FreeCAD.Vector(0,0,0),FreeCAD.Vector(2,0,0),FreeCAD.Vector(2,2,0)])
|
Draft.makeWire([FreeCAD.Vector(0,0,0),FreeCAD.Vector(2,0,0),FreeCAD.Vector(2,2,0)])
|
||||||
self.failUnless(FreeCAD.ActiveDocument.getObject("DWire"),"Draft Wire failed")
|
self.failUnless(FreeCAD.ActiveDocument.getObject("DWire"),"Draft Wire failed")
|
||||||
|
|
||||||
|
def testBSpline(self):
|
||||||
|
FreeCAD.Console.PrintLog ('Checking Draft BSpline...\n')
|
||||||
|
Draft.makeBSpline([FreeCAD.Vector(0,0,0),FreeCAD.Vector(2,0,0),FreeCAD.Vector(2,2,0)])
|
||||||
|
self.failUnless(FreeCAD.ActiveDocument.getObject("BSpline"),"Draft BSpline failed")
|
||||||
|
|
||||||
|
def testRectangle(self):
|
||||||
|
FreeCAD.Console.PrintLog ('Checking Draft Rectangle...\n')
|
||||||
|
Draft.makeRectangle(4,2)
|
||||||
|
self.failUnless(FreeCAD.ActiveDocument.getObject("Rectangle"),"Draft Rectangle failed")
|
||||||
|
|
||||||
def testArc(self):
|
def testArc(self):
|
||||||
# testing the Arc tool
|
|
||||||
FreeCAD.Console.PrintLog ('Checking Draft Arc...\n')
|
FreeCAD.Console.PrintLog ('Checking Draft Arc...\n')
|
||||||
Draft.makeCircle(2, startangle=0, endangle=90)
|
Draft.makeCircle(2, startangle=0, endangle=90)
|
||||||
self.failUnless(FreeCAD.ActiveDocument.getObject("Arc"),"Draft Arc failed")
|
self.failUnless(FreeCAD.ActiveDocument.getObject("Arc"),"Draft Arc failed")
|
||||||
|
|
||||||
|
def testCircle(self):
|
||||||
|
FreeCAD.Console.PrintLog ('Checking Draft Circle...\n')
|
||||||
|
Draft.makeCircle(3)
|
||||||
|
self.failUnless(FreeCAD.ActiveDocument.getObject("Circle"),"Draft Circle failed")
|
||||||
|
|
||||||
|
def testPolygon(self):
|
||||||
|
FreeCAD.Console.PrintLog ('Checking Draft Polygon...\n')
|
||||||
|
Draft.makePolygon(5,5)
|
||||||
|
self.failUnless(FreeCAD.ActiveDocument.getObject("Polygon"),"Draft Polygon failed")
|
||||||
|
|
||||||
|
def testEllipse(self):
|
||||||
|
FreeCAD.Console.PrintLog ('Checking Draft Ellipse...\n')
|
||||||
|
Draft.makeEllipse(5,3)
|
||||||
|
self.failUnless(FreeCAD.ActiveDocument.getObject("Ellipse"),"Draft Ellipse failed")
|
||||||
|
|
||||||
|
def testPoint(self):
|
||||||
|
FreeCAD.Console.PrintLog ('Checking Draft Point...\n')
|
||||||
|
Draft.makePoint(5,3,2)
|
||||||
|
self.failUnless(FreeCAD.ActiveDocument.getObject("Point"),"Draft Point failed")
|
||||||
|
|
||||||
|
def testText(self):
|
||||||
|
FreeCAD.Console.PrintLog ('Checking Draft Text...\n')
|
||||||
|
Draft.makeText("Testing Draft")
|
||||||
|
self.failUnless(FreeCAD.ActiveDocument.getObject("Text"),"Draft Text failed")
|
||||||
|
|
||||||
|
#def testShapeString(self):
|
||||||
|
# not working ATM because it needs a font file
|
||||||
|
# FreeCAD.Console.PrintLog ('Checking Draft ShapeString...\n')
|
||||||
|
# Draft.makeShapeString("Testing Draft")
|
||||||
|
# self.failUnless(FreeCAD.ActiveDocument.getObject("ShapeString"),"Draft ShapeString failed")
|
||||||
|
|
||||||
def testDimension(self):
|
def testDimension(self):
|
||||||
# testing the Arc tool
|
|
||||||
FreeCAD.Console.PrintLog ('Checking Draft Dimension...\n')
|
FreeCAD.Console.PrintLog ('Checking Draft Dimension...\n')
|
||||||
Draft.makeDimension(FreeCAD.Vector(0,0,0),FreeCAD.Vector(2,0,0),FreeCAD.Vector(1,-1,0))
|
Draft.makeDimension(FreeCAD.Vector(0,0,0),FreeCAD.Vector(2,0,0),FreeCAD.Vector(1,-1,0))
|
||||||
self.failUnless(FreeCAD.ActiveDocument.getObject("Dimension"),"Draft Dimension failed")
|
self.failUnless(FreeCAD.ActiveDocument.getObject("Dimension"),"Draft Dimension failed")
|
||||||
|
|
||||||
|
# modification tools
|
||||||
|
|
||||||
|
def testMove(self):
|
||||||
|
FreeCAD.Console.PrintLog ('Checking Draft Move...\n')
|
||||||
|
l = Draft.makeLine(FreeCAD.Vector(0,0,0),FreeCAD.Vector(-2,0,0))
|
||||||
|
Draft.move(l,FreeCAD.Vector(2,0,0))
|
||||||
|
self.failUnless(l.Start == FreeCAD.Vector(2,0,0),"Draft Move failed")
|
||||||
|
|
||||||
|
def testCopy(self):
|
||||||
|
FreeCAD.Console.PrintLog ('Checking Draft Move with copy...\n')
|
||||||
|
l = Draft.makeLine(FreeCAD.Vector(0,0,0),FreeCAD.Vector(2,0,0))
|
||||||
|
l2 = Draft.move(l,FreeCAD.Vector(2,0,0),copy=True)
|
||||||
|
self.failUnless(l2,"Draft Move with copy failed")
|
||||||
|
|
||||||
|
def testRotate(self):
|
||||||
|
FreeCAD.Console.PrintLog ('Checking Draft Rotate...\n')
|
||||||
|
l = Draft.makeLine(FreeCAD.Vector(2,0,0),FreeCAD.Vector(4,0,0))
|
||||||
|
Draft.rotate(l,90)
|
||||||
|
self.failUnless(l.Start == FreeCAD.Vector(0,2,0),"Draft Rotate failed")
|
||||||
|
|
||||||
|
def testOffset(self):
|
||||||
|
FreeCAD.Console.PrintLog ('Checking Draft Offset...\n')
|
||||||
|
r = Draft.makeRectangle(4,2)
|
||||||
|
r2 = Draft.offset(r,FreeCAD.Vector(-1,-1,0),copy=True)
|
||||||
|
self.failUnless(r2,"Draft Offset failed")
|
||||||
|
|
||||||
|
# modification tools
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
#closing doc
|
FreeCAD.closeDocument("DraftTest")
|
||||||
#FreeCAD.closeDocument("DraftTest")
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,7 @@ def All():
|
||||||
suite.addTest(unittest.defaultTestLoader.loadTestsFromName("TestPartGui") )
|
suite.addTest(unittest.defaultTestLoader.loadTestsFromName("TestPartGui") )
|
||||||
suite.addTest(unittest.defaultTestLoader.loadTestsFromName("TestPartDesignGui") )
|
suite.addTest(unittest.defaultTestLoader.loadTestsFromName("TestPartDesignGui") )
|
||||||
suite.addTest(unittest.defaultTestLoader.loadTestsFromName("TestDraft") )
|
suite.addTest(unittest.defaultTestLoader.loadTestsFromName("TestDraft") )
|
||||||
|
suite.addTest(unittest.defaultTestLoader.loadTestsFromName("TestArch") )
|
||||||
return suite
|
return suite
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
<File Id="ArchRoofPy" Name="ArchRoof.py" DiskId="1" />
|
<File Id="ArchRoofPy" Name="ArchRoof.py" DiskId="1" />
|
||||||
<File Id="importWebGLPy" Name="importWebGL.py" DiskId="1" />
|
<File Id="importWebGLPy" Name="importWebGL.py" DiskId="1" />
|
||||||
<File Id="ArchSpacePy" Name="ArchSpace.py" DiskId="1" />
|
<File Id="ArchSpacePy" Name="ArchSpace.py" DiskId="1" />
|
||||||
|
<File Id="TestArchPy" Name="TestArch.py" DiskId="1" />
|
||||||
</Component>
|
</Component>
|
||||||
</Directory>
|
</Directory>
|
||||||
</Include>
|
</Include>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user