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
def testConnectName(self): self.cursor = OracleDictionaryCursor(connection=self.connection) results = self.cursor.execute("SELECT * FROM test") self.assertEqual(results[0]["NAME"], 'Glenn')
def testExecuteConnectionNotSet(self): self.cursor = OracleDictionaryCursor() with self.assertRaises(ValueError): self.cursor.execute("SELECT * FROM test")
def testInitConnectionIsIncorrectType(self): self.cursor = OracleDictionaryCursor(connection=self.connection) self.assertTrue('foo' not in repr(self.cursor.connection))
def testInitConnectionIsCorrectType(self): self.cursor = OracleDictionaryCursor(connection=self.connection) self.assertTrue('cx_Oracle.Connection' in repr(self.cursor.connection))
def testInitConnectionIsNotNone(self): self.cursor = OracleDictionaryCursor(connection=self.connection) self.assertTrue(self.cursor.connection is not None)
def testInitConnectionIsNone(self): self.cursor = OracleDictionaryCursor(connection=None) self.assertEqual(self.cursor.connection, None)