Пример #1
0
class SelectQueryTestCase(unittest.TestCase):
    def setUp(self):
        self.host = dbhost
        self.dbName = dbname
        self.username = dbuser
        self.password = dbpassword
        self.conn = Connection(self.host, self.dbName, self.username, self.password, 3306, 10)

    def tearDown(self):
        if self.conn:
            self.conn.close()

    def testSelectStatementWithNoRowsReturned(self):
        result = self.conn.executeSQL("select * from channel where chanid = 999")
        if result:
            log.debug(self.conn.getFormattedSQLResultsFromIterator())
        else:
            log.debug(str(result))

        log.debug("Result = %s" % result)
        self.assertEquals(1, result, "successfull sql select should return 1")
        self.assertTrue(self.conn.getErrorCode() is None, "expected None error code")
        self.assertEquals("", self.conn.getErrorMsg(), "expected empty error msg")
        itr = self.conn.dictRowIterator()
        self.assertTrue(itr is None, "expected null iterator")

    def testSelectStatementWithOneRowReturned(self):
        if self.conn.executeSQL(
            "select chanid, visible, xmltvid, freqid, sourceid, callsign, name, channum from channel where chanid=1021"
        ):
            log.debug("\n" + self.conn.getFormattedSQLResultsFromIterator())
        else:
            log.debug("ERROR " + str(self.conn.getErrorCode()) + ": " + self.conn.getErrorMsg())

    def testSelectStatementWithManyRowsReturned(self):
        if self.conn.executeSQL(
            "select chanid, visible, xmltvid, freqid, sourceid, callsign, name, channum from channel order by chanid"
        ):
            log.debug("\n" + self.conn.getFormattedSQLResultsFromIterator())
        else:
            log.debug("ERROR " + str(self.conn.getErrorCode()) + ": " + self.conn.getErrorMsg())
Пример #2
0
class SelectQueryTestCase(unittest.TestCase):

    def setUp(self):
        self.host = dbhost
        self.dbName = dbname
        self.username = dbuser
        self.password = dbpassword
        self.conn = Connection(self.host, self.dbName, self.username, self.password, 3306, 10)

    def tearDown(self):
        if self.conn:
            self.conn.close()
            
    def testSelectStatementWithNoRowsReturned(self):
        result = self.conn.executeSQL('select * from channel where chanid = 999')    
        if result:
            log.debug(self.conn.getFormattedSQLResultsFromIterator())
        else:
            log.debug(str(result))

        log.debug('Result = %s' % result)
        self.assertEquals(1, result, 'successfull sql select should return 1')
        self.assertTrue(self.conn.getErrorCode() is None, 'expected None error code') 
        self.assertEquals('', self.conn.getErrorMsg(), 'expected empty error msg')
        itr = self.conn.dictRowIterator()
        self.assertTrue(itr is None, 'expected null iterator')

    def testSelectStatementWithOneRowReturned(self):
        if self.conn.executeSQL( "select chanid, visible, xmltvid, freqid, sourceid, callsign, name, channum from channel where chanid=1021" ):
            log.debug('\n' + self.conn.getFormattedSQLResultsFromIterator())
        else:
            log.debug('ERROR ' + str(self.conn.getErrorCode()) + ': ' + self.conn.getErrorMsg())

    def testSelectStatementWithManyRowsReturned(self):
        if self.conn.executeSQL( "select chanid, visible, xmltvid, freqid, sourceid, callsign, name, channum from channel order by chanid" ):
            log.debug('\n' + self.conn.getFormattedSQLResultsFromIterator())
        else:
            log.debug("ERROR " + str(self.conn.getErrorCode()) + ": " + self.conn.getErrorMsg())
Пример #3
0
 def testGetErrorCodeIsNoneWhenNothingDone(self):
     conn = Connection(dbhost, dbname, dbuser, dbpassword, 3306, 60.0)
     errorCode = conn.getErrorCode()
     self.assertTrue(errorCode is None)
Пример #4
0
 def testGetErrorCodeIsNoneWhenNothingDone(self):
     conn = Connection(dbhost, dbname, dbuser, dbpassword, 3306, 60.0)
     errorCode = conn.getErrorCode()
     self.assertTrue(errorCode is None)