[TechDraw] Make view test a unittest
This commit is contained in:
committed by
WandererFan
parent
cf8e3f8eda
commit
337b40f846
@@ -147,7 +147,7 @@ SET(TDTest_SRCS
|
||||
TDTest/DrawViewImageTest.py
|
||||
TDTest/DrawViewSymbolTest.py
|
||||
TDTest/DrawViewDimensionTest.py
|
||||
TDTest/DVPartTest.py
|
||||
TDTest/DrawViewPartTest.py
|
||||
TDTest/DVSectionTest.py
|
||||
TDTest/DVBalloonTest.py
|
||||
TDTest/TechDrawTestUtilities.py
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# basic test script for TechDraw module
|
||||
# creates a page and 1 view
|
||||
from __future__ import print_function
|
||||
|
||||
import FreeCAD
|
||||
import os
|
||||
|
||||
|
||||
def DVPartTest():
|
||||
path = os.path.dirname(os.path.abspath(__file__))
|
||||
print("TDPart path: " + path)
|
||||
templateFileSpec = path + "/TestTemplate.svg"
|
||||
|
||||
FreeCAD.newDocument("TDPart")
|
||||
FreeCAD.setActiveDocument("TDPart")
|
||||
FreeCAD.ActiveDocument = FreeCAD.getDocument("TDPart")
|
||||
|
||||
FreeCAD.ActiveDocument.addObject("Part::Box", "Box")
|
||||
|
||||
page = FreeCAD.ActiveDocument.addObject("TechDraw::DrawPage", "Page")
|
||||
FreeCAD.ActiveDocument.addObject("TechDraw::DrawSVGTemplate", "Template")
|
||||
FreeCAD.ActiveDocument.Template.Template = templateFileSpec
|
||||
FreeCAD.ActiveDocument.Page.Template = FreeCAD.ActiveDocument.Template
|
||||
page.Scale = 5.0
|
||||
# page.ViewObject.show() # unit tests run in console mode
|
||||
print("page created")
|
||||
|
||||
view = FreeCAD.ActiveDocument.addObject("TechDraw::DrawViewPart", "View")
|
||||
page.addView(view)
|
||||
|
||||
FreeCAD.ActiveDocument.View.Source = [FreeCAD.ActiveDocument.Box]
|
||||
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
|
||||
rc = False
|
||||
if "Up-to-date" in view.State:
|
||||
rc = True
|
||||
|
||||
FreeCAD.closeDocument("TDPart")
|
||||
return rc
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
DVPartTest()
|
||||
39
src/Mod/TechDraw/TDTest/DrawViewPartTest.py
Normal file
39
src/Mod/TechDraw/TDTest/DrawViewPartTest.py
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# basic test script for TechDraw module
|
||||
# creates a page and 1 view
|
||||
|
||||
import FreeCAD
|
||||
import unittest
|
||||
from .TechDrawTestUtilities import createPageWithSVGTemplate
|
||||
|
||||
|
||||
class DrawViewPartTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
"""Creates a page"""
|
||||
FreeCAD.newDocument("TDPart")
|
||||
FreeCAD.setActiveDocument("TDPart")
|
||||
FreeCAD.ActiveDocument = FreeCAD.getDocument("TDPart")
|
||||
|
||||
FreeCAD.ActiveDocument.addObject("Part::Box", "Box")
|
||||
|
||||
self.page = createPageWithSVGTemplate()
|
||||
self.page.Scale = 5.0
|
||||
# page.ViewObject.show() # unit tests run in console mode
|
||||
print("page created")
|
||||
|
||||
def tearDown(self):
|
||||
FreeCAD.closeDocument("TDPart")
|
||||
|
||||
def testMakeDrawViewPart(self):
|
||||
"""Tests if a view can be added to page"""
|
||||
view = FreeCAD.ActiveDocument.addObject("TechDraw::DrawViewPart", "View")
|
||||
self.page.addView(view)
|
||||
FreeCAD.ActiveDocument.View.Source = [FreeCAD.ActiveDocument.Box]
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
self.assertTrue("Up-to-date" in view.State)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -27,8 +27,8 @@ from TDTest.DrawViewAnnotationTest import DrawViewAnnotationTest # noqa: F401
|
||||
from TDTest.DrawViewDimensionTest import DrawViewDimensionTest # noqa: F401
|
||||
from TDTest.DrawViewImageTest import DrawViewImageTest # noqa: F401
|
||||
from TDTest.DrawViewSymbolTest import DrawViewSymbolTest # noqa: F401
|
||||
from TDTest.DrawViewPartTest import DrawViewPartTest # noqa: F401
|
||||
from TDTest.DProjGroupTest import DProjGroupTest
|
||||
from TDTest.DVPartTest import DVPartTest
|
||||
from TDTest.DVSectionTest import DVSectionTest
|
||||
from TDTest.DVBalloonTest import DVBalloonTest
|
||||
|
||||
@@ -38,14 +38,6 @@ from TDTest.DVBalloonTest import DVBalloonTest
|
||||
|
||||
|
||||
class TechDrawTestCases(unittest.TestCase):
|
||||
def testViewPartCase(self):
|
||||
print("starting TD DrawViewPart test")
|
||||
rc = DVPartTest()
|
||||
if rc:
|
||||
print("TD DrawViewPart test passed")
|
||||
else:
|
||||
print("TD DrawViewPart test failed")
|
||||
|
||||
def testProjGroupCase(self):
|
||||
print("starting TD DrawProjGroup test")
|
||||
rc = DProjGroupTest()
|
||||
|
||||
Reference in New Issue
Block a user