Trees | Indices | Help |
|
---|
|
1 # coding: utf8 2 # 3 # Project: The EDNA Kernel 4 # http://www.edna-site.org 5 # 6 # File: "$Id: EDTestCaseParallelExecute.py 2128 2010-10-04 16:39:42Z kieffer $" 7 # 8 # Copyright (C) 2008-2009 European Synchrotron Radiation Facility 9 # Grenoble, France 10 # 11 # Principal authors: Jérôme Kieffer (kieffer@esrf.fr) 12 # 13 # 14 # This program is free software: you can redistribute it and/or modify 15 # it under the terms of the GNU Lesser General Public License as published 16 # by the Free Software Foundation, either version 3 of the License, or 17 # (at your option) any later version. 18 # 19 # This program is distributed in the hope that it will be useful, 20 # but WITHOUT ANY WARRANTY; without even the implied warranty of 21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 # GNU Lesser General Public License for more details. 23 # 24 # You should have received a copy of the GNU General Public License 25 # and the GNU Lesser General Public License along with this program. 26 # If not, see <http://www.gnu.org/licenses/>. 27 # 28 29 __authors__ = ["Jérôme Kieffer"] 30 __contact__ = "Jerome.Kieffer@esrf.eu" 31 __license__ = "LGPLv3+" 32 __copyright__ = "European Synchrotron Radiation Facility, Grenoble, France" 33 34 import os, sys, math 35 from EDVerbose import EDVerbose 36 from EDTestCase import EDTestCase 37 from EDAssert import EDAssert 38 from EDUtilsUnit import EDUtilsUnit 39 from XSDataCommon import XSDataLength, XSDataString, XSDataAngle, XSDataTime 40 41 4244 """ 45 Unit & execution test for the EDUtilsUnit static class 46 """ 47 50 51132 133 134 135 if __name__ == '__main__': 136 137 edTestCaseEDUtils = EDTestCaseEDUtilsUnit("EDTestCaseEDUtilsUnit") 138 edTestCaseEDUtils.execute() 13953 """ 54 test the execution of unitTestGetSIValue static method 55 """ 56 EDVerbose.DEBUG("EDTestCaseEDUtilsUnit.unitTestGetSIValue") 57 xsd = XSDataLength(1.5) 58 xsd.setUnit(XSDataString("mm")) 59 EDAssert.equal(0.0015, EDUtilsUnit.getSIValue(xsd), "Conversion mm to meter") 60 xsd = XSDataAngle(90) 61 xsd.setUnit(XSDataString("deg")) 62 EDAssert.equal(math.pi / 2, EDUtilsUnit.getSIValue(xsd), "Conversion deg to rad")63 6466 """ 67 """ 68 EDVerbose.DEBUG("EDTestCaseEDUtilsUnit.unitTestToXSD") 69 xsdObt = EDUtilsUnit.toXSD(XSDataLength, "1.5 mm") 70 xsdExp = XSDataLength(1.5) 71 xsdExp.setUnit(XSDataString("mm")) 72 EDAssert.equal(xsdExp.marshal(), xsdObt.marshal(), "XML representation are the same")73 7476 """ 77 Test sub method specific to length: GetValueLength 78 """ 79 EDVerbose.DEBUG("EDTestCaseEDUtilsUnit.unitTestGetValueSILength") 80 EDAssert.equal(1.54E-10, EDUtilsUnit.getValueLength(1.54, "A"), "Length Conversion A -> m ")81 8284 """ 85 Test sub method specific to length: GetValueLength 86 """ 87 EDVerbose.DEBUG("EDTestCaseEDUtilsUnit.unitTestGetValueSIAngle") 88 EDAssert.equal(math.pi / 2.0, EDUtilsUnit.getValueAngle(90, "deg"), "Angle Conversion deg -> rad ")89 9092 """ 93 Test sub method specific to length: GetValueTime 94 """ 95 EDVerbose.DEBUG("EDTestCaseEDUtilsUnit.unitTestGetValueSITime") 96 EDAssert.equal(1800, EDUtilsUnit.getValueTime(30, "mn"), "Length Conversion mn -> s ")97 98100 """ 101 Test conversion in length 102 """ 103 EDVerbose.DEBUG("EDTestCaseEDUtilsUnit.unitTestGetValueLength") 104 EDAssert.equal(0.0452, EDUtilsUnit.getValue(EDUtilsUnit.toXSD(XSDataLength, "45.2 um"), "mm"), "Length Conversion um -> mm ")105 106108 """ 109 Test conversion in length 110 """ 111 EDVerbose.DEBUG("EDTestCaseEDUtilsUnit.unitTestGetValueAngle") 112 EDAssert.equal(100.0, EDUtilsUnit.getValue(EDUtilsUnit.toXSD(XSDataAngle, "90 deg"), "grad"), "Length Conversion deg -> grad ")113 114116 """ 117 Test conversion in Time 118 """ 119 EDVerbose.DEBUG("EDTestCaseEDUtilsUnit.unitTestGetValueTime") 120 EDAssert.equal(60.0, EDUtilsUnit.getValue(EDUtilsUnit.toXSD(XSDataTime, "1 h"), "mn"), "Length Conversion h -> mn ")121 122124 self.addTestMethod(self.unitTestGetSIValue) 125 self.addTestMethod(self.unitTestToXSD) 126 self.addTestMethod(self.unitTestGetValueSILength) 127 self.addTestMethod(self.unitTestGetValueSIAngle) 128 self.addTestMethod(self.unitTestGetValueSITime) 129 self.addTestMethod(self.unitTestGetValueLength) 130 self.addTestMethod(self.unitTestGetValueAngle) 131 self.addTestMethod(self.unitTestGetValueTime)
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Fri Jun 20 03:53:35 2014 | http://epydoc.sourceforge.net |