示例#1
0
 def getTestsDataHome(self):
     """
     Returns the Test data home directory
     @return: TestsDataHome
     @rtype: string
     """
     if (self.__strTestsDataHome is None):
         self.__strTestsDataHome = EDUtilsTest.getTestsDataHome()
     return self.__strTestsDataHome
 def __init__(self, _strPluginName, _strPluginDir=None, _strTestName=None):
     """
     Initialize the test case by determining the paths to the plugin home and plugin test directories.
     """
     EDTestCase.__init__(self, _strTestName)
     self.__strPluginName = _strPluginName
     self.__strTestsDataDir = None
     self.__strPluginTestsDataDir = None
     self.__strPluginHome = EDUtilsTest.getFactoryPluginTest().getModuleLocation(_strPluginName)
     self.__strPluginTestsDataHome = EDUtilsTest.getPluginTestDataDirectory(self.getClassName())
     self.__listRequiredConfigurationPluginNames = []
     self.__strConfigurationFile = None
     self.__dictConfigurations = {} #key=pluginName ; value=config
     self.dictReplace = {"${EDNA_TESTS_DATA_HOME}": EDUtilsTest.getTestsDataHome(),
                    "${EDNA_PLUGIN_TESTS_DATA_HOME}" : self.getPluginTestsDataHome(),
                    "${EDNA_HOME}": EDUtilsPath.getEdnaHome(),
                    "${USER}":  os.getenv("USER", "UndefindedUser"),
                    "${TMPDIR}": os.getenv("TMPDIR", tempfile.gettempdir()),
                     }
    def preProcess(self):
        """
        PreProcess of the execution test: download an EDF file from http://www.edna-site.org
        and remove any existing output file, i.e. /tmp/diff6105.edf 
        """
        EDTestCasePluginExecute.preProcess(self)
        self.loadTestImage([ "test_region1_dark_1_0040.edf"])

        xsDataInputReference = XSDataInputExecCommandLine.parseString(self.readAndParseFile (self.getDataInputFile()))
        strInputFile = xsDataInputReference.getInputFileName().getPath().getValue()
        if not(os.path.isdir(os.path.dirname(strInputFile))):
            os.makedirs(os.path.dirname(strInputFile), int("777", 8))
        EDVerbose.DEBUG("temporary filename is :" + strInputFile)
        shutil.copy(os.path.join(EDUtilsTest.getTestsDataHome(), "images", "test_region1_dark_1_0040.edf"), strInputFile)
        strInputXML = self.readAndParseFile (self.getDataInputFile())
        xsDataInputReference = XSDataInputExecCommandLine.parseString(strInputXML)
        outputFileName = xsDataInputReference.getInputFileName().getPath().getValue() + ".gz"
        EDVerbose.DEBUG(" Output file is %s" % outputFileName)
        if os.path.isfile(outputFileName):
            EDVerbose.DEBUG(" Output file exists %s, I will remove it" % outputFileName)
            os.remove(outputFileName)