def testCopyHTMLFilesAndDir(self):
     if not os.path.exists(EDUtilsPath.getEdnaUserTempFolder()):
         os.mkdir(EDUtilsPath.getEdnaUserTempFolder())
     strTestFromDir = os.path.join(EDUtilsPath.getEdnaUserTempFolder(), "TestFromDir")
     shutil.rmtree(strTestFromDir, ignore_errors=True)
     os.mkdir(strTestFromDir)
     strTestHtmlFilePath = os.path.join(strTestFromDir, "index.html")
     strTestHtmlDirPath = os.path.join(strTestFromDir, "index")
     EDUtilsFile.writeFile(strTestHtmlFilePath, "Test content")
     if not os.path.exists(strTestHtmlDirPath):
         os.mkdir(strTestHtmlDirPath)
     strTestHtmlDirFilePath = os.path.join(strTestHtmlDirPath, "test.txt")
     EDUtilsFile.writeFile(strTestHtmlDirFilePath, "Test content")
     #
     strTestToDir = os.path.join(EDUtilsPath.getEdnaUserTempFolder(), "TestToDir")
     shutil.rmtree(strTestToDir, ignore_errors=True)
     os.mkdir(strTestToDir)
     EDHandlerESRFPyarchv1_0.copyHTMLDir(strTestFromDir, strTestToDir)
     #
     # Check that files exist in strTestToDir:
     EDAssert.isFile(os.path.join(strTestToDir, "index", "index.html"))
     EDAssert.isFile(os.path.join(strTestToDir, "index", "index", "test.txt"))
     #
     shutil.rmtree(strTestFromDir, ignore_errors=True)
     shutil.rmtree(strTestToDir, ignore_errors=True)
 def testCopyHTMLFilesAndDir(self):
     if not os.path.exists(EDUtilsPath.getEdnaUserTempFolder()):
         os.mkdir(EDUtilsPath.getEdnaUserTempFolder())
     strTestFromDir = os.path.join(EDUtilsPath.getEdnaUserTempFolder(),
                                   "TestFromDir")
     shutil.rmtree(strTestFromDir, ignore_errors=True)
     os.mkdir(strTestFromDir)
     strTestHtmlFilePath = os.path.join(strTestFromDir, "index.html")
     strTestHtmlDirPath = os.path.join(strTestFromDir, "index")
     EDUtilsFile.writeFile(strTestHtmlFilePath, "Test content")
     if not os.path.exists(strTestHtmlDirPath):
         os.mkdir(strTestHtmlDirPath)
     strTestHtmlDirFilePath = os.path.join(strTestHtmlDirPath, "test.txt")
     EDUtilsFile.writeFile(strTestHtmlDirFilePath, "Test content")
     #
     strTestToDir = os.path.join(EDUtilsPath.getEdnaUserTempFolder(),
                                 "TestToDir")
     shutil.rmtree(strTestToDir, ignore_errors=True)
     os.mkdir(strTestToDir)
     EDHandlerESRFPyarchv1_0.copyHTMLDir(strTestFromDir, strTestToDir)
     #
     # Check that files exist in strTestToDir:
     EDAssert.isFile(os.path.join(strTestToDir, "index", "index.html"))
     EDAssert.isFile(
         os.path.join(strTestToDir, "index", "index", "test.txt"))
     #
     shutil.rmtree(strTestFromDir, ignore_errors=True)
     shutil.rmtree(strTestToDir, ignore_errors=True)
    def testCreateStructure(self):
        if "LOGNAME" in os.environ:
            name = os.environ["LOGNAME"]
        else:
            name = str(os.getpid())

        testfile = "/tmp/edna-%s/test-empty.h5" % name
        struct = "/toto/titi/tata"
        h5grp = self.edluginHDF5.createStructure(testfile, struct, {struct:{"foo":"bar"}, "/toto/titi":{"spam":"eggs"}, "/toto":{"tintin":"milou"}})
        EDAssert.equal(h5grp.name, struct, "Check the internal HDF5 path")
        EDAssert.equal(h5grp.file.filename, testfile, "Check the name of the HDF5 File")
        self.edluginHDF5.flushFile(testfile)
        h5grp = self.edluginHDF5.getHDF5File(testfile)[struct]
        ds = h5grp.require_dataset("fake", (10, 10), "i")
        ds[2] = range(10)
        self.edluginHDF5.flushAll()
        EDAssert.equal(self.edluginHDF5.getDataChunk(testfile, struct + "/fake", "[2,6]"), 6, "Check the shape of the dataset written on the disk")
        hdf = self.edluginHDF5.getHDF5File(testfile)
        if "foo" in hdf[struct].attrs:
            EDAssert.equal(hdf[struct].attrs["foo"], "bar", "attributes are OK")
        else:
            raise RuntimeError("HDF5 attributes are not set correctly")
        self.edluginHDF5.close(testfile)
        self.edluginHDF5.closeAll()
        EDAssert.isFile(testfile, "Check the existance of the destination HDF5 file")
    def testExecute(self):
        """
        """
        self.run()
        plugin = self.getPlugin()

################################################################################
# Compare XSDataResults
################################################################################

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

        EDAssert.isFile(xsDataResultObtained.gnom.gnomFile.path.value, "Gnom file exists")
示例#5
0
    def testCreateStructure(self):
        if "LOGNAME" in os.environ:
            name = os.environ["LOGNAME"]
        else:
            name = str(os.getpid())

        testfile = "/tmp/edna-%s/test-empty.h5" % name
        struct = "/toto/titi/tata"
        h5grp = self.edluginHDF5.createStructure(
            testfile, struct, {
                struct: {
                    "foo": "bar"
                },
                "/toto/titi": {
                    "spam": "eggs"
                },
                "/toto": {
                    "tintin": "milou"
                }
            })
        EDAssert.equal(h5grp.name, struct, "Check the internal HDF5 path")
        EDAssert.equal(h5grp.file.filename, testfile,
                       "Check the name of the HDF5 File")
        self.edluginHDF5.flushFile(testfile)
        h5grp = self.edluginHDF5.getHDF5File(testfile)[struct]
        ds = h5grp.require_dataset("fake", (10, 10), "i")
        ds[2] = range(10)
        self.edluginHDF5.flushAll()
        EDAssert.equal(
            self.edluginHDF5.getDataChunk(testfile, struct + "/fake", "[2,6]"),
            6, "Check the shape of the dataset written on the disk")
        hdf = self.edluginHDF5.getHDF5File(testfile)
        if "foo" in hdf[struct].attrs:
            EDAssert.equal(hdf[struct].attrs["foo"], "bar",
                           "attributes are OK")
        else:
            raise RuntimeError("HDF5 attributes are not set correctly")
        self.edluginHDF5.close(testfile)
        self.edluginHDF5.closeAll()
        EDAssert.isFile(testfile,
                        "Check the existance of the destination HDF5 file")
示例#6
0
    def testExecute(self):
        """
        """
        self.run()
        plugin = self.getPlugin()

        ################################################################################
        # Compare XSDataResults
        ################################################################################

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

        EDAssert.isFile(xsDataResultObtained.gnom.gnomFile.path.value,
                        "Gnom file exists")
 def testExecute(self):
     """
     """
     self.run()
     webPage = self.plugin.dataOutput.htmlPage.path.value
     EDAssert.isFile(webPage, "Webpage is generated")
 def testExecute(self):
     """
     """
     self.run()
     webPage = self.plugin.dataOutput.htmlPage.path.value
     EDAssert.isFile(webPage, "Webpage is generated")