Example #1
0
class TestOracleDictionaryCursor(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 = OracleDictionaryCursor(connection=None)
        self.assertEqual(self.cursor.connection, None)

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

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

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


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


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


    def tearDown(self):
        self.connection = None
        del self.connection
Example #2
0
 def testConnectName(self):
     self.cursor = OracleDictionaryCursor(connection=self.connection)
     results = self.cursor.execute("SELECT * FROM test")
     self.assertEqual(results[0]["NAME"], 'Glenn')
Example #3
0
 def testExecuteConnectionNotSet(self):
     self.cursor = OracleDictionaryCursor()
     with self.assertRaises(ValueError):
         self.cursor.execute("SELECT * FROM test")
Example #4
0
 def testInitConnectionIsIncorrectType(self):
     self.cursor = OracleDictionaryCursor(connection=self.connection)
     self.assertTrue('foo' not in repr(self.cursor.connection))
Example #5
0
 def testInitConnectionIsCorrectType(self):
     self.cursor = OracleDictionaryCursor(connection=self.connection)
     self.assertTrue('cx_Oracle.Connection' in repr(self.cursor.connection))
Example #6
0
 def testInitConnectionIsNotNone(self):
     self.cursor = OracleDictionaryCursor(connection=self.connection)
     self.assertTrue(self.cursor.connection is not None)
Example #7
0
 def testInitConnectionIsNone(self):
     self.cursor = OracleDictionaryCursor(connection=None)
     self.assertEqual(self.cursor.connection, None)