コード例 #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)
コード例 #2
0
ファイル: test_db.py プロジェクト: codingforfun/pymagellan
    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)
コード例 #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)
コード例 #4
0
ファイル: test_db.py プロジェクト: codingforfun/pymagellan
    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)
コード例 #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)
コード例 #6
0
ファイル: test_db.py プロジェクト: codingforfun/pymagellan
    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)
コード例 #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
コード例 #8
0
ファイル: test_db.py プロジェクト: codingforfun/pymagellan
    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
コード例 #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)
コード例 #10
0
ファイル: test_db.py プロジェクト: codingforfun/pymagellan
    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)