equal
deleted
inserted
replaced
1 # copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
1 # copyright 2003-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
3 # |
3 # |
4 # This file is part of CubicWeb. |
4 # This file is part of CubicWeb. |
5 # |
5 # |
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
18 """unit tests for module cubicweb.server.sources.rql2sql""" |
18 """unit tests for module cubicweb.server.sources.rql2sql""" |
19 from __future__ import print_function |
19 from __future__ import print_function |
20 |
20 |
21 import sys |
21 import sys |
22 import os |
22 |
23 from datetime import date |
23 from logilab import database as db |
24 from logilab.common.testlib import TestCase, unittest_main, mock_object |
24 from logilab.common.testlib import TestCase, unittest_main, mock_object |
25 |
25 |
26 from rql import BadRQLQuery |
26 from rql import BadRQLQuery |
27 from rql.utils import register_function, FunctionDescr |
27 from rql.utils import register_function, FunctionDescr |
28 |
28 |
32 |
32 |
33 |
33 |
34 # add a dumb registered procedure |
34 # add a dumb registered procedure |
35 class stockproc(FunctionDescr): |
35 class stockproc(FunctionDescr): |
36 supported_backends = ('postgres', 'sqlite', 'mysql') |
36 supported_backends = ('postgres', 'sqlite', 'mysql') |
|
37 |
37 try: |
38 try: |
38 register_function(stockproc) |
39 register_function(stockproc) |
39 except AssertionError as ex: |
40 except AssertionError: |
40 pass # already registered |
41 pass # already registered |
41 |
42 |
42 |
43 |
43 from logilab import database as db |
|
44 def monkey_patch_import_driver_module(driver, drivers, quiet=True): |
44 def monkey_patch_import_driver_module(driver, drivers, quiet=True): |
45 if not driver in drivers: |
45 if driver not in drivers: |
46 raise db.UnknownDriver(driver) |
46 raise db.UnknownDriver(driver) |
47 for modname in drivers[driver]: |
47 for modname in drivers[driver]: |
48 try: |
48 try: |
49 if not quiet: |
49 if not quiet: |
50 sys.stderr.write('Trying %s\n' % modname) |
50 sys.stderr.write('Trying %s\n' % modname) |