Tests.py
Go to the documentation of this file.00001
00002
00003
00004
00005 import FreeCAD, unittest
00006
00007
00008
00009
00010
00011
00012
00013 class ParameterTestCase(unittest.TestCase):
00014 def setUp(self):
00015 self.TestPar = FreeCAD.ParamGet("System parameter:Test")
00016
00017 def testGroup(self):
00018
00019
00020 Temp = self.TestPar.GetGroup("44")
00021 self.failUnless(self.TestPar.HasGroup("44"),"Test on created group failed")
00022
00023 self.TestPar.RemGroup("44")
00024 self.failUnless(not self.TestPar.HasGroup("44"),"Test on delete group failed")
00025 Temp =0
00026
00027
00028 def testInt(self):
00029
00030
00031
00032 self.TestPar.SetInt("44",4711)
00033 self.failUnless(self.TestPar.GetInt("44") == 4711,"In and out error at Int")
00034
00035 self.TestPar.RemInt("44")
00036 self.failUnless(self.TestPar.GetInt("44",1) == 1,"Deletion error at Int")
00037
00038
00039 def testBool(self):
00040
00041
00042 self.TestPar.SetBool("44",1)
00043 self.failUnless(self.TestPar.GetBool("44") == 1,"In and out error at Bool")
00044
00045 self.TestPar.RemBool("44")
00046 self.failUnless(self.TestPar.GetBool("44",0) == 0,"Deletion error at Bool")
00047
00048 def testFloat(self):
00049
00050
00051
00052 self.TestPar.SetFloat("44",4711.4711)
00053 self.failUnless(self.TestPar.GetFloat("44") == 4711.4711,"In and out error at Float")
00054
00055 self.TestPar.RemFloat("44")
00056 self.failUnless(self.TestPar.GetFloat("44",1.1) == 1.1,"Deletion error at Float")
00057
00058 def testString(self):
00059
00060
00061
00062 self.TestPar.SetString("44","abcdefgh")
00063 self.failUnless(self.TestPar.GetString("44") == "abcdefgh","In and out error at String")
00064
00065 self.TestPar.RemString("44")
00066 self.failUnless(self.TestPar.GetString("44","hallo") == "hallo","Deletion error at String")
00067
00068 def testNesting(self):
00069
00070
00071 for i in range(50):
00072 self.TestPar.SetFloat(`i`,4711.4711)
00073 self.TestPar.SetInt(`i`,4711)
00074 self.TestPar.SetBool(`i`,1)
00075 Temp = self.TestPar.GetGroup(`i`)
00076 for l in range(50):
00077 Temp.SetFloat(`l`,4711.4711)
00078 Temp.SetInt(`l`,4711)
00079 Temp.SetBool(`l`,1)
00080 Temp = 0
00081
00082 def testExportImport(self):
00083
00084
00085 self.TestPar.SetFloat("ExTest",4711.4711)
00086 self.TestPar.SetInt("ExTest",4711)
00087 self.TestPar.SetString("ExTest","4711")
00088 self.TestPar.SetBool("ExTest",1)
00089 Temp = self.TestPar.GetGroup("ExTest")
00090 Temp.SetFloat("ExTest",4711.4711)
00091 Temp.SetInt("ExTest",4711)
00092 Temp.SetString("ExTest","4711")
00093 Temp.SetBool("ExTest",1)
00094 self.TestPar.Export("ExportTest.FCExport")
00095 Temp = self.TestPar.GetGroup("ImportTest")
00096 Temp.Import("ExportTest.FCExport")
00097 self.failUnless(Temp.GetFloat("ExTest") == 4711.4711,"ExportImport error")
00098 Temp = 0
00099
00100 def tearDown(self):
00101
00102 TestPar = FreeCAD.ParamGet("System parameter:Test")
00103 TestPar.Clear()
00104
00105
00106
00107
00108
00109
00110
00111