cubicweb/server/test/unittest_ssplanner.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 26 May 2016 15:38:39 +0200
changeset 11477 3b4d41566de3
parent 11269 73ac69970047
child 11767 432f87a63057
permissions -rw-r--r--
[repo] Don't crash on start when fs schema is missing some db schema entities This occurs usually while developping and we don't want systematically to rebuild the database to start the instance or run e.g. i18ninstance.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6957
ffda12be2e9f [repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6781
diff changeset
     1
# copyright 2003-2011 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
7977
e2d3ff3e7660 [test] drop some deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6957
diff changeset
    19
from cubicweb.devtools import TestServerConfiguration, get_test_db_handler
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
2923
b97a0f8dd4dc fix test schema and update some tests to work again with wf changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2920
diff changeset
    23
# keep cnx so it's not garbage collected and the associated session closed
6781
5062d86d6ffe [unittest2] use unittest2 module fixture api
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6632
diff changeset
    24
def setUpModule(*args):
6631
26c303c3f1aa [test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    25
    global repo, cnx
11269
73ac69970047 [devtools] Simplify test configuration's init
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 11250
diff changeset
    26
    handler = get_test_db_handler(TestServerConfiguration('data', __file__))
7977
e2d3ff3e7660 [test] drop some deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6957
diff changeset
    27
    handler.build_db_cache()
e2d3ff3e7660 [test] drop some deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6957
diff changeset
    28
    global repo, cnx
e2d3ff3e7660 [test] drop some deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6957
diff changeset
    29
    repo, cnx = handler.get_repo_and_cnx()
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    30
6781
5062d86d6ffe [unittest2] use unittest2 module fixture api
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6632
diff changeset
    31
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
    32
    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
    33
    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
    34
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    35
class SSPlannerTC(BasePlannerTC):
11250
597f02c5cf5a [tox] Use py.test to run tests
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11237
diff changeset
    36
    _test = check_plan
1802
d628defebc17 delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1398
diff changeset
    37
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    38
    def setUp(self):
6631
26c303c3f1aa [test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    39
        self.__class__.repo = repo
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    40
        BasePlannerTC.setUp(self)
3252
c0e10da6f1cf tests update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2923
diff changeset
    41
        self.planner = SSPlanner(self.o.schema, self.repo.vreg.rqlhelper)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    42
        self.system = self.o._repo.system_source
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    43
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    44
    def tearDown(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    45
        BasePlannerTC.tearDown(self)
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):
3587
5b3725f315fc test fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3252
diff changeset
    48
        self._test('Any XN ORDERBY XN WHERE X name XN, X is IN (Basket, State, Folder)',
5b3725f315fc test fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3252
diff changeset
    49
                   [('OneFetchStep', [('Any XN ORDERBY XN WHERE X name XN, X is IN(Basket, State, Folder)',
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    50
                                       [{'X': 'Basket', 'XN': 'String'},
3587
5b3725f315fc test fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3252
diff changeset
    51
                                        {'X': 'State', 'XN': 'String'},
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    52
                                        {'X': 'Folder', 'XN': 'String'}])],
11237
f32134dd0067 [repository] drop remanescence of old multi-sources code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 11057
diff changeset
    53
                     [])])
1802
d628defebc17 delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1398
diff changeset
    54
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    55
    def test_groupeded_ambigous_sol(self):
3587
5b3725f315fc test fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3252
diff changeset
    56
        self._test('Any XN,COUNT(X) GROUPBY XN WHERE X name XN, X is IN (Basket, State, Folder)',
5b3725f315fc test fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3252
diff changeset
    57
                   [('OneFetchStep', [('Any XN,COUNT(X) GROUPBY XN WHERE X name XN, X is IN(Basket, State, Folder)',
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    58
                                       [{'X': 'Basket', 'XN': 'String'},
3587
5b3725f315fc test fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3252
diff changeset
    59
                                        {'X': 'State', 'XN': 'String'},
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    60
                                        {'X': 'Folder', 'XN': 'String'}])],
11237
f32134dd0067 [repository] drop remanescence of old multi-sources code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 11057
diff changeset
    61
                     [])])
1802
d628defebc17 delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1398
diff changeset
    62
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    63
if __name__ == '__main__':
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    64
    from logilab.common.testlib import unittest_main
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    65
    unittest_main()