Esempio n. 1
0
    def postProcess(self, _edObject=None):
        EDPluginExec.postProcess(self)
        self.DEBUG("EDPluginExecSaxsCurvesv1_1.postProcess")

        # Create some output data
        xsDataResult = XSDataResultSaxsCurvesv1_0()
        if self.outputDataFile is None:
            self.outputDataFile = "output.edf"
        if os.path.isfile(self.outputDataFile):
            xsdFile = XSDataFile()
            xsdFile.setPath(XSDataString(os.path.abspath(self.outputDataFile)))
            xsDataResult.setOutputDataFile(xsdFile)

        self.setDataOutput(xsDataResult)
 def preProcess(self):
     """
     PreProcess of the execution test: download a set of images  from http://www.edna-site.org
     and remove any existing output file 
     """
     EDTestCasePluginExecute.preProcess(self)
     self.loadTestImage([ "bsa_013_08.ang", "bsa_013_08.dat" ])
     strExpectedOutput = self.readAndParseFile (self.getReferenceDataOutputFile())
     EDVerbose.DEBUG("strExpectedOutput:" + strExpectedOutput)
     xsDataResultReference = XSDataResultSaxsCurvesv1_0.parseString(strExpectedOutput)
     self.refOutput = xsDataResultReference.getOutputDataFile().getPath().getValue()
     EDVerbose.DEBUG(" Output file is %s" % self.refOutput)
     if not os.path.isdir(os.path.dirname(self.refOutput)):
         os.makedirs(os.path.dirname(self.refOutput))
     if os.path.isfile(self.refOutput):
         EDVerbose.DEBUG(" Output file exists %s, I will remove it" % self.refOutput)
         os.remove(self.refOutput)
 def preProcess(self):
     """
     PreProcess of the execution test: download a set of images  from http://www.edna-site.org
     and remove any existing output file 
     """
     EDTestCasePluginExecute.preProcess(self)
     self.loadTestImage(["bsa_013_08.ang", "bsa_013_08.dat"])
     strExpectedOutput = self.readAndParseFile(
         self.getReferenceDataOutputFile())
     EDVerbose.DEBUG("strExpectedOutput:" + strExpectedOutput)
     xsDataResultReference = XSDataResultSaxsCurvesv1_0.parseString(
         strExpectedOutput)
     self.refOutput = xsDataResultReference.getOutputDataFile().getPath(
     ).getValue()
     EDVerbose.DEBUG(" Output file is %s" % self.refOutput)
     if not os.path.isdir(os.path.dirname(self.refOutput)):
         os.makedirs(os.path.dirname(self.refOutput))
     if os.path.isfile(self.refOutput):
         EDVerbose.DEBUG(" Output file exists %s, I will remove it" %
                         self.refOutput)
         os.remove(self.refOutput)
    def testExecute(self):
        """
        """
        self.run()

        plugin = self.getPlugin()

        strExpectedOutput = self.readAndParseFile (self.getReferenceDataOutputFile())
#        strObtainedOutput = self.readAndParseFile (self.m_edObtainedOutputDataFile)
        EDVerbose.DEBUG("Checking obtained result...")
        xsDataResultReference = XSDataResultSaxsCurvesv1_0.parseString(strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()
        EDAssert.strAlmostEqual(xsDataResultReference.marshal(), xsDataResultObtained.marshal(), "XSDataResult output are the same")


        outputData = open(xsDataResultObtained.getOutputDataFile().getPath().getValue(), "rb").read()
        referenceData = open(os.path.join(self.getTestsDataImagesHome(), "bsa_013_08.dat"), "rb").read()

        EDVerbose.DEBUG("Expected= %s" % os.path.join(self.getTestsDataImagesHome(), "bsa_013_08.dat"))
        EDVerbose.DEBUG("Obtained= %s" % xsDataResultObtained.getOutputDataFile().getPath().getValue())

        EDAssert.strAlmostEqual(outputData, referenceData, _strComment="Curves are the same", _strExcluded="bsa_013_08")
    def testExecute(self):
        """
        """
        self.run()

        plugin = self.getPlugin()

        strExpectedOutput = self.readAndParseFile(
            self.getReferenceDataOutputFile())
        #        strObtainedOutput = self.readAndParseFile (self.m_edObtainedOutputDataFile)
        EDVerbose.DEBUG("Checking obtained result...")
        xsDataResultReference = XSDataResultSaxsCurvesv1_0.parseString(
            strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()
        EDAssert.strAlmostEqual(xsDataResultReference.marshal(),
                                xsDataResultObtained.marshal(),
                                "XSDataResult output are the same")

        outputData = os.linesep.join([
            i.strip() for i in open(
                xsDataResultObtained.getOutputDataFile().getPath().getValue(),
                "rb") if not i.startswith("#")
        ])
        referenceData = os.linesep.join([
            i.strip() for i in open(
                os.path.join(self.getTestsDataImagesHome(), "bsa_013_08.dat"),
                "rb") if not i.startswith("#")
        ])

        #        EDVerbose.DEBUG("Expected= %s" % os.path.join(self.getTestsDataImagesHome(), "bsa_013_08.dat"))
        #        EDVerbose.DEBUG("Obtained= %s" % xsDataResultObtained.getOutputDataFile().getPath().getValue())

        EDAssert.strAlmostEqual(
            outputData,
            referenceData,
            _strComment="Curves are the same",
        )
Esempio n. 6
0
    def postProcess(self, _edObject=None):
        EDPluginExecProcessScript.postProcess(self)
        EDVerbose.DEBUG("EDPluginExecSaxsCurvesv1_0.postProcess")

        #Append the headers is needed
        if self.extraHeader != []:
            datalines = open(self.outputDataFile, "rb").readlines()
            datafile = open(self.outputDataFile, "w")
            for oneLine in self.extraHeader:
                datafile.write(self.headerMarker + oneLine.strip() +
                               os.linesep)
            for oneLine in datalines:
                datafile.write(oneLine.strip() + os.linesep)
            datafile.close()
        # Create some output data
        xsDataResult = XSDataResultSaxsCurvesv1_0()
        if self.outputDataFile is None:
            self.outputDataFile = "output.edf"
        if os.path.isfile(self.outputDataFile):
            xsdFile = XSDataFile()
            xsdFile.setPath(XSDataString(os.path.abspath(self.outputDataFile)))
            xsDataResult.setOutputDataFile(xsdFile)

        self.setDataOutput(xsDataResult)