Navigation Menu

Skip to content

Commit

Permalink
Split Connection and ConnectionManager Unitests apart
Browse files Browse the repository at this point in the history
  • Loading branch information
nerdynick committed May 14, 2011
1 parent ce3db47 commit d88f27c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 58 deletions.
2 changes: 1 addition & 1 deletion test/__init__.py
@@ -1,7 +1,7 @@
import unittest

def suite():
modules = ['testPool', 'testConnection', 'testQuery', 'testTransaction', 'testLogging']
modules = ['testConnection', 'testConnectionManager', 'testPool', 'testQuery', 'testTransaction', 'testLogging']
alltests = unittest.TestSuite()
for module in map(__import__, modules):
alltests.addTest(unittest.findTestCases(module))
Expand Down
57 changes: 0 additions & 57 deletions test/testConnection.py
Expand Up @@ -15,7 +15,6 @@ def suite():
loader = unittest.TestLoader()
alltests = unittest.TestSuite()
alltests.addTest(loader.loadTestsFromTestCase(Connection))
alltests.addTest(loader.loadTestsFromTestCase(ConnectionManager))

return alltests
# return unittest.TestLoader().loadTestsFromTestCase(Connection)
Expand Down Expand Up @@ -124,62 +123,6 @@ def testPossitionBasedConnectionArgs(self):
self.assertEqual(connection.info['port'], conArgs[4], msg="Ports don't match")
except Exception, e:
self.fail("Failed to create connection with error: "+str(e))


class ConnectionManager(unittest.TestCase):

def setUp(self):
self.username = 'unittest'
self.password = 'zEzaj37u'
self.host = 'localhost'
self.db = 'employees'


self.connDict = {
"host":self.host,
"user":self.username,
"passwd":self.password,
"db":self.db}

def testConnectionManagerCreation(self):
"""
Test the creation of a Connection Manager Object
"""
connectionInfo = PySQLPool.getNewConnection(**self.connDict)
self.assertTrue(isinstance(connectionInfo, PySQLPool.connection.Connection))

connection = PySQLPool.connection.ConnectionManager(connectionInfo)
self.assertTrue(isinstance(connection, PySQLPool.connection.ConnectionManager), msg="Not an instance")

def testConnectionManagerBasicLock(self):
"""
Test the locking of a Connection Manager Object
"""
connectionInfo = PySQLPool.getNewConnection(**self.connDict)
self.assertTrue(isinstance(connectionInfo, PySQLPool.connection.Connection))

connection = PySQLPool.connection.ConnectionManager(connectionInfo)
self.assertTrue(isinstance(connection, PySQLPool.connection.ConnectionManager), msg="Not an instance")

#Test raw boolean and func return
self.assertFalse(connection._locked, msg="Lock Bool not init false")
self.assertFalse(connection.is_locked(), msg="Lock Bool Func not init false")

locked = connection.lock()

self.assertTrue(connection._locked, msg="Lock Bool not true")
self.assertTrue(connection.is_locked(), msg="Lock Bool Func not true")
self.assertTrue(locked, msg="Return not true")

connection.release()
self.assertFalse(connection._locked, msg="Lock Bool not false")
self.assertFalse(connection.is_locked(), msg="Lock Bool Func not false")

def testConnectionManagerTransaction(self):
pass

def testConnectionManagerTransRollback(self):
pass

if __name__ == "__main__":
unittest.main(defaultTest='suite')

0 comments on commit d88f27c

Please sign in to comment.