server/test/unittest_session.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 23 Jan 2012 12:39:21 +0100
changeset 8179 e52a084e955c
parent 7970 83075d897943
child 8542 7e264ce34cd4
permissions -rw-r--r--
backport stable
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7350
c2452cd57026 [session] enhance session's transaction storage handling to fix cases where commit/rollback is done while in the context of hooks_control/security_enabled managers. Closes #1412648: commit or rollback during postcreate reset hooks control state
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6340
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: 5197
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: 5197
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: 5197
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: 5197
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: 5197
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: 5197
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: 5197
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: 5197
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: 5197
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: 5197
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: 5197
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: 5197
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: 5197
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: 5197
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: 5197
diff changeset
    17
# with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
7364
aff846ce1050 missing future import
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7350
diff changeset
    18
from __future__ import with_statement
aff846ce1050 missing future import
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7350
diff changeset
    19
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    20
from logilab.common.testlib import TestCase, unittest_main, mock_object
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    21
5193
c9671feff5e2 [session] no way for queries from an InternalSession to be a dbapi query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4212
diff changeset
    22
from cubicweb.devtools.testlib import CubicWebTC
7350
c2452cd57026 [session] enhance session's transaction storage handling to fix cases where commit/rollback is done while in the context of hooks_control/security_enabled managers. Closes #1412648: commit or rollback during postcreate reset hooks control state
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6340
diff changeset
    23
from cubicweb.server.session import _make_description, hooks_control
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    24
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    25
class Variable:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    26
    def __init__(self, name):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    27
        self.name = name
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    28
        self.children = []
