author | David Douard <david.douard@logilab.fr> |
Mon, 29 Jul 2013 14:22:40 +0200 | |
branch | stable |
changeset 9193 | eaa58d1c7d5f |
parent 8675 | b60329e40e26 |
child 9043 | 97c3bb9a7c99 |
permissions | -rw-r--r-- |
8544
3d049071957e
massive copyright update to avoid clutering later patches
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8289
diff
changeset
|
1 |
# copyright 2003-2012 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/>. |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
18 |
|
1016
26387b836099
use datetime instead of mx.DateTime
sylvain.thenault@logilab.fr
parents:
520
diff
changeset
|
19 |
from datetime import datetime, timedelta |
6944
0cf10429ad39
[sources] rewrite the way pyrorql mapping are stored in the database so it can be reused for other sources (eg datafeed+cwxml)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6783
diff
changeset
|
20 |
from itertools import repeat |
1016
26387b836099
use datetime instead of mx.DateTime
sylvain.thenault@logilab.fr
parents:
520
diff
changeset
|
21 |
|
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
22 |
from cubicweb.devtools import TestServerConfiguration, init_test_database |
7078
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
23 |
from cubicweb.devtools.testlib import CubicWebTC, Tags |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
24 |
from cubicweb.devtools.repotest import do_monkey_patch, undo_monkey_patch |
7078
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
25 |
from cubicweb.devtools import get_test_db_handler |
2072
8008e8812d76
deactivate sqlite connection wrapping for unittest_multisources for now
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
26 |
|
519
06390418cd9a
pyrorql source now ignore external eids which are themselves coming from another external source already in use by the repository (should have the same uri)
sylvain.thenault@logilab.fr
parents:
342
diff
changeset
|
27 |
class ExternalSource1Configuration(TestServerConfiguration): |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
28 |
sourcefile = 'sources_extern' |
1786
eccd1885d42e
one more msplanning bug fixed...
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
29 |
|
519
06390418cd9a
pyrorql source now ignore external eids which are themselves coming from another external source already in use by the repository (should have the same uri)
sylvain.thenault@logilab.fr
parents:
342
diff
changeset
|
30 |
class ExternalSource2Configuration(TestServerConfiguration): |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
31 |
sourcefile = 'sources_multi' |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
32 |
|
7975
6ea7378b2c14
[test] fix test failure caused by 7922:d307c3817782
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7771
diff
changeset
|
33 |
MTIME = datetime.utcnow() - timedelta(0, 10) |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
34 |
|
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
35 |
EXTERN_SOURCE_CFG = u''' |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
36 |
cubicweb-user = admin |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
37 |
cubicweb-password = gingkow |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
38 |
base-url=http://extern.org/ |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
39 |
''' |
519
06390418cd9a
pyrorql source now ignore external eids which are themselves coming from another external source already in use by the repository (should have the same uri)
sylvain.thenault@logilab.fr
parents:
342
diff
changeset
|
40 |
|
4691
ae468fae9965
[test] fix test inter-dependancies pb. Pytest ok in each individual test dir, though not yet for whole cubicweb, but for different reasons
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
41 |
# hi-jacking |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
42 |
from cubicweb.server.sources.pyrorql import PyroRQLSource |
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
43 |
from cubicweb.dbapi import Connection |
4691
ae468fae9965
[test] fix test inter-dependancies pb. Pytest ok in each individual test dir, though not yet for whole cubicweb, but for different reasons
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
44 |
|
ae468fae9965
[test] fix test inter-dependancies pb. Pytest ok in each individual test dir, though not yet for whole cubicweb, but for different reasons
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
45 |
PyroRQLSource_get_connection = PyroRQLSource.get_connection |
ae468fae9965
[test] fix test inter-dependancies pb. Pytest ok in each individual test dir, though not yet for whole cubicweb, but for different reasons
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
46 |
Connection_close = Connection.close |
ae468fae9965
[test] fix test inter-dependancies pb. Pytest ok in each individual test dir, though not yet for whole cubicweb, but for different reasons
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
47 |
|
6724
24bf6f181d0e
[pyro source] store pyro source mapping file into the database
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6631
diff
changeset
|
48 |
def add_extern_mapping(source): |
6944
0cf10429ad39
[sources] rewrite the way pyrorql mapping are stored in the database so it can be reused for other sources (eg datafeed+cwxml)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6783
diff
changeset
|
49 |
source.init_mapping(zip(('Card', 'Affaire', 'State', |
0cf10429ad39
[sources] rewrite the way pyrorql mapping are stored in the database so it can be reused for other sources (eg datafeed+cwxml)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6783
diff
changeset
|
50 |
'in_state', 'documented_by', 'multisource_inlined_rel'), |
0cf10429ad39
[sources] rewrite the way pyrorql mapping are stored in the database so it can be reused for other sources (eg datafeed+cwxml)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6783
diff
changeset
|
51 |
repeat(u'write'))) |
6724
24bf6f181d0e
[pyro source] store pyro source mapping file into the database
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6631
diff
changeset
|
52 |
|
24bf6f181d0e
[pyro source] store pyro source mapping file into the database
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6631
diff
changeset
|
53 |
|
7078
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
54 |
def pre_setup_database_extern(session, config): |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
55 |
session.execute('INSERT Card X: X title "C3: An external card", X wikiid "aaa"') |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
56 |
session.execute('INSERT Card X: X title "C4: Ze external card", X wikiid "zzz"') |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
57 |
session.execute('INSERT Affaire X: X ref "AFFREF"') |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
58 |
session.commit() |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
59 |
|
7078
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
60 |
def pre_setup_database_multi(session, config): |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
61 |
session.create_entity('CWSource', name=u'extern', type=u'pyrorql', |
8675
b60329e40e26
[rql sources] uses an URL as remote host address for pyro/zmq rql sources,
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8544
diff
changeset
|
62 |
url=u'pyro:///extern', config=EXTERN_SOURCE_CFG) |
7078
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
63 |
session.commit() |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
64 |
|
8675
b60329e40e26
[rql sources] uses an URL as remote host address for pyro/zmq rql sources,
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8544
diff
changeset
|
65 |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
66 |
class TwoSourcesTC(CubicWebTC): |
6758
28b11ecf319b
[ms] #1382452: incorrect results with multi-sources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6631
diff
changeset
|
67 |
"""Main repo -> extern-multi -> extern |
28b11ecf319b
[ms] #1382452: incorrect results with multi-sources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6631
diff
changeset
|
68 |
\-------------/ |
28b11ecf319b
[ms] #1382452: incorrect results with multi-sources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6631
diff
changeset
|
69 |
""" |
7078
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
70 |
test_db_id= 'cw-server-multisources' |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
71 |
tags = CubicWebTC.tags | Tags(('multisources')) |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
72 |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
73 |
@classmethod |
7078
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
74 |
def setUpClass(cls): |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
75 |
cls._cfg2 = ExternalSource1Configuration('data', apphome=TwoSourcesTC.datadir) |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
76 |
cls._cfg3 = ExternalSource2Configuration('data', apphome=TwoSourcesTC.datadir) |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
77 |
TestServerConfiguration.no_sqlite_wrap = True |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
78 |
# hi-jack PyroRQLSource.get_connection to access existing connection (no |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
79 |
# pyro connection) |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
80 |
PyroRQLSource.get_connection = lambda x: x.uri == 'extern-multi' and cls.cnx3 or cls.cnx2 |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
81 |
# also necessary since the repository is closing its initial connections |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
82 |
# pool though we want to keep cnx2 valid |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
83 |
Connection.close = lambda x: None |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
84 |
|
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
85 |
@classmethod |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
86 |
def tearDowncls(cls): |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
87 |
PyroRQLSource.get_connection = PyroRQLSource_get_connection |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
88 |
Connection.close = Connection_close |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
89 |
cls.cnx2.close() |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
90 |
cls.cnx3.close() |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
91 |
TestServerConfiguration.no_sqlite_wrap = False |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
92 |
|
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
93 |
@classmethod |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
94 |
def _init_repo(cls): |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
95 |
repo2_handler = get_test_db_handler(cls._cfg2) |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
96 |
repo2_handler.build_db_cache('4cards-1affaire',pre_setup_func=pre_setup_database_extern) |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
97 |
cls.repo2, cls.cnx2 = repo2_handler.get_repo_and_cnx('4cards-1affaire') |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
98 |
|
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
99 |
repo3_handler = get_test_db_handler(cls._cfg3) |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
100 |
repo3_handler.build_db_cache('multisource',pre_setup_func=pre_setup_database_multi) |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
101 |
cls.repo3, cls.cnx3 = repo3_handler.get_repo_and_cnx('multisource') |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
102 |
|
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
103 |
|
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
104 |
super(TwoSourcesTC, cls)._init_repo() |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
105 |
|
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
106 |
def setUp(self): |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
107 |
CubicWebTC.setUp(self) |
7078
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
108 |
self.addCleanup(self.cnx2.close) |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
109 |
self.addCleanup(self.cnx3.close) |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
110 |
do_monkey_patch() |
1786
eccd1885d42e
one more msplanning bug fixed...
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
111 |
|
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
112 |
def tearDown(self): |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
113 |
for source in self.repo.sources[1:]: |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
114 |
self.repo.remove_source(source.uri) |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
115 |
CubicWebTC.tearDown(self) |
7078
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
116 |
self.cnx2.close() |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
117 |
self.cnx3.close() |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
118 |
undo_monkey_patch() |
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
119 |
|
7078
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
120 |
@staticmethod |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
121 |
def pre_setup_database(session, config): |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
122 |
for uri, src_config in [('extern', EXTERN_SOURCE_CFG), |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
123 |
('extern-multi', ''' |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
124 |
cubicweb-user = admin |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
125 |
cubicweb-password = gingkow |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
126 |
''')]: |
7088
76e0dba5f8f3
merge old stable into stable
Pierre-Yves David <pierre-yves.david@logilab.fr>
diff
changeset
|
127 |
source = session.create_entity('CWSource', name=unicode(uri), |
8675
b60329e40e26
[rql sources] uses an URL as remote host address for pyro/zmq rql sources,
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8544
diff
changeset
|
128 |
type=u'pyrorql', url=u'pyro:///extern-multi', |
7088
76e0dba5f8f3
merge old stable into stable
Pierre-Yves David <pierre-yves.david@logilab.fr>
diff
changeset
|
129 |
config=unicode(src_config)) |
76e0dba5f8f3
merge old stable into stable
Pierre-Yves David <pierre-yves.david@logilab.fr>
diff
changeset
|
130 |
session.commit() |
6724
24bf6f181d0e
[pyro source] store pyro source mapping file into the database
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6631
diff
changeset
|
131 |
add_extern_mapping(source) |
7088
76e0dba5f8f3
merge old stable into stable
Pierre-Yves David <pierre-yves.david@logilab.fr>
diff
changeset
|
132 |
|
7078
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
133 |
session.commit() |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
134 |
# trigger discovery |
7078
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
135 |
session.execute('Card X') |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
136 |
session.execute('Affaire X') |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
137 |
session.execute('State X') |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
138 |
|
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
139 |
def setup_database(self): |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
140 |
cu2 = self.cnx2.cursor() |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
141 |
self.ec1 = cu2.execute('Any X WHERE X is Card, X title "C3: An external card", X wikiid "aaa"')[0][0] |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
142 |
self.aff1 = cu2.execute('Any X WHERE X is Affaire, X ref "AFFREF"')[0][0] |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
143 |
cu2.close() |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
144 |
# add some entities |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
145 |
self.ic1 = self.sexecute('INSERT Card X: X title "C1: An internal card", X wikiid "aaai"')[0][0] |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
146 |
self.ic2 = self.sexecute('INSERT Card X: X title "C2: Ze internal card", X wikiid "zzzi"')[0][0] |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
147 |
|
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
148 |
def test_eid_comp(self): |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
149 |
rset = self.sexecute('Card X WHERE X eid > 1') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
150 |
self.assertEqual(len(rset), 4) |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
151 |
rset = self.sexecute('Any X,T WHERE X title T, X eid > 1') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
152 |
self.assertEqual(len(rset), 4) |
1786
eccd1885d42e
one more msplanning bug fixed...
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
153 |
|
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
154 |
def test_metainformation(self): |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
155 |
rset = self.sexecute('Card X ORDERBY T WHERE X title T') |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
156 |
# 2 added to the system source, 2 added to the external source |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
157 |
self.assertEqual(len(rset), 4) |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
158 |
# since they are orderd by eid, we know the 3 first one is coming from the system source |
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
159 |
# and the others from external source |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
160 |
self.assertEqual(rset.get_entity(0, 0).cw_metainformation(), |
7631
4ac19f288149
[repo test] fix broken tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7088
diff
changeset
|
161 |
{'source': {'type': 'native', 'uri': 'system', 'use-cwuri-as-url': False}, |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
162 |
'type': u'Card', 'extid': None}) |
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
163 |
externent = rset.get_entity(3, 0) |
5557
1a534c596bff
[entity] continue cleanup of Entity/AnyEntity namespace
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5556
diff
changeset
|
164 |
metainf = externent.cw_metainformation() |
7631
4ac19f288149
[repo test] fix broken tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7088
diff
changeset
|
165 |
self.assertEqual(metainf['source'], {'type': 'pyrorql', 'base-url': 'http://extern.org/', 'uri': 'extern', 'use-cwuri-as-url': False}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
166 |
self.assertEqual(metainf['type'], 'Card') |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
167 |
self.assert_(metainf['extid']) |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
168 |
etype = self.sexecute('Any ETN WHERE X is ET, ET name ETN, X eid %(x)s', |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4766
diff
changeset
|
169 |
{'x': externent.eid})[0][0] |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
170 |
self.assertEqual(etype, 'Card') |
1786
eccd1885d42e
one more msplanning bug fixed...
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
171 |
|
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
172 |
def test_order_limit_offset(self): |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
173 |
rsetbase = self.sexecute('Any W,X ORDERBY W,X WHERE X wikiid W') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
174 |
self.assertEqual(len(rsetbase), 4) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
175 |
self.assertEqual(sorted(rsetbase.rows), rsetbase.rows) |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
176 |
rset = self.sexecute('Any W,X ORDERBY W,X LIMIT 2 OFFSET 2 WHERE X wikiid W') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
177 |
self.assertEqual(rset.rows, rsetbase.rows[2:4]) |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
178 |
|
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
179 |
def test_has_text(self): |
519
06390418cd9a
pyrorql source now ignore external eids which are themselves coming from another external source already in use by the repository (should have the same uri)
sylvain.thenault@logilab.fr
parents:
342
diff
changeset
|
180 |
self.repo.sources_by_uri['extern'].synchronize(MTIME) # in case fti_update has been run before |
7791
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7771
diff
changeset
|
181 |
self.assertTrue(self.sexecute('Any X WHERE X has_text "affref"')) |
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7771
diff
changeset
|
182 |
self.assertTrue(self.sexecute('Affaire X WHERE X has_text "affref"')) |
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7771
diff
changeset
|
183 |
self.assertTrue(self.sexecute('Any X ORDERBY FTIRANK(X) WHERE X has_text "affref"')) |
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7771
diff
changeset
|
184 |
self.assertTrue(self.sexecute('Affaire X ORDERBY FTIRANK(X) WHERE X has_text "affref"')) |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
185 |
|
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
186 |
def test_anon_has_text(self): |
519
06390418cd9a
pyrorql source now ignore external eids which are themselves coming from another external source already in use by the repository (should have the same uri)
sylvain.thenault@logilab.fr
parents:
342
diff
changeset
|
187 |
self.repo.sources_by_uri['extern'].synchronize(MTIME) # in case fti_update has been run before |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
188 |
self.sexecute('INSERT Affaire X: X ref "no readable card"')[0][0] |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
189 |
aff1 = self.sexecute('INSERT Affaire X: X ref "card"')[0][0] |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
190 |
# grant read access |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4766
diff
changeset
|
191 |
self.sexecute('SET X owned_by U WHERE X eid %(x)s, U login "anon"', {'x': aff1}) |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
192 |
self.commit() |
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
193 |
cnx = self.login('anon') |
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
194 |
cu = cnx.cursor() |
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
195 |
rset = cu.execute('Any X WHERE X has_text "card"') |
5768
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5655
diff
changeset
|
196 |
# 5: 4 card + 1 readable affaire |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
197 |
self.assertEqual(len(rset), 5, zip(rset.rows, rset.description)) |
5768
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5655
diff
changeset
|
198 |
rset = cu.execute('Any X ORDERBY FTIRANK(X) WHERE X has_text "card"') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
199 |
self.assertEqual(len(rset), 5, zip(rset.rows, rset.description)) |
6197
d8f0dce0b86d
[test] fixes to follow recent changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5768
diff
changeset
|
200 |
Connection_close(cnx.cnx) # cnx is a TestCaseConnectionProxy |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
201 |
|
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
202 |
def test_synchronization(self): |
7078
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
203 |
cu = self.cnx2.cursor() |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4766
diff
changeset
|
204 |
assert cu.execute('Any X WHERE X eid %(x)s', {'x': self.aff1}) |
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4766
diff
changeset
|
205 |
cu.execute('SET X ref "BLAH" WHERE X eid %(x)s', {'x': self.aff1}) |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
206 |
aff2 = cu.execute('INSERT Affaire X: X ref "AFFREUX"')[0][0] |
7078
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
207 |
self.cnx2.commit() |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
208 |
try: |
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
209 |
# force sync |
519
06390418cd9a
pyrorql source now ignore external eids which are themselves coming from another external source already in use by the repository (should have the same uri)
sylvain.thenault@logilab.fr
parents:
342
diff
changeset
|
210 |
self.repo.sources_by_uri['extern'].synchronize(MTIME) |
7791
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7771
diff
changeset
|
211 |
self.assertTrue(self.sexecute('Any X WHERE X has_text "blah"')) |
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7771
diff
changeset
|
212 |
self.assertTrue(self.sexecute('Any X WHERE X has_text "affreux"')) |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
213 |
cu.execute('DELETE Affaire X WHERE X eid %(x)s', {'x': aff2}) |
7078
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
214 |
self.cnx2.commit() |
519
06390418cd9a
pyrorql source now ignore external eids which are themselves coming from another external source already in use by the repository (should have the same uri)
sylvain.thenault@logilab.fr
parents:
342
diff
changeset
|
215 |
self.repo.sources_by_uri['extern'].synchronize(MTIME) |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
216 |
rset = self.sexecute('Any X WHERE X has_text "affreux"') |
7791
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7771
diff
changeset
|
217 |
self.assertFalse(rset) |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
218 |
finally: |
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
219 |
# restore state |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4766
diff
changeset
|
220 |
cu.execute('SET X ref "AFFREF" WHERE X eid %(x)s', {'x': self.aff1}) |
7078
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
221 |
self.cnx2.commit() |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
222 |
|
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
223 |
def test_simplifiable_var(self): |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
224 |
affeid = self.sexecute('Affaire X WHERE X ref "AFFREF"')[0][0] |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
225 |
rset = self.sexecute('Any X,AA,AB WHERE E eid %(x)s, E in_state X, X name AA, X modification_date AB', |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4766
diff
changeset
|
226 |
{'x': affeid}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
227 |
self.assertEqual(len(rset), 1) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
228 |
self.assertEqual(rset[0][1], "pitetre") |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
229 |
|
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
230 |
def test_simplifiable_var_2(self): |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
231 |
affeid = self.sexecute('Affaire X WHERE X ref "AFFREF"')[0][0] |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
232 |
rset = self.sexecute('Any E WHERE E eid %(x)s, E in_state S, NOT S name "moved"', |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
233 |
{'x': affeid, 'u': self.session.user.eid}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
234 |
self.assertEqual(len(rset), 1) |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
235 |
|
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
236 |
def test_sort_func(self): |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
237 |
self.sexecute('Affaire X ORDERBY DUMB_SORT(RF) WHERE X ref RF') |
1786
eccd1885d42e
one more msplanning bug fixed...
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
238 |
|
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
239 |
def test_sort_func_ambigous(self): |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
240 |
self.sexecute('Any X ORDERBY DUMB_SORT(RF) WHERE X title RF') |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
241 |
|
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
242 |
def test_in_eid(self): |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
243 |
iec1 = self.repo.extid2eid(self.repo.sources_by_uri['extern'], str(self.ec1), |
519
06390418cd9a
pyrorql source now ignore external eids which are themselves coming from another external source already in use by the repository (should have the same uri)
sylvain.thenault@logilab.fr
parents:
342
diff
changeset
|
244 |
'Card', self.session) |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
245 |
rset = self.sexecute('Any X WHERE X eid IN (%s, %s)' % (iec1, self.ic1)) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
246 |
self.assertEqual(sorted(r[0] for r in rset.rows), sorted([iec1, self.ic1])) |
1786
eccd1885d42e
one more msplanning bug fixed...
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
247 |
|
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
248 |
def test_greater_eid(self): |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
249 |
rset = self.sexecute('Any X WHERE X eid > %s' % (self.ic1 - 1)) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
250 |
self.assertEqual(len(rset.rows), 2) # self.ic1 and self.ic2 |
7078
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
251 |
cu = self.cnx2.cursor() |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
252 |
ec2 = cu.execute('INSERT Card X: X title "glup"')[0][0] |
7078
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
253 |
self.cnx2.commit() |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
254 |
# 'X eid > something' should not trigger discovery |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
255 |
rset = self.sexecute('Any X WHERE X eid > %s' % (self.ic1 - 1)) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
256 |
self.assertEqual(len(rset.rows), 2) |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
257 |
# trigger discovery using another query |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
258 |
crset = self.sexecute('Card X WHERE X title "glup"') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
259 |
self.assertEqual(len(crset.rows), 1) |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
260 |
rset = self.sexecute('Any X WHERE X eid > %s' % (self.ic1 - 1)) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
261 |
self.assertEqual(len(rset.rows), 3) |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
262 |
rset = self.sexecute('Any MAX(X)') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
263 |
self.assertEqual(len(rset.rows), 1) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
264 |
self.assertEqual(rset.rows[0][0], crset[0][0]) |
1786
eccd1885d42e
one more msplanning bug fixed...
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
265 |
|
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
266 |
def test_attr_unification_1(self): |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
267 |
n1 = self.sexecute('INSERT Note X: X type "AFFREF"')[0][0] |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
268 |
n2 = self.sexecute('INSERT Note X: X type "AFFREU"')[0][0] |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
269 |
rset = self.sexecute('Any X,Y WHERE X is Note, Y is Affaire, X type T, Y ref T') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
270 |
self.assertEqual(len(rset), 1, rset.rows) |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
271 |
|
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
272 |
def test_attr_unification_2(self): |
7078
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
273 |
cu = self.cnx2.cursor() |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
274 |
ec2 = cu.execute('INSERT Card X: X title "AFFREF"')[0][0] |
7078
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
275 |
self.cnx2.commit() |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
276 |
try: |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
277 |
c1 = self.sexecute('INSERT Card C: C title "AFFREF"')[0][0] |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
278 |
rset = self.sexecute('Any X,Y WHERE X is Card, Y is Affaire, X title T, Y ref T') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
279 |
self.assertEqual(len(rset), 2, rset.rows) |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
280 |
finally: |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4766
diff
changeset
|
281 |
cu.execute('DELETE Card X WHERE X eid %(x)s', {'x': ec2}) |
7078
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
282 |
self.cnx2.commit() |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
283 |
|
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
284 |
def test_attr_unification_neq_1(self): |
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
285 |
# XXX complete |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
286 |
self.sexecute('Any X,Y WHERE X is Note, Y is Affaire, X creation_date D, Y creation_date > D') |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
287 |
|
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
288 |
def test_attr_unification_neq_2(self): |
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
289 |
# XXX complete |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
290 |
self.sexecute('Any X,Y WHERE X is Card, Y is Affaire, X creation_date D, Y creation_date > D') |
1786
eccd1885d42e
one more msplanning bug fixed...
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
291 |
|
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
292 |
def test_union(self): |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
293 |
afeids = self.sexecute('Affaire X') |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
294 |
ueids = self.sexecute('CWUser X') |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
295 |
rset = self.sexecute('(Any X WHERE X is Affaire) UNION (Any X WHERE X is CWUser)') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
296 |
self.assertEqual(sorted(r[0] for r in rset.rows), |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
297 |
sorted(r[0] for r in afeids + ueids)) |
1786
eccd1885d42e
one more msplanning bug fixed...
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
298 |
|
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
299 |
def test_subquery1(self): |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
300 |
rsetbase = self.sexecute('Any W,X WITH W,X BEING (Any W,X ORDERBY W,X WHERE X wikiid W)') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
301 |
self.assertEqual(len(rsetbase), 4) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
302 |
self.assertEqual(sorted(rsetbase.rows), rsetbase.rows) |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
303 |
rset = self.sexecute('Any W,X LIMIT 2 OFFSET 2 WITH W,X BEING (Any W,X ORDERBY W,X WHERE X wikiid W)') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
304 |
self.assertEqual(rset.rows, rsetbase.rows[2:4]) |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
305 |
rset = self.sexecute('Any W,X ORDERBY W,X LIMIT 2 OFFSET 2 WITH W,X BEING (Any W,X WHERE X wikiid W)') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
306 |
self.assertEqual(rset.rows, rsetbase.rows[2:4]) |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
307 |
rset = self.sexecute('Any W,X WITH W,X BEING (Any W,X ORDERBY W,X LIMIT 2 OFFSET 2 WHERE X wikiid W)') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
308 |
self.assertEqual(rset.rows, rsetbase.rows[2:4]) |
1786
eccd1885d42e
one more msplanning bug fixed...
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
309 |
|
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
310 |
def test_subquery2(self): |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
311 |
affeid = self.sexecute('Affaire X WHERE X ref "AFFREF"')[0][0] |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
312 |
rset = self.sexecute('Any X,AA,AB WITH X,AA,AB BEING (Any X,AA,AB WHERE E eid %(x)s, E in_state X, X name AA, X modification_date AB)', |
1786
eccd1885d42e
one more msplanning bug fixed...
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
313 |
{'x': affeid}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
314 |
self.assertEqual(len(rset), 1) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
315 |
self.assertEqual(rset[0][1], "pitetre") |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
316 |
|
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
317 |
def test_not_relation(self): |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
318 |
states = set(tuple(x) for x in self.sexecute('Any S,SN WHERE S is State, S name SN')) |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
319 |
userstate = self.session.user.in_state[0] |
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
320 |
states.remove((userstate.eid, userstate.name)) |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
321 |
notstates = set(tuple(x) for x in self.sexecute('Any S,SN WHERE S is State, S name SN, NOT X in_state S, X eid %(x)s', |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4766
diff
changeset
|
322 |
{'x': self.session.user.eid})) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
323 |
self.assertSetEqual(notstates, states) |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
324 |
aff1 = self.sexecute('Any X WHERE X is Affaire, X ref "AFFREF"')[0][0] |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4766
diff
changeset
|
325 |
aff1stateeid, aff1statename = self.sexecute('Any S,SN WHERE X eid %(x)s, X in_state S, S name SN', {'x': aff1})[0] |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
326 |
self.assertEqual(aff1statename, 'pitetre') |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
327 |
states.add((userstate.eid, userstate.name)) |
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
328 |
states.remove((aff1stateeid, aff1statename)) |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
329 |
notstates = set(tuple(x) for x in self.sexecute('Any S,SN WHERE S is State, S name SN, NOT X in_state S, X eid %(x)s', |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4766
diff
changeset
|
330 |
{'x': aff1})) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
331 |
self.assertSetEqual(notstates, states) |
1786
eccd1885d42e
one more msplanning bug fixed...
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
332 |
|
1840
f4b5c15d1147
test and fix #342997: local eid used for absolute_url of external entities
sylvain.thenault@logilab.fr
parents:
1786
diff
changeset
|
333 |
def test_absolute_url_base_url(self): |
7078
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
334 |
cu = self.cnx2.cursor() |
1840
f4b5c15d1147
test and fix #342997: local eid used for absolute_url of external entities
sylvain.thenault@logilab.fr
parents:
1786
diff
changeset
|
335 |
ceid = cu.execute('INSERT Card X: X title "without wikiid to get eid based url"')[0][0] |
7078
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
336 |
self.cnx2.commit() |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
337 |
lc = self.sexecute('Card X WHERE X title "without wikiid to get eid based url"').get_entity(0, 0) |
8289
c17d855bd95b
[repo test] fix test regression introduced by 8286:8b0146e31baa
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7979
diff
changeset
|
338 |
self.assertEqual(lc.absolute_url(), 'http://extern.org/%s' % ceid) |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
339 |
cu.execute('DELETE Card X WHERE X eid %(x)s', {'x':ceid}) |
7078
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
340 |
self.cnx2.commit() |
1840
f4b5c15d1147
test and fix #342997: local eid used for absolute_url of external entities
sylvain.thenault@logilab.fr
parents:
1786
diff
changeset
|
341 |
|
f4b5c15d1147
test and fix #342997: local eid used for absolute_url of external entities
sylvain.thenault@logilab.fr
parents:
1786
diff
changeset
|
342 |
def test_absolute_url_no_base_url(self): |
7078
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
343 |
cu = self.cnx3.cursor() |
1840
f4b5c15d1147
test and fix #342997: local eid used for absolute_url of external entities
sylvain.thenault@logilab.fr
parents:
1786
diff
changeset
|
344 |
ceid = cu.execute('INSERT Card X: X title "without wikiid to get eid based url"')[0][0] |
7078
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
345 |
self.cnx3.commit() |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
346 |
lc = self.sexecute('Card X WHERE X title "without wikiid to get eid based url"').get_entity(0, 0) |
8289
c17d855bd95b
[repo test] fix test regression introduced by 8286:8b0146e31baa
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7979
diff
changeset
|
347 |
self.assertEqual(lc.absolute_url(), 'http://testing.fr/cubicweb/%s' % lc.eid) |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
348 |
cu.execute('DELETE Card X WHERE X eid %(x)s', {'x':ceid}) |
7078
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6781
diff
changeset
|
349 |
self.cnx3.commit() |
1840
f4b5c15d1147
test and fix #342997: local eid used for absolute_url of external entities
sylvain.thenault@logilab.fr
parents:
1786
diff
changeset
|
350 |
|
6758
28b11ecf319b
[ms] #1382452: incorrect results with multi-sources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6631
diff
changeset
|
351 |
def test_crossed_relation_noeid_needattr(self): |
28b11ecf319b
[ms] #1382452: incorrect results with multi-sources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6631
diff
changeset
|
352 |
"""http://www.cubicweb.org/ticket/1382452""" |
28b11ecf319b
[ms] #1382452: incorrect results with multi-sources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6631
diff
changeset
|
353 |
aff1 = self.sexecute('INSERT Affaire X: X ref "AFFREF"')[0][0] |
28b11ecf319b
[ms] #1382452: incorrect results with multi-sources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6631
diff
changeset
|
354 |
# link within extern source |
28b11ecf319b
[ms] #1382452: incorrect results with multi-sources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6631
diff
changeset
|
355 |
ec1 = self.sexecute('Card X WHERE X wikiid "zzz"')[0][0] |
28b11ecf319b
[ms] #1382452: incorrect results with multi-sources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6631
diff
changeset
|
356 |
self.sexecute('SET A documented_by C WHERE E eid %(a)s, C eid %(c)s', |
28b11ecf319b
[ms] #1382452: incorrect results with multi-sources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6631
diff
changeset
|
357 |
{'a': aff1, 'c': ec1}) |
28b11ecf319b
[ms] #1382452: incorrect results with multi-sources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6631
diff
changeset
|
358 |
# link from system to extern source |
28b11ecf319b
[ms] #1382452: incorrect results with multi-sources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6631
diff
changeset
|
359 |
self.sexecute('SET A documented_by C WHERE E eid %(a)s, C eid %(c)s', |
28b11ecf319b
[ms] #1382452: incorrect results with multi-sources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6631
diff
changeset
|
360 |
{'a': aff1, 'c': self.ic2}) |
28b11ecf319b
[ms] #1382452: incorrect results with multi-sources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6631
diff
changeset
|
361 |
rset = self.sexecute('DISTINCT Any DEP WHERE P ref "AFFREF", P documented_by DEP, DEP wikiid LIKE "z%"') |
28b11ecf319b
[ms] #1382452: incorrect results with multi-sources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6631
diff
changeset
|
362 |
self.assertEqual(sorted(rset.rows), [[ec1], [self.ic2]]) |
28b11ecf319b
[ms] #1382452: incorrect results with multi-sources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6631
diff
changeset
|
363 |
|
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
364 |
def test_nonregr1(self): |
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
365 |
ueid = self.session.user.eid |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
366 |
affaire = self.sexecute('Affaire X WHERE X ref "AFFREF"').get_entity(0, 0) |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
367 |
self.sexecute('Any U WHERE U in_group G, (G name IN ("managers", "logilab") OR (X require_permission P?, P name "bla", P require_group G)), X eid %(x)s, U eid %(u)s', |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
368 |
{'x': affaire.eid, 'u': ueid}) |
1786
eccd1885d42e
one more msplanning bug fixed...
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
369 |
|
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
370 |
def test_nonregr2(self): |
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
371 |
iworkflowable = self.session.user.cw_adapt_to('IWorkflowable') |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
372 |
iworkflowable.fire_transition('deactivate') |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
373 |
treid = iworkflowable.latest_trinfo().eid |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
374 |
rset = self.sexecute('Any X ORDERBY D DESC WHERE E eid %(x)s, E wf_info_for X, X modification_date D', |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
375 |
{'x': treid}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
376 |
self.assertEqual(len(rset), 1) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6197
diff
changeset
|
377 |
self.assertEqual(rset.rows[0], [self.session.user.eid]) |
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
378 |
|
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
379 |
def test_nonregr3(self): |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2072
diff
changeset
|
380 |
self.sexecute('DELETE Card X WHERE X eid %(x)s, NOT X multisource_inlined_rel Y', {'x': self.ic1}) |
1786
eccd1885d42e
one more msplanning bug fixed...
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
381 |
|
7771
59ddc2dbe7e0
[multi-sources] closes #1918120: drop behaviour leading to wrong result as demonstrated by the ticket
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7650
diff
changeset
|
382 |
def test_nonregr4(self): |
59ddc2dbe7e0
[multi-sources] closes #1918120: drop behaviour leading to wrong result as demonstrated by the ticket
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7650
diff
changeset
|
383 |
self.sexecute('Any X,S,U WHERE X in_state S, X todo_by U') |
59ddc2dbe7e0
[multi-sources] closes #1918120: drop behaviour leading to wrong result as demonstrated by the ticket
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7650
diff
changeset
|
384 |
|
7650
278fe9c1f3ad
[repo] closes #1821172: fix source deletion
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7631
diff
changeset
|
385 |
def test_delete_source(self): |
278fe9c1f3ad
[repo] closes #1821172: fix source deletion
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7631
diff
changeset
|
386 |
req = self.request() |
278fe9c1f3ad
[repo] closes #1821172: fix source deletion
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7631
diff
changeset
|
387 |
req.execute('DELETE CWSource S WHERE S name "extern"') |
278fe9c1f3ad
[repo] closes #1821172: fix source deletion
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7631
diff
changeset
|
388 |
self.commit() |
278fe9c1f3ad
[repo] closes #1821172: fix source deletion
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7631
diff
changeset
|
389 |
cu = self.session.system_sql("SELECT * FROM entities WHERE source='extern'") |
7791
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7771
diff
changeset
|
390 |
self.assertFalse(cu.fetchall()) |
7650
278fe9c1f3ad
[repo] closes #1821172: fix source deletion
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7631
diff
changeset
|
391 |
|
342
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
392 |
if __name__ == '__main__': |
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
393 |
from logilab.common.testlib import unittest_main |
6becc066fc00
backport unittest_multisources from cubicweb-multisources
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
394 |
unittest_main() |