Exemplo n.º 1
0
    def testAddData(self):
        db = Database(MapDirectory(self.testdatadir), "db00", 'a')
        table = db.getTableByName("R_GR0")

        beforedata = [curs.getRow().asList() for curs in table.getCursor(0)]

        ## Add an empty row
        refrow = Row(table)
        refrow.setColumn(0, 1)
        table.writeRow(refrow)

        refdata = refrow.asList()

        db.close()

        db = Database(MapDirectory(self.testdatadir), "db00")
        table = db.getTableByName("R_GR0")

        aux = db.getTableByName("AUX_GR0")
        am = AuxTableManager(aux)

        afterdata = [curs.getRow().asList() for curs in table.getCursor(0)]

        for curs in table.getCursor(0):
            row = curs.getRow()

            index = row.asDict()['NAME_REF'] & 0xffffff
            offset = row.asDict()['NAME_REF'] >> 24

        self.assertEqual(beforedata + [refdata], afterdata)
Exemplo n.º 2
0
    def testAddData(self):
        db = Database(MapDirectory(self.testdatadir), "db00", "a")
        table = db.getTableByName("R_GR0")

        beforedata = [curs.getRow().asList() for curs in table.getCursor(0)]

        ## Add an empty row
        refrow = Row(table)
        refrow.setColumn(0, 1)
        table.writeRow(refrow)

        refdata = refrow.asList()

        db.close()

        db = Database(MapDirectory(self.testdatadir), "db00")
        table = db.getTableByName("R_GR0")

        aux = db.getTableByName("AUX_GR0")
        am = AuxTableManager(aux)

        afterdata = [curs.getRow().asList() for curs in table.getCursor(0)]

        for curs in table.getCursor(0):
            row = curs.getRow()

            index = row.asDict()["NAME_REF"] & 0xFFFFFF
            offset = row.asDict()["NAME_REF"] >> 24

        self.assertEqual(beforedata + [refdata], afterdata)
Exemplo n.º 3
0
    def testAddRows(self):
        random.seed(0)
        db = Database(MapDirectory(self.testdatadir), "db00", 'a')
        table = db.getTableByName("R_GR0")

        rows = [curs.getRow() for curs in table.getCursor(0)]

        data = [
            "".join([
                chr(random.randint(0, 255))
                for i in xrange(table.rstruct.rt_len)
            ]) for j in xrange(5)
        ]

        newrows = [Row(table, data=d) for d in data]

        for row in newrows:
            table.writeRow(row)

        self.assertEqual(table.getRowCount(), 29 + 5)

        db.close()

        ## Read back
        db = Database(MapDirectory(self.testdatadir), "db00", 'r')
        table = db.getTableByName("R_GR0")

        rowsafter = [curs.getRow() for curs in table.getCursor(0)]

        self.assertEqual(table.getRowCount(), 29 + 5)

        self.assertEqual(rows + newrows, rowsafter)
Exemplo n.º 4
0
    def testAddRows(self):
        random.seed(0)
        db = Database(MapDirectory(self.testdatadir), "db00", "a")
        table = db.getTableByName("R_GR0")

        rows = [curs.getRow() for curs in table.getCursor(0)]

        data = ["".join([chr(random.randint(0, 255)) for i in xrange(table.rstruct.rt_len)]) for j in xrange(5)]

        newrows = [Row(table, data=d) for d in data]

        for row in newrows:
            table.writeRow(row)

        self.assertEqual(table.getRowCount(), 29 + 5)

        db.close()

        ## Read back
        db = Database(MapDirectory(self.testdatadir), "db00", "r")
        table = db.getTableByName("R_GR0")

        rowsafter = [curs.getRow() for curs in table.getCursor(0)]

        self.assertEqual(table.getRowCount(), 29 + 5)

        self.assertEqual(rows + newrows, rowsafter)
Exemplo n.º 5
0
    def testAuxIndex(self):
        db = Database(MapDirectory(self.testdatadir), "db00")

        table = db.getTableByName("R_GR0")
        aux = db.getTableByName("AUX_GR0")

        rows = [x.getRow() for x in aux.getCursor(0)]
        index = rows[0].asDict()['NAME_BUF']

        n = len(index) / 4
        index = struct.unpack('%dI' % n, index)
Exemplo n.º 6
0
    def testAuxIndex(self):
        db = Database(MapDirectory(self.testdatadir), "db00")

        table = db.getTableByName("R_GR0")
        aux = db.getTableByName("AUX_GR0")

        rows = [x.getRow() for x in aux.getCursor(0)]
        index = rows[0].asDict()["NAME_BUF"]

        n = len(index) / 4
        index = struct.unpack("%dI" % n, index)
Exemplo n.º 7
0
    def testSimple(self):
        db = Database(MapDirectory(self.testdatadir), "db00")

        table = db.getTableByName("R_GR0")

        for curs in table.getCursor(0):
            row = curs.getRow()

            aux = db.getTableByName("AUX_GR0")

            am = AuxTableManager(aux)

            index = row.asDict()['NAME_REF'] & 0xffffff
            offset = row.asDict()['NAME_REF'] >> 24
Exemplo n.º 8
0
    def testSimple(self):
        db = Database(MapDirectory(self.testdatadir), "db00")

        table = db.getTableByName("R_GR0")

        for curs in table.getCursor(0):
            row = curs.getRow()

            aux = db.getTableByName("AUX_GR0")

            am = AuxTableManager(aux)

            index = row.asDict()["NAME_REF"] & 0xFFFFFF
            offset = row.asDict()["NAME_REF"] >> 24
Exemplo n.º 9
0
    def testOpenForAppend(self):
        random.seed(0)
        db = Database(MapDirectory(self.testdatadir), "db00", 'a')
        table = db.getTableByName("R_GR0")

        databefore = [curs.getRow() for curs in table.getCursor(0)]
        rowcountbefore = table.getRowCount()

        self.assertEqual(rowcountbefore, 29)

        db.close()

        ## Read back
        db = Database(MapDirectory(self.testdatadir), "db00", 'r')
        table = db.getTableByName("R_GR0")

        dataafter = [curs.getRow() for curs in table.getCursor(0)]
        rowcountafter = table.getRowCount()

        self.assertEqual(rowcountbefore, rowcountafter)
        self.assertEqual(len(databefore), len(dataafter))
        self.assertEqual(databefore, dataafter)
Exemplo n.º 10
0
    def testOpenForAppend(self):
        random.seed(0)
        db = Database(MapDirectory(self.testdatadir), "db00", "a")
        table = db.getTableByName("R_GR0")

        databefore = [curs.getRow() for curs in table.getCursor(0)]
        rowcountbefore = table.getRowCount()

        self.assertEqual(rowcountbefore, 29)

        db.close()

        ## Read back
        db = Database(MapDirectory(self.testdatadir), "db00", "r")
        table = db.getTableByName("R_GR0")

        dataafter = [curs.getRow() for curs in table.getCursor(0)]
        rowcountafter = table.getRowCount()

        self.assertEqual(rowcountbefore, rowcountafter)
        self.assertEqual(len(databefore), len(dataafter))
        self.assertEqual(databefore, dataafter)