equal
deleted
inserted
replaced
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 unittest |
22 |
23 |
23 from logilab import database as db |
24 from logilab import database as db |
24 from logilab.common.testlib import TestCase, unittest_main, mock_object |
25 from logilab.common.testlib import mock_object |
25 |
26 |
26 from rql import BadRQLQuery |
27 from rql import BadRQLQuery |
27 from rql.utils import register_function, FunctionDescr |
28 from rql.utils import register_function, FunctionDescr |
28 |
29 |
29 from cubicweb import devtools |
30 from cubicweb import devtools |
2234 WHERE NOT (DATE(_P.cw_datenaiss)=CURRENT_DATE)'''), |
2235 WHERE NOT (DATE(_P.cw_datenaiss)=CURRENT_DATE)'''), |
2235 ]: |
2236 ]: |
2236 with self.subTest(rql=rql): |
2237 with self.subTest(rql=rql): |
2237 self._check(rql, sql) |
2238 self._check(rql, sql) |
2238 |
2239 |
2239 class removeUnsusedSolutionsTC(TestCase): |
2240 class removeUnsusedSolutionsTC(unittest.TestCase): |
2240 def test_invariant_not_varying(self): |
2241 def test_invariant_not_varying(self): |
2241 rqlst = mock_object(defined_vars={}) |
2242 rqlst = mock_object(defined_vars={}) |
2242 rqlst.defined_vars['A'] = mock_object(scope=rqlst, stinfo={}, _q_invariant=True) |
2243 rqlst.defined_vars['A'] = mock_object(scope=rqlst, stinfo={}, _q_invariant=True) |
2243 rqlst.defined_vars['B'] = mock_object(scope=rqlst, stinfo={}, _q_invariant=False) |
2244 rqlst.defined_vars['B'] = mock_object(scope=rqlst, stinfo={}, _q_invariant=False) |
2244 self.assertEqual(remove_unused_solutions(rqlst, [{'A': 'RugbyGroup', 'B': 'RugbyTeam'}, |
2245 self.assertEqual(remove_unused_solutions(rqlst, [{'A': 'RugbyGroup', 'B': 'RugbyTeam'}, |
2257 ([{'A': 'RugbyGroup', 'B': 'RugbyTeam'}], {}, set()) |
2258 ([{'A': 'RugbyGroup', 'B': 'RugbyTeam'}], {}, set()) |
2258 ) |
2259 ) |
2259 |
2260 |
2260 |
2261 |
2261 if __name__ == '__main__': |
2262 if __name__ == '__main__': |
2262 unittest_main() |
2263 unittest.main() |