Beispiel #1
0
class TestOracleCursor(unittest.TestCase):
    def setUp(self):
        self.connection = OracleConnection(host='127.0.0.1', user='******', 
                                        passwd='y47test', sid='XE').connect

    # connection from __init__
    def testInitConnectionIsNone(self):
        self.cursor = OracleCursor(connection=None)
        self.assertEqual(self.cursor.connection, None)

    def testInitConnectionIsNotNone(self):
        self.cursor = OracleCursor(connection=self.connection)
        self.assertTrue(self.cursor.connection is not None)

    def testInitConnectionIsCorrectType(self):
        self.cursor = OracleCursor(connection=self.connection)
        self.assertTrue('cx_Oracle.Connection' in repr(self.cursor.connection))

    def testInitConnectionIsIncorrectType(self):
        self.cursor = OracleCursor(connection=self.connection)
        self.assertTrue('foo' not in repr(self.cursor.connection))


    # row_type from __init__
    def testRowTypeDefault(self):
        self.cursor = OracleCursor(connection=self.connection)
        self.assertTrue(self.cursor._getRowType() in ALLOWED_TYPES)

    def testRowTypeInAllowedTypes(self):
        self.cursor = OracleCursor(connection=self.connection,
                                    row_type=types.DictionaryType)
        self.assertTrue(self.cursor._getRowType() in ALLOWED_TYPES)

    def testRowTypeNotInAllowedTypes(self):
        self.cursor = OracleCursor(connection=self.connection,
                                    row_type=types.ListType)
        self.assertTrue(self.cursor._getRowType() not in ALLOWED_TYPES)


    # execute
    def testExecuteConnectionNotSet(self):
        self.cursor = OracleCursor()
        with self.assertRaises(ValueError):
            self.cursor.execute("SELECT * FROM test")


    def testConnectName(self):
        self.cursor = OracleCursor(connection=self.connection)
        results = self.cursor.execute("SELECT * FROM test")
        self.assertEqual(results[0][0], 'Glenn')


    def tearDown(self):
        self.connection = None
        del self.connection
Beispiel #2
0
 def testConnectName(self):
     self.cursor = OracleCursor(connection=self.connection)
     results = self.cursor.execute("SELECT * FROM test")
     self.assertEqual(results[0][0], 'Glenn')
Beispiel #3
0
 def testExecuteConnectionNotSet(self):
     self.cursor = OracleCursor()
     with self.assertRaises(ValueError):
         self.cursor.execute("SELECT * FROM test")
Beispiel #4
0
 def testRowTypeNotInAllowedTypes(self):
     self.cursor = OracleCursor(connection=self.connection,
                                 row_type=types.ListType)
     self.assertTrue(self.cursor._getRowType() not in ALLOWED_TYPES)
Beispiel #5
0
 def testRowTypeInAllowedTypes(self):
     self.cursor = OracleCursor(connection=self.connection,
                                 row_type=types.DictionaryType)
     self.assertTrue(self.cursor._getRowType() in ALLOWED_TYPES)
Beispiel #6
0
 def testRowTypeDefault(self):
     self.cursor = OracleCursor(connection=self.connection)
     self.assertTrue(self.cursor._getRowType() in ALLOWED_TYPES)
Beispiel #7
0
 def testInitConnectionIsIncorrectType(self):
     self.cursor = OracleCursor(connection=self.connection)
     self.assertTrue('foo' not in repr(self.cursor.connection))
Beispiel #8
0
 def testInitConnectionIsCorrectType(self):
     self.cursor = OracleCursor(connection=self.connection)
     self.assertTrue('cx_Oracle.Connection' in repr(self.cursor.connection))
Beispiel #9
0
 def testInitConnectionIsNotNone(self):
     self.cursor = OracleCursor(connection=self.connection)
     self.assertTrue(self.cursor.connection is not None)
Beispiel #10
0
 def testInitConnectionIsNone(self):
     self.cursor = OracleCursor(connection=None)
     self.assertEqual(self.cursor.connection, None)