1802
d628defebc17 delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1398
diff changeset
    29
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    30
    def get_type(self, solution, args=None):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    31
        return solution[self.name]
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    32
    def as_string(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    33
        return self.name
1802
d628defebc17 delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1398
diff changeset
    34
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    35
class Function:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    36
    def __init__(self, name, varname):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    37
        self.name = name
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    38
        self.children = [Variable(varname)]
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    39
    def get_type(self, solution, args=None):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    40
        return 'Int'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    41
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    42
class MakeDescriptionTC(TestCase):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    43
    def test_known_values(self):
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 0
diff changeset
    44
        solution = {'A': 'Int', 'B': 'CWUser'}
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    45
        self.assertEqual(_make_description((Function('max', 'A'), Variable('B')), {}, solution),
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 0
diff changeset
    46
                          ['Int','CWUser'])
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    47
7350
c2452cd57026 [session] enhance session's transaction storage handling to fix cases where commit/rollback is done while in the context of hooks_control/security_enabled managers. Closes #1412648: commit or rollback during postcreate reset hooks control state
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6340
diff changeset
    48
5193
c9671feff5e2 [session] no way for queries from an InternalSession to be a dbapi query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4212
diff changeset
    49
class InternalSessionTC(CubicWebTC):
c9671feff5e2 [session] no way for queries from an InternalSession to be a dbapi query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4212
diff changeset
    50
    def test_dbapi_query(self):
c9671feff5e2 [session] no way for queries from an InternalSession to be a dbapi query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4212
diff changeset
    51
        session = self.repo.internal_session()
c9671feff5e2 [session] no way for queries from an InternalSession to be a dbapi query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4212
diff changeset
    52
        self.assertFalse(session.running_dbapi_query)
5197
98dc05495e3e [test] properly close session
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5193
diff changeset
    53
        session.close()
5193
c9671feff5e2 [session] no way for queries from an InternalSession to be a dbapi query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4212
diff changeset
    54
7350
c2452cd57026 [session] enhance session's transaction storage handling to fix cases where commit/rollback is done while in the context of hooks_control/security_enabled managers. Closes #1412648: commit or rollback during postcreate reset hooks control state
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6340
diff changeset
    55
c2452cd57026 [session] enhance session's transaction storage handling to fix cases where commit/rollback is done while in the context of hooks_control/security_enabled managers. Closes #1412648: commit or rollback during postcreate reset hooks control state
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6340
diff changeset
    56
class SessionTC(CubicWebTC):
c2452cd57026 [session] enhance session's transaction storage handling to fix cases where commit/rollback is done while in the context of hooks_control/security_enabled managers. Closes #1412648: commit or rollback during postcreate reset hooks control state
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6340
diff changeset
    57
c2452cd57026 [session] enhance session's transaction storage handling to fix cases where commit/rollback is done while in the context of hooks_control/security_enabled managers. Closes #1412648: commit or rollback during postcreate reset hooks control state
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6340
diff changeset
    58
    def test_hooks_control(self):
c2452cd57026 [session] enhance session's transaction storage handling to fix cases where commit/rollback is done while in the context of hooks_control/security_enabled managers. Closes #1412648: commit or rollback during postcreate reset hooks control state
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6340
diff changeset
    59
        session = self.session
c2452cd57026 [session] enhance session's transaction storage handling to fix cases where commit/rollback is done while in the context of hooks_control/security_enabled managers. Closes #1412648: commit or rollback during postcreate reset hooks control state
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6340
diff changeset
    60
        self.assertEqual(session.hooks_mode, session.HOOKS_ALLOW_ALL)
c2452cd57026 [session] enhance session's transaction storage handling to fix cases where commit/rollback is done while in the context of hooks_control/security_enabled managers. Closes #1412648: commit or rollback during postcreate reset hooks control state
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6340
diff changeset
    61
        self.assertEqual(session.disabled_hook_categories, set())
c2452cd57026 [session] enhance session's transaction storage handling to fix cases where commit/rollback is done while in the context of hooks_control/security_enabled managers. Closes #1412648: commit or rollback during postcreate reset hooks control state
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6340
diff changeset
    62
        self.assertEqual(session.enabled_hook_categories, set())
c2452cd57026 [session] enhance session's transaction storage handling to fix cases where commit/rollback is done while in the context of hooks_control/security_enabled managers. Closes #1412648: commit or rollback during postcreate reset hooks control state
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6340
diff changeset
    63
        self.assertEqual(len(session._tx_data), 1)
c2452cd57026 [session] enhance session's transaction storage handling to fix cases where commit/rollback is done while in the context of hooks_control/security_enabled managers. Closes #1412648: commit or rollback during postcreate reset hooks control state
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6340
diff changeset
    64
        with hooks_control(session, session.HOOKS_DENY_ALL, 'metadata'):
c2452cd57026 [session] enhance session's transaction storage handling to fix cases where commit/rollback is done while in the context of hooks_control/security_enabled managers. Closes #1412648: commit or rollback during postcreate reset hooks control state
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6340
diff changeset
    65
            self.assertEqual(session.hooks_mode, session.HOOKS_DENY_ALL)
c2452cd57026 [session] enhance session's transaction storage handling to fix cases where commit/rollback is done while in the context of hooks_control/security_enabled managers. Closes #1412648: commit or rollback during postcreate reset hooks control state
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6340
diff changeset
    66
            self.assertEqual(session.disabled_hook_categories, set())
c2452cd57026 [session] enhance session's transaction storage handling to fix cases where commit/rollback is done while in the context of hooks_control/security_enabled managers. Closes #1412648: commit or rollback during postcreate reset hooks control state
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6340
diff changeset
    67
            self.assertEqual(session.enabled_hook_categories, set(('metadata',)))
c2452cd57026 [session] enhance session's transaction storage handling to fix cases where commit/rollback is done while in the context of hooks_control/security_enabled managers. Closes #1412648: commit or rollback during postcreate reset hooks control state
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6340
diff changeset
    68
            session.commit()
c2452cd57026 [session] enhance session's transaction storage handling to fix cases where commit/rollback is done while in the context of hooks_control/security_enabled managers. Closes #1412648: commit or rollback during postcreate reset hooks control state
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6340
diff changeset
    69
            self.assertEqual(session.hooks_mode, session.HOOKS_DENY_ALL)
c2452cd57026 [session] enhance session's transaction storage handling to fix cases where commit/rollback is done while in the context of hooks_control/security_enabled managers. Closes #1412648: commit or rollback during postcreate reset hooks control state
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6340
diff changeset
    70
            self.assertEqual(session.disabled_hook_categories, set())
c2452cd57026 [session] enhance session's transaction storage handling to fix cases where commit/rollback is done while in the context of hooks_control/security_enabled managers. Closes #1412648: commit or rollback during postcreate reset hooks control state
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6340
diff changeset
    71
            self.assertEqual(session.enabled_hook_categories, set(('metadata',)))
c2452cd57026 [session] enhance session's transaction storage handling to fix cases where commit/rollback is done while in the context of hooks_control/security_enabled managers. Closes #1412648: commit or rollback during postcreate reset hooks control state
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6340
diff changeset
    72
            session.rollback()
c2452cd57026 [session] enhance session's transaction storage handling to fix cases where commit/rollback is done while in the context of hooks_control/security_enabled managers. Closes #1412648: commit or rollback during postcreate reset hooks control state
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6340
diff changeset
    73
            self.assertEqual(session.hooks_mode, session.HOOKS_DENY_ALL)
c2452cd57026 [session] enhance session's transaction storage handling to fix cases where commit/rollback is done while in the context of hooks_control/security_enabled managers. Closes #1412648: commit or rollback during postcreate reset hooks control state
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6340
diff changeset
    74
            self.assertEqual(session.disabled_hook_categories, set())
c2452cd57026 [session] enhance session's transaction storage handling to fix cases where commit/rollback is done while in the context of hooks_control/security_enabled managers. Closes #1412648: commit or rollback during postcreate reset hooks control state
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6340
diff changeset
    75
            self.assertEqual(session.enabled_hook_categories, set(('metadata',)))
7757
5b3584c5a7c3 [hooks control] test and fix session.reset_hooks_mode_categories, closes #1908680
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7730
diff changeset
    76
            with hooks_control(session, session.HOOKS_ALLOW_ALL, 'integrity'):
5b3584c5a7c3 [hooks control] test and fix session.reset_hooks_mode_categories, closes #1908680
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7730
diff changeset
    77
                self.assertEqual(session.hooks_mode, session.HOOKS_ALLOW_ALL)
5b3584c5a7c3 [hooks control] test and fix session.reset_hooks_mode_categories, closes #1908680
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7730
diff changeset
    78
                self.assertEqual(session.disabled_hook_categories, set(('integrity',)))
5b3584c5a7c3 [hooks control] test and fix session.reset_hooks_mode_categories, closes #1908680
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7730
diff changeset
    79
                self.assertEqual(session.enabled_hook_categories, set(('metadata',))) # not changed in such case
5b3584c5a7c3 [hooks control] test and fix session.reset_hooks_mode_categories, closes #1908680
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7730
diff changeset
    80
            self.assertEqual(session.hooks_mode, session.HOOKS_DENY_ALL)
5b3584c5a7c3 [hooks control] test and fix session.reset_hooks_mode_categories, closes #1908680
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7730
diff changeset
    81
            self.assertEqual(session.disabled_hook_categories, set())
5b3584c5a7c3 [hooks control] test and fix session.reset_hooks_mode_categories, closes #1908680
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7730
diff changeset
    82
            self.assertEqual(session.enabled_hook_categories, set(('metadata',)))
7350
c2452cd57026 [session] enhance session's transaction storage handling to fix cases where commit/rollback is done while in the context of hooks_control/security_enabled managers. Closes #1412648: commit or rollback during postcreate reset hooks control state
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6340
diff changeset
    83
        # leaving context manager with no transaction running should reset the
7398
26695dd703d8 [repository api] definitly kill usage of word 'pool' to refer to connections set used by a session
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7364
diff changeset
    84
        # transaction local storage (and associated cnxset)
7350
c2452cd57026 [session] enhance session's transaction storage handling to fix cases where commit/rollback is done while in the context of hooks_control/security_enabled managers. Closes #1412648: commit or rollback during postcreate reset hooks control state
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6340
diff changeset
    85
        self.assertEqual(session._tx_data, {})
7398
26695dd703d8 [repository api] definitly kill usage of word 'pool' to refer to connections set used by a session
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7364
diff changeset
    86
        self.assertEqual(session.cnxset, None)
7757
5b3584c5a7c3 [hooks control] test and fix session.reset_hooks_mode_categories, closes #1908680
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7730
diff changeset
    87
        self.assertEqual(session.hooks_mode, session.HOOKS_ALLOW_ALL)
5b3584c5a7c3 [hooks control] test and fix session.reset_hooks_mode_categories, closes #1908680
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7730
diff changeset
    88
        self.assertEqual(session.disabled_hook_categories, set())
5b3584c5a7c3 [hooks control] test and fix session.reset_hooks_mode_categories, closes #1908680
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7730
diff changeset
    89
        self.assertEqual(session.enabled_hook_categories, set())
7350
c2452cd57026 [session] enhance session's transaction storage handling to fix cases where commit/rollback is done while in the context of hooks_control/security_enabled managers. Closes #1412648: commit or rollback during postcreate reset hooks control state
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6340
diff changeset
    90
7969
d43569aaf5d6 [rset] don't only consider a sample select node / solution to compute rset description. Closes #2036499
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7757
diff changeset
    91
    def test_build_descr1(self):
7730
8d0edec31aaf [querier] we should not insert None but skip the line when some unknown eid is detected (closes #1892491)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7398
diff changeset
    92
        rset = self.execute('(Any U,L WHERE U login L) UNION (Any G,N WHERE G name N, G is CWGroup)')
8d0edec31aaf [querier] we should not insert None but skip the line when some unknown eid is detected (closes #1892491)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7398
diff changeset
    93
        orig_length = len(rset)
8d0edec31aaf [querier] we should not insert None but skip the line when some unknown eid is detected (closes #1892491)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7398
diff changeset
    94
        rset.rows[0][0] = 9999999
8d0edec31aaf [querier] we should not insert None but skip the line when some unknown eid is detected (closes #1892491)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7398
diff changeset
    95
        description = self.session.build_description(rset.syntax_tree(), None, rset.rows)
8d0edec31aaf [querier] we should not insert None but skip the line when some unknown eid is detected (closes #1892491)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7398
diff changeset
    96
        self.assertEqual(len(description), orig_length - 1)
8d0edec31aaf [querier] we should not insert None but skip the line when some unknown eid is detected (closes #1892491)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7398
diff changeset
    97
        self.assertEqual(len(rset.rows), orig_length - 1)
7791
31bb51ea5485 [deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7757
diff changeset
    98
        self.assertFalse(rset.rows[0][0] == 9999999)
7730
8d0edec31aaf [querier] we should not insert None but skip the line when some unknown eid is detected (closes #1892491)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7398
diff changeset
    99
7969
d43569aaf5d6 [rset] don't only consider a sample select node / solution to compute rset description. Closes #2036499
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7757
diff changeset
   100
    def test_build_descr2(self):
d43569aaf5d6 [rset] don't only consider a sample select node / solution to compute rset description. Closes #2036499
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7757
diff changeset
   101
        rset = self.execute('Any X,Y WITH X,Y BEING ((Any G,NULL WHERE G is CWGroup) UNION (Any U,G WHERE U in_group G))')
d43569aaf5d6 [rset] don't only consider a sample select node / solution to compute rset description. Closes #2036499
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7757
diff changeset
   102
        for x, y in rset.description:
d43569aaf5d6 [rset] don't only consider a sample select node / solution to compute rset description. Closes #2036499
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7757
diff changeset
   103
            if y is not None:
d43569aaf5d6 [rset] don't only consider a sample select node / solution to compute rset description. Closes #2036499
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7757
diff changeset
   104
                self.assertEqual(y, 'CWGroup')
d43569aaf5d6 [rset] don't only consider a sample select node / solution to compute rset description. Closes #2036499
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7757
diff changeset
   105
d43569aaf5d6 [rset] don't only consider a sample select node / solution to compute rset description. Closes #2036499
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7757
diff changeset
   106
    def test_build_descr3(self):
d43569aaf5d6 [rset] don't only consider a sample select node / solution to compute rset description. Closes #2036499
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7757
diff changeset
   107
        rset = self.execute('(Any G,NULL WHERE G is CWGroup) UNION (Any U,G WHERE U in_group G)')
d43569aaf5d6 [rset] don't only consider a sample select node / solution to compute rset description. Closes #2036499
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7757
diff changeset
   108
        for x, y in rset.description:
d43569aaf5d6 [rset] don't only consider a sample select node / solution to compute rset description. Closes #2036499
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7757
diff changeset
   109
            if y is not None:
d43569aaf5d6 [rset] don't only consider a sample select node / solution to compute rset description. Closes #2036499
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7757
diff changeset
   110
                self.assertEqual(y, 'CWGroup')
d43569aaf5d6 [rset] don't only consider a sample select node / solution to compute rset description. Closes #2036499
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7757
diff changeset
   111
7730
8d0edec31aaf [querier] we should not insert None but skip the line when some unknown eid is detected (closes #1892491)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7398
diff changeset
   112
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   113
if __name__ == '__main__':
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   114
    unittest_main()