示例#1
0
    def test_getData_spectrum_trans(self):
        fun = sys._getframe().f_code.co_name
        print("Run: %s.%s() " % (self.__class__.__name__, fun))

        arr = {
            "int": [
                'select IDENT,IDENT from telefonbuch where ROWNUM <= 1',
                "SPECTRUM", "DevLong64", [1, 0]
            ],
            "long": [
                'select IDENT,NAME from telefonbuch where ROWNUM <= 1',
                "SPECTRUM", "DevLong64", [1, 0]
            ],
            "float": [
                'select IDENT,IDENT from telefonbuch where ROWNUM <= 1',
                "SPECTRUM", "DevLong64", [1, 0]
            ],
            "str": [
                'select NAME,VNAME from telefonbuch where ROWNUM <= 1',
                "SPECTRUM", "DevString", [1, 0]
            ],
            # "str": ['select NAME,VNAME from telefonbuch where ROWNUM <= 1',
            #        "SPECTRUM", "DevString", [1, 0]],
            "unicode": [
                'select NAME,IDENT from telefonbuch where ROWNUM <= 1',
                "SPECTRUM", "DevString", [1, 0]
            ],
            "bool": [
                'select IDENT,IDENT from telefonbuch where ROWNUM <= 1',
                "SPECTRUM", "DevLong64", [1, 0]
            ],
        }

        for a in arr:
            cursor = self._mydb.cursor()
            cursor.execute(arr[a][0])
            value = cursor.fetchall()
            cursor.close()

            arr[a][3] = [len(value[0]), 0]

            ds = DBaseSource()
            ds.query = arr[a][0]
            ds.dbtype = self.__dbtype
            ds.format = arr[a][1]
            ds.user = self.__user
            ds.passwd = self.__passwd
            ds.dsn = self.__dsn
            dt = ds.getData()

            self.checkData(dt, arr[a][1], list(el for el in value[0]),
                           arr[a][2], arr[a][3])
示例#2
0
    def test_getData_scalar(self):
        fun = sys._getframe().f_code.co_name
        print("Run: %s.%s() " % (self.__class__.__name__, fun))

        arr = {
            "int": [
                'select IDENT from telefonbuch where ROWNUM <= 1', "SCALAR",
                "DevLong64", [1, 0]
            ],
            "long": [
                'select IDENT from telefonbuch where ROWNUM <= 1', "SCALAR",
                "DevLong64", [1, 0]
            ],
            "float": [
                'select IDENT from telefonbuch where ROWNUM <= 1', "SCALAR",
                "DevLong64", [1, 0]
            ],
            "str": [
                'select NAME from telefonbuch where ROWNUM <= 1', "SCALAR",
                "DevString", [1, 0]
            ],
            "unicode": [
                'select NAME from telefonbuch where ROWNUM <= 1', "SCALAR",
                "DevString", [1, 0]
            ],
            "bool": [
                'select IDENT from telefonbuch where ROWNUM <= 1', "SCALAR",
                "DevLong64", [1, 0]
            ],
        }

        for a in arr:
            cursor = self._mydb.cursor()
            cursor.execute(arr[a][0])
            value = cursor.fetchone()[0]
            cursor.close()

            ds = DBaseSource()
            ds.query = arr[a][0]
            ds.dbtype = self.__dbtype
            ds.format = arr[a][1]
            ds.user = self.__user
            ds.passwd = self.__passwd
            ds.dsn = self.__dsn
            dt = ds.getData()

            #            print a, value, dt,arr[a][0]

            self.checkData(dt, arr[a][1], value, arr[a][2], arr[a][3])
示例#3
0
    def test_getData_default(self):
        fun = sys._getframe().f_code.co_name
        print("Run: %s.%s() " % (self.__class__.__name__, fun))

        query = 'select * from (select IDENT from telefonbuch) ' + \
                'where ROWNUM <= 1'
        format = "SPECTRUM"

        cursor = self._mydb.cursor()
        cursor.execute(query)
        scalar = cursor.fetchone()[0]
        cursor.close()

        ds = DBaseSource()
        self.myAssertRaise(PackageError, ds.getData)

        ds = DBaseSource()
        ds.dbtype = "UNKNOWNDB"
        self.myAssertRaise(PackageError, ds.getData)

        ds = DBaseSource()
        ds.dbtype = self.__dbtype
        #        dt = ds.getData()
        self.myAssertRaise(cx_Oracle.DatabaseError, ds.getData)

        ds = DBaseSource()
        ds.dbtype = self.__dbtype
        ds.query = query
        self.myAssertRaise(cx_Oracle.DatabaseError, ds.getData)

        ds = DBaseSource()
        ds.dbtype = self.__dbtype
        ds.user = self.__user
        ds.passwd = self.__passwd
        ds.query = query
        ds.format = format
        ds.dsn = self.__dsn
        dt = ds.getData()

        self.checkData(dt, 'SPECTRUM', [scalar], 'DevLong64', [1, 0])