equal
deleted
inserted
replaced
|
1 #!/usr/bin/env python3 |
|
2 |
|
3 from tests.config import Config |
|
4 from mytoolkit import mymanager |
|
5 |
|
6 import unittest |
|
7 |
|
8 |
|
9 class TestMyManager(unittest.TestCase): |
|
10 |
|
11 def setUp(self): |
|
12 cfg = Config('pgtoolkit.conf') |
|
13 test_db_conn_params = cfg['databases']['test_mysql'] |
|
14 params = self.params_to_mapping(test_db_conn_params) |
|
15 self.m = mymanager.get_instance() |
|
16 self.m.create_conn(**params) |
|
17 |
|
18 def tearDown(self): |
|
19 self.m.destroy_conn() |
|
20 |
|
21 def params_to_mapping(self, params): |
|
22 return dict([param.split('=') for param in params.split(' ')]) |
|
23 |
|
24 def test_mysql_query(self): |
|
25 with self.m.cursor() as curs: |
|
26 ajaj = 1 |
|
27 curs.execute('SELECT %(ajaj)s AS ajaj', locals()) |
|
28 row = curs.fetchone_dict() |
|
29 self.assertEqual(row.ajaj, ajaj) |
|
30 |
|
31 |
|
32 if __name__ == '__main__': |
|
33 unittest.main() |
|
34 |