[TechDraw] Make symbol test a unittest

This commit is contained in:
Benjamin Bræstrup Sayoc
2022-07-25 02:07:43 +02:00
committed by WandererFan
parent 906618c0b6
commit 4fc8596d7b
4 changed files with 43 additions and 16 deletions

View File

@@ -0,0 +1,39 @@
from __future__ import print_function
import FreeCAD
import os
import unittest
from .TechDrawTestUtilities import createPageWithSVGTemplate
class DrawViewSymbolTest(unittest.TestCase):
def setUp(self):
"""Creates a page"""
FreeCAD.newDocument("TDAnno")
FreeCAD.setActiveDocument("TDAnno")
FreeCAD.ActiveDocument = FreeCAD.getDocument("TDAnno")
self.page = createPageWithSVGTemplate("TDAnno")
def tearDown(self):
FreeCAD.closeDocument("TDAnno")
def testMakeSymbol(self):
"""Tests if an symbol can be added to page"""
sym = FreeCAD.ActiveDocument.addObject("TechDraw::DrawViewSymbol", "TestSymbol")
path = os.path.dirname(os.path.abspath(__file__))
symbolFileSpec = path + "/TestSymbol.svg"
f = open(symbolFileSpec, "r")
svg = f.read()
f.close()
sym.Symbol = svg
self.page.addView(sym)
sym.X = 220.0
sym.Y = 150.0
FreeCAD.ActiveDocument.recompute()
self.assertTrue("Up-to-date" in sym.State)
if __name__ == "__main__":
unittest.main()