cubicweb/server/test/unittest_ssplanner.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 03 Nov 2017 15:26:32 +0100
changeset 12239 19aae64c4010
parent 12237 2dd0dcb2e5f9
permissions -rw-r--r--
[cleanup] Fix some flake8 errors
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12237
2dd0dcb2e5f9 [test] Drop no more used "maxeid" based deletion in BaseQuerierTC and derived tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 11769
diff changeset
     1
# copyright 2003 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
5421
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4766
diff changeset
     2
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4766
diff changeset
     3
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4766
diff changeset
     4
# This file is part of CubicWeb.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4766
diff changeset
     5
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4766
diff changeset
     6
# CubicWeb is free software: you can redistribute it and/or modify it under the
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4766
diff changeset
     7
# terms of the GNU Lesser General Public License as published by the Free
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4766
diff changeset
     8
# Software Foundation, either version 2.1 of the License, or (at your option)
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4766
diff changeset
     9
# any later version.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4766
diff changeset
    10
#
5424
8ecbcbff9777 replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5421
diff changeset
    11
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
5421
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4766
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4766
diff changeset
    13
# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4766
diff changeset
    14
# details.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4766
diff changeset
    15
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4766
diff changeset
    16
# You should have received a copy of the GNU Lesser General Public License along
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4766
diff changeset
    17
# with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
1977
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1802
diff changeset
    18
11768
b8b71dd09a2c [test] Avoid pytest discovery warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 11767
diff changeset
    19
from cubicweb import devtools
11250
597f02c5cf5a [tox] Use py.test to run tests
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11237
diff changeset
    20
from cubicweb.devtools.repotest import BasePlannerTC, check_plan
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    21
from cubicweb.server.ssplanner import SSPlanner
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    22
11767
432f87a63057 flake8 and all
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 11269
diff changeset
    23
6781
5062d86d6ffe [unittest2] use unittest2 module fixture api
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6632
diff changeset
    24
def setUpModule(*args):
11767
432f87a63057 flake8 and all
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 11269
diff changeset
    25
    # keep cnx so it's not garbage collected and the associated session closed
6631
26c303c3f1aa [test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    26
    global repo, cnx
11768
b8b71dd09a2c [test] Avoid pytest discovery warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 11767
diff changeset
    27
    handler = devtools.get_test_db_handler(devtools.TestServerConfiguration('data', __file__))
7977
e2d3ff3e7660 [test] drop some deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6957
diff changeset
    28
    handler.build_db_cache()
e2d3ff3e7660 [test] drop some deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6957
diff changeset
    29
    global repo, cnx
e2d3ff3e7660 [test] drop some deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6957
diff changeset
    30
    repo, cnx = handler.get_repo_and_cnx()
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    31
11767
432f87a63057 flake8 and all
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 11269
diff changeset
    32
6781
5062d86d6ffe [unittest2] use unittest2 module fixture api
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6632
diff changeset
    33
def tearDownModule(*args):
4766
162b2b127b15 [test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    34
    global repo, cnx
162b2b127b15 [test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    35
    del repo, cnx
162b2b127b15 [test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    36
11767
432f87a63057 flake8 and all
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 11269
diff changeset
    37
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    38
class SSPlannerTC(BasePlannerTC):
11250
597f02c5cf5a [tox] Use py.test to run tests
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11237
diff changeset
    39
    _test = check_plan
1802
d628defebc17 delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1398
diff changeset
    40
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    41
    def setUp(self):
6631
26c303c3f1aa [test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    42
        self.__class__.repo = repo
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    43
        BasePlannerTC.setUp(self)
3252
c0e10da6f1cf tests update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2923
diff changeset
    44
        self.planner = SSPlanner(self.o.schema, self.repo.vreg.rqlhelper)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    45
        self.system = self.o._repo.system_source
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    46
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    47
    def test_ordered_ambigous_sol(self):
12239
19aae64c4010 [cleanup] Fix some flake8 errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 12237
diff changeset
    48
        self._test(
19aae64c4010 [cleanup] Fix some flake8 errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 12237
diff changeset
    49
            'Any XN ORDERBY XN WHERE X name XN, X is IN (Basket, State, Folder)',
19aae64c4010 [cleanup] Fix some flake8 errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 12237
diff changeset
    50
            [('OneFetchStep', [('Any XN ORDERBY XN WHERE X name XN, '
19aae64c4010 [cleanup] Fix some flake8 errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 12237
diff changeset
    51
                                'X is IN(Basket, State, Folder)',
19aae64c4010 [cleanup] Fix some flake8 errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 12237
diff changeset
    52
                                [{'X': 'Basket', 'XN': 'String'},
19aae64c4010 [cleanup] Fix some flake8 errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 12237
diff changeset
    53
                                 {'X': 'State', 'XN': 'String'},
19aae64c4010 [cleanup] Fix some flake8 errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 12237
diff changeset
    54
                                 {'X': 'Folder', 'XN': 'String'}])],
19aae64c4010 [cleanup] Fix some flake8 errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 12237
diff changeset
    55
              [])])
1802
d628defebc17 delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1398
diff changeset
    56
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    57
    def test_groupeded_ambigous_sol(self):
12239
19aae64c4010 [cleanup] Fix some flake8 errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 12237
diff changeset
    58
        self._test(
19aae64c4010 [cleanup] Fix some flake8 errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 12237
diff changeset
    59
            'Any XN,COUNT(X) GROUPBY XN WHERE X name XN, X is IN (Basket, State, Folder)',
19aae64c4010 [cleanup] Fix some flake8 errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 12237
diff changeset
    60
            [('OneFetchStep', [('Any XN,COUNT(X) GROUPBY XN WHERE X name XN, '
19aae64c4010 [cleanup] Fix some flake8 errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 12237
diff changeset
    61
                                'X is IN(Basket, State, Folder)',
19aae64c4010 [cleanup] Fix some flake8 errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 12237
diff changeset
    62
                                [{'X': 'Basket', 'XN': 'String'},
19aae64c4010 [cleanup] Fix some flake8 errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 12237
diff changeset
    63
                                 {'X': 'State', 'XN': 'String'},
19aae64c4010 [cleanup] Fix some flake8 errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 12237
diff changeset
    64
                                 {'X': 'Folder', 'XN': 'String'}])],
19aae64c4010 [cleanup] Fix some flake8 errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 12237
diff changeset
    65
              [])])
19aae64c4010 [cleanup] Fix some flake8 errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 12237
diff changeset
    66
1802
d628defebc17 delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1398
diff changeset
    67
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    68
if __name__ == '__main__':
11769
f5b815f67ce2 [test] Remove some usages of lgc.testlib
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 11768
diff changeset
    69
    import unittest
f5b815f67ce2 [test] Remove some usages of lgc.testlib
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 11768
diff changeset
    70
    unittest.main()