diff --git a/src/Mod/TechDraw/CMakeLists.txt b/src/Mod/TechDraw/CMakeLists.txt index e26b111cb1..cc46644550 100644 --- a/src/Mod/TechDraw/CMakeLists.txt +++ b/src/Mod/TechDraw/CMakeLists.txt @@ -148,7 +148,7 @@ SET(TDTest_SRCS TDTest/DrawViewSymbolTest.py TDTest/DrawViewDimensionTest.py TDTest/DrawViewPartTest.py - TDTest/DVSectionTest.py + TDTest/DrawViewSectionTest.py TDTest/DVBalloonTest.py TDTest/TechDrawTestUtilities.py ) diff --git a/src/Mod/TechDraw/TDTest/DVSectionTest.py b/src/Mod/TechDraw/TDTest/DVSectionTest.py deleted file mode 100644 index 15a1624b74..0000000000 --- a/src/Mod/TechDraw/TDTest/DVSectionTest.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# test script for TechDraw module -# creates a page, 1 view and 1 section view -from __future__ import print_function - -import FreeCAD -import os - - -def DVSectionTest(): - path = os.path.dirname(os.path.abspath(__file__)) - print("TDSection path: " + path) - templateFileSpec = path + "/TestTemplate.svg" - - FreeCAD.newDocument("TDSection") - FreeCAD.setActiveDocument("TDSection") - FreeCAD.ActiveDocument = FreeCAD.getDocument("TDSection") - - box = 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") - rc = page.addView(view) - view.Source = [box] - view.Direction = (0.0, 0.0, 1.0) - view.Rotation = 0.0 - view.X = 30.0 - view.Y = 150.0 - print("view created") - - section = FreeCAD.ActiveDocument.addObject("TechDraw::DrawViewSection", "Section") - rc = page.addView(section) - section.Source = [box] - section.BaseView = view - section.Direction = (0.0, 1.0, 0.0) - section.SectionNormal = (0.0, 1.0, 0.0) - section.SectionOrigin = (5.0, 5.0, 5.0) - view.touch() - print("section created") - - FreeCAD.ActiveDocument.recompute() - rc = False - if ("Up-to-date" in view.State) and ("Up-to-date" in section.State): - rc = True - - FreeCAD.closeDocument("TDSection") - return rc - - -if __name__ == "__main__": - DVSectionTest() diff --git a/src/Mod/TechDraw/TDTest/DrawViewSectionTest.py b/src/Mod/TechDraw/TDTest/DrawViewSectionTest.py new file mode 100644 index 0000000000..43a5158fe8 --- /dev/null +++ b/src/Mod/TechDraw/TDTest/DrawViewSectionTest.py @@ -0,0 +1,51 @@ +import FreeCAD +import unittest +from .TechDrawTestUtilities import createPageWithSVGTemplate + + +class DrawViewSectionTest(unittest.TestCase): + def setUp(self): + """Creates a page and a view""" + FreeCAD.newDocument("TDSection") + FreeCAD.setActiveDocument("TDSection") + FreeCAD.ActiveDocument = FreeCAD.getDocument("TDSection") + + self.box = 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") + + self.view = FreeCAD.ActiveDocument.addObject("TechDraw::DrawViewPart", "View") + self.page.addView(self.view) + self.view.Source = [self.box] + self.view.Direction = (0.0, 0.0, 1.0) + self.view.Rotation = 0.0 + self.view.X = 30.0 + self.view.Y = 150.0 + print("view created") + + def tearDown(self): + FreeCAD.closeDocument("TDSection") + + def testMakeDrawViewSection(self): + """Tests if a DrawViewSection can be added to page""" + section = FreeCAD.ActiveDocument.addObject( + "TechDraw::DrawViewSection", "Section" + ) + self.page.addView(section) + section.Source = [self.box] + section.BaseView = self.view + section.Direction = (0.0, 1.0, 0.0) + section.SectionNormal = (0.0, 1.0, 0.0) + section.SectionOrigin = (5.0, 5.0, 5.0) + self.view.touch() + print("section created") + + FreeCAD.ActiveDocument.recompute() + self.assertTrue("Up-to-date" in section.State) + + +if __name__ == "__main__": + unittest.main() diff --git a/src/Mod/TechDraw/TestTechDrawApp.py b/src/Mod/TechDraw/TestTechDrawApp.py index 8305b0ac0b..a3409d3dd9 100644 --- a/src/Mod/TechDraw/TestTechDrawApp.py +++ b/src/Mod/TechDraw/TestTechDrawApp.py @@ -26,10 +26,10 @@ from TDTest.DrawHatchTest import DrawHatchTest # noqa: F401 from TDTest.DrawViewAnnotationTest import DrawViewAnnotationTest # noqa: F401 from TDTest.DrawViewDimensionTest import DrawViewDimensionTest # noqa: F401 from TDTest.DrawViewImageTest import DrawViewImageTest # noqa: F401 +from TDTest.DrawViewSectionTest import DrawViewSectionTest # noqa: F401 from TDTest.DrawViewSymbolTest import DrawViewSymbolTest # noqa: F401 from TDTest.DrawViewPartTest import DrawViewPartTest # noqa: F401 from TDTest.DProjGroupTest import DProjGroupTest -from TDTest.DVSectionTest import DVSectionTest from TDTest.DVBalloonTest import DVBalloonTest # --------------------------------------------------------------------------- @@ -46,14 +46,6 @@ class TechDrawTestCases(unittest.TestCase): else: print("TD DrawProjGroup test failed") - def testSectionCase(self): - print("starting TD DrawViewSection test") - rc = DVSectionTest() - if rc: - print("TD DrawViewSection test passed") - else: - print("TD DrawViewSection test failed") - def testBalloonCase(self): print("starting TD DrawViewBalloon test") rc = DVBalloonTest()