--- a/tests/test_mymanager.py Thu Mar 07 15:42:47 2013 +0100
+++ b/tests/test_mymanager.py Thu Mar 07 18:26:52 2013 +0100
@@ -4,6 +4,7 @@
from mytoolkit import mymanager
import unittest
+import logging
class TestMyManager(unittest.TestCase):
@@ -14,10 +15,18 @@
params = self.params_to_mapping(test_db_conn_params)
self.m = mymanager.get_instance()
self.m.create_conn(**params)
+ #self.setup_logging()
def tearDown(self):
self.m.destroy_conn()
+ def setup_logging(self):
+ #FIXME: write test handler, check SQL log
+ log = logging.getLogger('mymanager_sql')
+ handler = logging.StreamHandler()
+ log.addHandler(handler)
+ log.setLevel(logging.DEBUG)
+
def params_to_mapping(self, params):
return dict([param.split('=') for param in params.split(' ')])
@@ -28,6 +37,11 @@
row = curs.fetchone_dict()
self.assertEqual(row.ajaj, ajaj)
+ def test_mysql_error(self):
+ with self.m.cursor() as curs:
+ self.assertRaises(mymanager.OperationalError,
+ curs.execute, 'SELECT give_me_some_error;')
+
if __name__ == '__main__':
unittest.main()