def test_last_h5cpp(self):
        print("Run: %s.test_last() " % self.__class__.__name__)

        fname = "test.h5"
        nxFile = None
        eFile = None

        # gname = "testGroup"
        # gtype = "NXentry"
        # fdname = "testField"
        # fdtype = "int64"

        # file handle
        FileWriter.writer = H5CppWriter
        nxFile = FileWriter.create_file(fname, overwrite=True).root()
        # element file objects
        eFile = EFile([], None, nxFile)

        el = Element(self._tfname, self._fattrs2, eFile)
        fi = EField(self._fattrs3, el)
        el2 = EDimensions(self._fattrs3, fi)
        self.assertEqual(fi.tagName, "field")
        self.assertEqual(fi.content, [])
        self.assertEqual(fi._tagAttrs, self._fattrs3)
        self.assertEqual(fi.doc, "")
        self.assertEqual(fi._lastObject(), None)
        self.assertEqual(type(el2.last), EField)
        self.assertEqual(el2.last.rank, "2")

        nxFile.close()
        os.remove(fname)
Exemple #2
0
    def test_last_novalue(self):
        fun = sys._getframe().f_code.co_name
        print("Run: %s.%s() " % (self.__class__.__name__, fun))

        fname = "test.h5"
        nxFile = None
        eFile = None

        # gname = "testGroup"
        # gtype = "NXentry"
        # fdname = "testField"
        # fdtype = "int64"

        # file handle
        nxFile = FileWriter.create_file(fname, overwrite=True).root()
        # element file objects
        eFile = EFile([], None, nxFile)

        el = Element(self._tfname, self._fattrs2, eFile)
        fi = EField(self._fattrs2, el)
        el2 = EDimensions(self._fattrs4, fi)
        el3 = EDim(self._attrs3, el2)
        self.assertEqual(fi.tagName, "field")
        self.assertEqual(fi.content, [])
        self.assertEqual(fi._tagAttrs, self._fattrs2)
        self.assertEqual(fi.doc, "")
        self.assertEqual(fi._lastObject(), None)
        self.assertEqual(type(el2.last), EField)
        self.assertEqual(el2.last.rank, "1")
        self.assertEqual(el3._beforeLast().lengths, {})
        self.assertEqual(fi.lengths, {})
        self.assertEqual(fi.rank, "1")

        nxFile.close()
        os.remove(fname)
Exemple #3
0
    def test_store_last_index2(self):
        fun = sys._getframe().f_code.co_name
        print("Run: %s.%s() " % (self.__class__.__name__, fun))

        fname = "test.h5"
        nxFile = None
        eFile = None

        # gname = "testGroup"
        # gtype = "NXentry"
        # fdname = "testField"
        # fdtype = "int64"

        # file handle
        nxFile = FileWriter.create_file(fname, overwrite=True).root()
        # element file objects
        eFile = EFile([], None, nxFile)

        el = Element(self._tfname, self._fattrs2, eFile)
        fi = EField(self._fattrs2, el)
        el2 = EDimensions(self._fattrs3, fi)
        el3 = EDim(self._attrs5, el2)
        ds = TstDataSource()
        ds.value0d = self.__rnd.randint(1, 10)
        el3.source = ds
        el4 = EDim(self._attrs4, el2)
        ds2 = TstDataSource()
        ds2.value0d = self.__rnd.randint(1, 10)
        el4.source = ds2
        el3.store()
        el4.store()

        self.assertEqual(fi.tagName, "field")
        self.assertEqual(fi.content, [])
        self.assertEqual(fi._tagAttrs, self._fattrs2)
        self.assertEqual(fi.doc, "")
        self.assertEqual(fi._lastObject(), None)
        self.assertEqual(type(el2.last), EField)
        self.assertEqual(el2.last.rank, "2")
        self.assertEqual(el3._beforeLast().lengths, {
            '1': '%s' % ds.value0d,
            '2': '%s' % ds2.value0d
        })
        self.assertEqual(fi.lengths, {
            '1': '%s' % ds.value0d,
            '2': '%s' % ds2.value0d
        })
        self.assertEqual(fi.rank, "2")

        nxFile.close()
        os.remove(fname)