author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Tue, 09 Mar 2010 14:38:41 +0100 | |
changeset 4853 | 5dd4a9a46266 |
parent 4835 | 13b0b96d7982 |
child 4913 | 083b4d454192 |
permissions | -rw-r--r-- |
0 | 1 |
# -*- coding: iso-8859-1 -*- |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1954
diff
changeset
|
2 |
"""unit tests for module cubicweb.server.repository |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1954
diff
changeset
|
3 |
|
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1954
diff
changeset
|
4 |
:organization: Logilab |
4212
ab6573088b4a
update copyright: welcome 2010
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3771
diff
changeset
|
5 |
:copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1954
diff
changeset
|
6 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1954
diff
changeset
|
7 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1954
diff
changeset
|
8 |
""" |
0 | 9 |
|
10 |
import os |
|
11 |
import sys |
|
12 |
import threading |
|
13 |
import time |
|
14 |
from copy import deepcopy |
|
1016
26387b836099
use datetime instead of mx.DateTime
sylvain.thenault@logilab.fr
parents:
17
diff
changeset
|
15 |
from datetime import datetime |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
17
diff
changeset
|
16 |
|
0 | 17 |
from logilab.common.testlib import TestCase, unittest_main |
18 |
||
19 |
from yams.constraints import UniqueConstraint |
|
20 |
||
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
21 |
from cubicweb import (BadConnectionId, RepositoryError, ValidationError, |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
22 |
UnknownEid, AuthenticationError) |
0 | 23 |
from cubicweb.schema import CubicWebSchema, RQLConstraint |
4766
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
24 |
from cubicweb.dbapi import connect, multiple_connections_unfix |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
25 |
from cubicweb.devtools.testlib import CubicWebTC |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
17
diff
changeset
|
26 |
from cubicweb.devtools.repotest import tuplify |
3445
32492e9e734b
update and simplify test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2968
diff
changeset
|
27 |
from cubicweb.server import repository, hook |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
17
diff
changeset
|
28 |
from cubicweb.server.sqlutils import SQL_PREFIX |
4806
4f12f59b1a13
[fti] refactor and fix full text indexation handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
29 |
from cubicweb.server.sources import native |
0 | 30 |
|
31 |
# start name server anyway, process will fail if already running |
|
32 |
os.system('pyro-ns >/dev/null 2>/dev/null &') |
|
33 |
||
34 |
||
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
35 |
class RepositoryTC(CubicWebTC): |
0 | 36 |
""" singleton providing access to a persistent storage for entities |
37 |
and relation |
|
38 |
""" |
|
1787 | 39 |
|
0 | 40 |
def test_fill_schema(self): |
4766
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
41 |
origshema = self.repo.schema |
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
42 |
try: |
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
43 |
self.repo.schema = CubicWebSchema(self.repo.config.appid) |
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
44 |
self.repo.config._cubes = None # avoid assertion error |
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
45 |
self.repo.config.repairing = True # avoid versions checking |
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
46 |
self.repo.fill_schema() |
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
47 |
table = SQL_PREFIX + 'CWEType' |
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
48 |
namecol = SQL_PREFIX + 'name' |
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
49 |
finalcol = SQL_PREFIX + 'final' |
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
50 |
self.session.set_pool() |
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
51 |
cu = self.session.system_sql('SELECT %s FROM %s WHERE %s is NULL' % ( |
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
52 |
namecol, table, finalcol)) |
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
53 |
self.assertEquals(cu.fetchall(), []) |
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
54 |
cu = self.session.system_sql('SELECT %s FROM %s WHERE %s=%%(final)s ORDER BY %s' |
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
55 |
% (namecol, table, finalcol, namecol), {'final': 'TRUE'}) |
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
56 |
self.assertEquals(cu.fetchall(), [(u'Boolean',), (u'Bytes',), |
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
57 |
(u'Date',), (u'Datetime',), |
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
58 |
(u'Decimal',),(u'Float',), |
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
59 |
(u'Int',), |
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
60 |
(u'Interval',), (u'Password',), |
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
61 |
(u'String',), (u'Time',)]) |
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
62 |
finally: |
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
63 |
self.repo.set_schema(origshema) |
1787 | 64 |
|
0 | 65 |
def test_schema_has_owner(self): |
66 |
repo = self.repo |
|
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
67 |
cnxid = repo.connect(self.admlogin, password=self.admpassword) |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
68 |
self.failIf(repo.execute(cnxid, 'CWEType X WHERE NOT X owned_by U')) |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
69 |
self.failIf(repo.execute(cnxid, 'CWRType X WHERE NOT X owned_by U')) |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
70 |
self.failIf(repo.execute(cnxid, 'CWAttribute X WHERE NOT X owned_by U')) |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
71 |
self.failIf(repo.execute(cnxid, 'CWRelation X WHERE NOT X owned_by U')) |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
72 |
self.failIf(repo.execute(cnxid, 'CWConstraint X WHERE NOT X owned_by U')) |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
73 |
self.failIf(repo.execute(cnxid, 'CWConstraintType X WHERE NOT X owned_by U')) |
1787 | 74 |
|
0 | 75 |
def test_connect(self): |
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
76 |
self.assert_(self.repo.connect(self.admlogin, password=self.admpassword)) |
0 | 77 |
self.assertRaises(AuthenticationError, |
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
78 |
self.repo.connect, self.admlogin, password='nimportnawak') |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
79 |
self.assertRaises(AuthenticationError, |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
80 |
self.repo.connect, self.admlogin, password=None) |
0 | 81 |
self.assertRaises(AuthenticationError, |
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
82 |
self.repo.connect, None, password=None) |
0 | 83 |
self.assertRaises(AuthenticationError, |
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
84 |
self.repo.connect, self.admlogin) |
0 | 85 |
self.assertRaises(AuthenticationError, |
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
86 |
self.repo.connect, None) |
1787 | 87 |
|
0 | 88 |
def test_execute(self): |
89 |
repo = self.repo |
|
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
90 |
cnxid = repo.connect(self.admlogin, password=self.admpassword) |
0 | 91 |
repo.execute(cnxid, 'Any X') |
92 |
repo.execute(cnxid, 'Any X where X is Personne') |
|
93 |
repo.execute(cnxid, 'Any X where X is Personne, X nom ~= "to"') |
|
94 |
repo.execute(cnxid, 'Any X WHERE X has_text %(text)s', {'text': u'\xe7a'}) |
|
95 |
repo.close(cnxid) |
|
1787 | 96 |
|
0 | 97 |
def test_login_upassword_accent(self): |
98 |
repo = self.repo |
|
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
99 |
cnxid = repo.connect(self.admlogin, password=self.admpassword) |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
100 |
repo.execute(cnxid, 'INSERT CWUser X: X login %(login)s, X upassword %(passwd)s, X in_group G WHERE G name "users"', |
0 | 101 |
{'login': u"barnab�", 'passwd': u"h�h�h�".encode('UTF8')}) |
102 |
repo.commit(cnxid) |
|
103 |
repo.close(cnxid) |
|
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
104 |
self.assert_(repo.connect(u"barnab�", password=u"h�h�h�".encode('UTF8'))) |
1787 | 105 |
|
0 | 106 |
def test_invalid_entity_rollback(self): |
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
107 |
cnxid = self.repo.connect(self.admlogin, password=self.admpassword) |
1787 | 108 |
# no group |
3771 | 109 |
self.repo.execute(cnxid, |
110 |
'INSERT CWUser X: X login %(login)s, X upassword %(passwd)s', |
|
111 |
{'login': u"tutetute", 'passwd': 'tutetute'}) |
|
112 |
self.assertRaises(ValidationError, self.repo.commit, cnxid) |
|
113 |
self.failIf(self.repo.execute(cnxid, 'CWUser X WHERE X login "tutetute"')) |
|
1787 | 114 |
|
0 | 115 |
def test_close(self): |
116 |
repo = self.repo |
|
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
117 |
cnxid = repo.connect(self.admlogin, password=self.admpassword) |
0 | 118 |
self.assert_(cnxid) |
119 |
repo.close(cnxid) |
|
120 |
self.assertRaises(BadConnectionId, repo.execute, cnxid, 'Any X') |
|
1787 | 121 |
|
0 | 122 |
def test_invalid_cnxid(self): |
123 |
self.assertRaises(BadConnectionId, self.repo.execute, 0, 'Any X') |
|
124 |
self.assertRaises(BadConnectionId, self.repo.close, None) |
|
1787 | 125 |
|
0 | 126 |
def test_shared_data(self): |
127 |
repo = self.repo |
|
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
128 |
cnxid = repo.connect(self.admlogin, password=self.admpassword) |
0 | 129 |
repo.set_shared_data(cnxid, 'data', 4) |
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
130 |
cnxid2 = repo.connect(self.admlogin, password=self.admpassword) |
0 | 131 |
self.assertEquals(repo.get_shared_data(cnxid, 'data'), 4) |
132 |
self.assertEquals(repo.get_shared_data(cnxid2, 'data'), None) |
|
133 |
repo.set_shared_data(cnxid2, 'data', 5) |
|
134 |
self.assertEquals(repo.get_shared_data(cnxid, 'data'), 4) |
|
135 |
self.assertEquals(repo.get_shared_data(cnxid2, 'data'), 5) |
|
136 |
repo.get_shared_data(cnxid2, 'data', pop=True) |
|
137 |
self.assertEquals(repo.get_shared_data(cnxid, 'data'), 4) |
|
138 |
self.assertEquals(repo.get_shared_data(cnxid2, 'data'), None) |
|
139 |
repo.close(cnxid) |
|
140 |
repo.close(cnxid2) |
|
141 |
self.assertRaises(BadConnectionId, repo.get_shared_data, cnxid, 'data') |
|
142 |
self.assertRaises(BadConnectionId, repo.get_shared_data, cnxid2, 'data') |
|
143 |
self.assertRaises(BadConnectionId, repo.set_shared_data, cnxid, 'data', 1) |
|
144 |
self.assertRaises(BadConnectionId, repo.set_shared_data, cnxid2, 'data', 1) |
|
145 |
||
146 |
def test_check_session(self): |
|
147 |
repo = self.repo |
|
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
148 |
cnxid = repo.connect(self.admlogin, password=self.admpassword) |
0 | 149 |
self.assertEquals(repo.check_session(cnxid), None) |
150 |
repo.close(cnxid) |
|
151 |
self.assertRaises(BadConnectionId, repo.check_session, cnxid) |
|
152 |
||
153 |
def test_transaction_base(self): |
|
154 |
repo = self.repo |
|
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
155 |
cnxid = repo.connect(self.admlogin, password=self.admpassword) |
0 | 156 |
# check db state |
157 |
result = repo.execute(cnxid, 'Personne X') |
|
158 |
self.assertEquals(result.rowcount, 0) |
|
159 |
# rollback entity insertion |
|
160 |
repo.execute(cnxid, "INSERT Personne X: X nom 'bidule'") |
|
161 |
result = repo.execute(cnxid, 'Personne X') |
|
162 |
self.assertEquals(result.rowcount, 1) |
|
163 |
repo.rollback(cnxid) |
|
164 |
result = repo.execute(cnxid, 'Personne X') |
|
165 |
self.assertEquals(result.rowcount, 0, result.rows) |
|
166 |
# commit |
|
167 |
repo.execute(cnxid, "INSERT Personne X: X nom 'bidule'") |
|
168 |
repo.commit(cnxid) |
|
169 |
result = repo.execute(cnxid, 'Personne X') |
|
170 |
self.assertEquals(result.rowcount, 1) |
|
171 |
||
172 |
def test_transaction_base2(self): |
|
173 |
repo = self.repo |
|
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
174 |
cnxid = repo.connect(self.admlogin, password=self.admpassword) |
0 | 175 |
# rollback relation insertion |
176 |
repo.execute(cnxid, "SET U in_group G WHERE U login 'admin', G name 'guests'") |
|
177 |
result = repo.execute(cnxid, "Any U WHERE U in_group G, U login 'admin', G name 'guests'") |
|
178 |
self.assertEquals(result.rowcount, 1) |
|
179 |
repo.rollback(cnxid) |
|
180 |
result = repo.execute(cnxid, "Any U WHERE U in_group G, U login 'admin', G name 'guests'") |
|
181 |
self.assertEquals(result.rowcount, 0, result.rows) |
|
1787 | 182 |
|
0 | 183 |
def test_transaction_base3(self): |
184 |
repo = self.repo |
|
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
185 |
cnxid = repo.connect(self.admlogin, password=self.admpassword) |
0 | 186 |
# rollback state change which trigger TrInfo insertion |
4835
13b0b96d7982
[repo] enhanced security handling: deprecates unsafe_execute, in favor of explicit read/write security control using the `enabled_security` context manager. Also code executed on the repository side is now unsafe by default.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4808
diff
changeset
|
187 |
session = repo._get_session(cnxid) |
13b0b96d7982
[repo] enhanced security handling: deprecates unsafe_execute, in favor of explicit read/write security control using the `enabled_security` context manager. Also code executed on the repository side is now unsafe by default.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4808
diff
changeset
|
188 |
session.set_pool() |
13b0b96d7982
[repo] enhanced security handling: deprecates unsafe_execute, in favor of explicit read/write security control using the `enabled_security` context manager. Also code executed on the repository side is now unsafe by default.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4808
diff
changeset
|
189 |
user = session.user |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
190 |
user.fire_transition('deactivate') |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
191 |
rset = repo.execute(cnxid, 'TrInfo T WHERE T wf_info_for X, X eid %(x)s', {'x': user.eid}) |
0 | 192 |
self.assertEquals(len(rset), 1) |
193 |
repo.rollback(cnxid) |
|
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
194 |
rset = repo.execute(cnxid, 'TrInfo T WHERE T wf_info_for X, X eid %(x)s', {'x': user.eid}) |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
195 |
self.assertEquals(len(rset), 0) |
1787 | 196 |
|
0 | 197 |
def test_transaction_interleaved(self): |
198 |
self.skip('implement me') |
|
199 |
||
1880
293fe4b49e28
two in one: #343320: Logging out while deleting a CWUser blocks the cw server / #342692: ensure transaction state when Ctrl-C or other stop signal is received
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1787
diff
changeset
|
200 |
def test_close_wait_processing_request(self): |
293fe4b49e28
two in one: #343320: Logging out while deleting a CWUser blocks the cw server / #342692: ensure transaction state when Ctrl-C or other stop signal is received
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1787
diff
changeset
|
201 |
repo = self.repo |
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
202 |
cnxid = repo.connect(self.admlogin, password=self.admpassword) |
1880
293fe4b49e28
two in one: #343320: Logging out while deleting a CWUser blocks the cw server / #342692: ensure transaction state when Ctrl-C or other stop signal is received
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1787
diff
changeset
|
203 |
repo.execute(cnxid, 'INSERT CWUser X: X login "toto", X upassword "tutu", X in_group G WHERE G name "users"') |
293fe4b49e28
two in one: #343320: Logging out while deleting a CWUser blocks the cw server / #342692: ensure transaction state when Ctrl-C or other stop signal is received
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1787
diff
changeset
|
204 |
repo.commit(cnxid) |
293fe4b49e28
two in one: #343320: Logging out while deleting a CWUser blocks the cw server / #342692: ensure transaction state when Ctrl-C or other stop signal is received
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1787
diff
changeset
|
205 |
# close has to be in the thread due to sqlite limitations |
293fe4b49e28
two in one: #343320: Logging out while deleting a CWUser blocks the cw server / #342692: ensure transaction state when Ctrl-C or other stop signal is received
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1787
diff
changeset
|
206 |
def close_in_a_few_moment(): |
293fe4b49e28
two in one: #343320: Logging out while deleting a CWUser blocks the cw server / #342692: ensure transaction state when Ctrl-C or other stop signal is received
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1787
diff
changeset
|
207 |
time.sleep(0.1) |
293fe4b49e28
two in one: #343320: Logging out while deleting a CWUser blocks the cw server / #342692: ensure transaction state when Ctrl-C or other stop signal is received
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1787
diff
changeset
|
208 |
repo.close(cnxid) |
293fe4b49e28
two in one: #343320: Logging out while deleting a CWUser blocks the cw server / #342692: ensure transaction state when Ctrl-C or other stop signal is received
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1787
diff
changeset
|
209 |
t = threading.Thread(target=close_in_a_few_moment) |
293fe4b49e28
two in one: #343320: Logging out while deleting a CWUser blocks the cw server / #342692: ensure transaction state when Ctrl-C or other stop signal is received
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1787
diff
changeset
|
210 |
t.start() |
293fe4b49e28
two in one: #343320: Logging out while deleting a CWUser blocks the cw server / #342692: ensure transaction state when Ctrl-C or other stop signal is received
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1787
diff
changeset
|
211 |
try: |
293fe4b49e28
two in one: #343320: Logging out while deleting a CWUser blocks the cw server / #342692: ensure transaction state when Ctrl-C or other stop signal is received
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1787
diff
changeset
|
212 |
repo.execute(cnxid, 'DELETE CWUser X WHERE X login "toto"') |
293fe4b49e28
two in one: #343320: Logging out while deleting a CWUser blocks the cw server / #342692: ensure transaction state when Ctrl-C or other stop signal is received
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1787
diff
changeset
|
213 |
repo.commit(cnxid) |
293fe4b49e28
two in one: #343320: Logging out while deleting a CWUser blocks the cw server / #342692: ensure transaction state when Ctrl-C or other stop signal is received
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1787
diff
changeset
|
214 |
finally: |
293fe4b49e28
two in one: #343320: Logging out while deleting a CWUser blocks the cw server / #342692: ensure transaction state when Ctrl-C or other stop signal is received
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1787
diff
changeset
|
215 |
t.join() |
293fe4b49e28
two in one: #343320: Logging out while deleting a CWUser blocks the cw server / #342692: ensure transaction state when Ctrl-C or other stop signal is received
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1787
diff
changeset
|
216 |
|
0 | 217 |
def test_initial_schema(self): |
218 |
schema = self.repo.schema |
|
219 |
# check order of attributes is respected |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
220 |
self.assertListEquals([r.type for r in schema.eschema('CWAttribute').ordered_relations() |
1787 | 221 |
if not r.type in ('eid', 'is', 'is_instance_of', 'identity', |
2608
21856eda34f6
[F repo tests] tests have to be updated:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2588
diff
changeset
|
222 |
'creation_date', 'modification_date', 'cwuri', |
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
223 |
'owned_by', 'created_by', |
4680
8a6bee838464
[test] update tests broken by changes on attributes permissions handling in yams (add/delete replaced by update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
224 |
'update_permission', 'read_permission')], |
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
225 |
['relation_type', |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
226 |
'from_entity', 'to_entity', |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
227 |
'in_basket', 'constrained_by', |
1787 | 228 |
'cardinality', 'ordernum', |
0 | 229 |
'indexed', 'fulltextindexed', 'internationalizable', |
2608
21856eda34f6
[F repo tests] tests have to be updated:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2588
diff
changeset
|
230 |
'defaultval', 'description', 'description_format']) |
0 | 231 |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
232 |
self.assertEquals(schema.eschema('CWEType').main_attribute(), 'name') |
0 | 233 |
self.assertEquals(schema.eschema('State').main_attribute(), 'name') |
234 |
||
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
235 |
constraints = schema.rschema('name').rdef('CWEType', 'String').constraints |
0 | 236 |
self.assertEquals(len(constraints), 2) |
237 |
for cstr in constraints[:]: |
|
238 |
if isinstance(cstr, UniqueConstraint): |
|
239 |
constraints.remove(cstr) |
|
240 |
break |
|
241 |
else: |
|
242 |
self.fail('unique constraint not found') |
|
243 |
sizeconstraint = constraints[0] |
|
244 |
self.assertEquals(sizeconstraint.min, None) |
|
245 |
self.assertEquals(sizeconstraint.max, 64) |
|
246 |
||
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
247 |
constraints = schema.rschema('relation_type').rdef('CWAttribute', 'CWRType').constraints |
0 | 248 |
self.assertEquals(len(constraints), 1) |
249 |
cstr = constraints[0] |
|
250 |
self.assert_(isinstance(cstr, RQLConstraint)) |
|
251 |
self.assertEquals(cstr.restriction, 'O final TRUE') |
|
252 |
||
253 |
ownedby = schema.rschema('owned_by') |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
254 |
self.assertEquals(ownedby.objects('CWEType'), ('CWUser',)) |
0 | 255 |
|
256 |
def test_pyro(self): |
|
257 |
import Pyro |
|
258 |
Pyro.config.PYRO_MULTITHREADED = 0 |
|
1880
293fe4b49e28
two in one: #343320: Logging out while deleting a CWUser blocks the cw server / #342692: ensure transaction state when Ctrl-C or other stop signal is received
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1787
diff
changeset
|
259 |
done = [] |
0 | 260 |
# the client part has to be in the thread due to sqlite limitations |
1880
293fe4b49e28
two in one: #343320: Logging out while deleting a CWUser blocks the cw server / #342692: ensure transaction state when Ctrl-C or other stop signal is received
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1787
diff
changeset
|
261 |
t = threading.Thread(target=self._pyro_client, args=(done,)) |
0 | 262 |
try: |
263 |
daemon = self.repo.pyro_register() |
|
264 |
t.start() |
|
1880
293fe4b49e28
two in one: #343320: Logging out while deleting a CWUser blocks the cw server / #342692: ensure transaction state when Ctrl-C or other stop signal is received
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1787
diff
changeset
|
265 |
while not done: |
293fe4b49e28
two in one: #343320: Logging out while deleting a CWUser blocks the cw server / #342692: ensure transaction state when Ctrl-C or other stop signal is received
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1787
diff
changeset
|
266 |
daemon.handleRequests(1.0) |
293fe4b49e28
two in one: #343320: Logging out while deleting a CWUser blocks the cw server / #342692: ensure transaction state when Ctrl-C or other stop signal is received
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1787
diff
changeset
|
267 |
t.join(1) |
293fe4b49e28
two in one: #343320: Logging out while deleting a CWUser blocks the cw server / #342692: ensure transaction state when Ctrl-C or other stop signal is received
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1787
diff
changeset
|
268 |
if t.isAlive(): |
293fe4b49e28
two in one: #343320: Logging out while deleting a CWUser blocks the cw server / #342692: ensure transaction state when Ctrl-C or other stop signal is received
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1787
diff
changeset
|
269 |
self.fail('something went wrong, thread still alive') |
0 | 270 |
finally: |
271 |
repository.pyro_unregister(self.repo.config) |
|
4766
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
272 |
from logilab.common import pyro_ext |
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
273 |
pyro_ext._DAEMONS.clear() |
1787 | 274 |
|
1880
293fe4b49e28
two in one: #343320: Logging out while deleting a CWUser blocks the cw server / #342692: ensure transaction state when Ctrl-C or other stop signal is received
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1787
diff
changeset
|
275 |
def _pyro_client(self, done): |
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
276 |
cnx = connect(self.repo.config.appid, u'admin', password='gingkow') |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2642
diff
changeset
|
277 |
try: |
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2642
diff
changeset
|
278 |
# check we can get the schema |
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2642
diff
changeset
|
279 |
schema = cnx.get_schema() |
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2642
diff
changeset
|
280 |
self.assertEquals(schema.__hashmode__, None) |
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2642
diff
changeset
|
281 |
cu = cnx.cursor() |
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2642
diff
changeset
|
282 |
rset = cu.execute('Any U,G WHERE U in_group G') |
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2642
diff
changeset
|
283 |
cnx.close() |
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2642
diff
changeset
|
284 |
done.append(True) |
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2642
diff
changeset
|
285 |
finally: |
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2642
diff
changeset
|
286 |
# connect monkey path some method by default, remove them |
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2642
diff
changeset
|
287 |
multiple_connections_unfix() |
0 | 288 |
|
289 |
def test_internal_api(self): |
|
290 |
repo = self.repo |
|
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
291 |
cnxid = repo.connect(self.admlogin, password=self.admpassword) |
0 | 292 |
session = repo._get_session(cnxid, setpool=True) |
1954 | 293 |
self.assertEquals(repo.type_and_source_from_eid(1, session), |
294 |
('CWGroup', 'system', None)) |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
295 |
self.assertEquals(repo.type_from_eid(1, session), 'CWGroup') |
0 | 296 |
self.assertEquals(repo.source_from_eid(1, session).uri, 'system') |
297 |
self.assertEquals(repo.eid2extid(repo.system_source, 1, session), None) |
|
298 |
class dummysource: uri = 'toto' |
|
299 |
self.assertRaises(UnknownEid, repo.eid2extid, dummysource, 1, session) |
|
300 |
||
301 |
def test_public_api(self): |
|
302 |
self.assertEquals(self.repo.get_schema(), self.repo.schema) |
|
303 |
self.assertEquals(self.repo.source_defs(), {'system': {'adapter': 'native', 'uri': 'system'}}) |
|
304 |
# .properties() return a result set |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
305 |
self.assertEquals(self.repo.properties().rql, 'Any K,V WHERE P is CWProperty,P pkey K, P value V, NOT P for_user U') |
0 | 306 |
|
307 |
def test_session_api(self): |
|
308 |
repo = self.repo |
|
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
309 |
cnxid = repo.connect(self.admlogin, password=self.admpassword) |
0 | 310 |
self.assertEquals(repo.user_info(cnxid), (5, 'admin', set([u'managers']), {})) |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
311 |
self.assertEquals(repo.describe(cnxid, 1), (u'CWGroup', u'system', None)) |
0 | 312 |
repo.close(cnxid) |
313 |
self.assertRaises(BadConnectionId, repo.user_info, cnxid) |
|
314 |
self.assertRaises(BadConnectionId, repo.describe, cnxid, 1) |
|
315 |
||
316 |
def test_shared_data_api(self): |
|
317 |
repo = self.repo |
|
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
318 |
cnxid = repo.connect(self.admlogin, password=self.admpassword) |
0 | 319 |
self.assertEquals(repo.get_shared_data(cnxid, 'data'), None) |
320 |
repo.set_shared_data(cnxid, 'data', 4) |
|
321 |
self.assertEquals(repo.get_shared_data(cnxid, 'data'), 4) |
|
322 |
repo.get_shared_data(cnxid, 'data', pop=True) |
|
323 |
repo.get_shared_data(cnxid, 'whatever', pop=True) |
|
324 |
self.assertEquals(repo.get_shared_data(cnxid, 'data'), None) |
|
325 |
repo.close(cnxid) |
|
326 |
self.assertRaises(BadConnectionId, repo.set_shared_data, cnxid, 'data', 0) |
|
327 |
self.assertRaises(BadConnectionId, repo.get_shared_data, cnxid, 'data') |
|
1787 | 328 |
|
2588
3a590ff82e99
[F schema serial] #344876: missing some 'is'/'is_instance_of' relation for newly created instances
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2200
diff
changeset
|
329 |
def test_schema_is_relation(self): |
3a590ff82e99
[F schema serial] #344876: missing some 'is'/'is_instance_of' relation for newly created instances
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2200
diff
changeset
|
330 |
no_is_rset = self.execute('Any X WHERE NOT X is ET') |
3a590ff82e99
[F schema serial] #344876: missing some 'is'/'is_instance_of' relation for newly created instances
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2200
diff
changeset
|
331 |
self.failIf(no_is_rset, no_is_rset.description) |
3a590ff82e99
[F schema serial] #344876: missing some 'is'/'is_instance_of' relation for newly created instances
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2200
diff
changeset
|
332 |
|
2642 | 333 |
# def test_perfo(self): |
334 |
# self.set_debug(True) |
|
335 |
# from time import time, clock |
|
336 |
# t, c = time(), clock() |
|
337 |
# try: |
|
338 |
# self.create_user('toto') |
|
339 |
# finally: |
|
340 |
# self.set_debug(False) |
|
341 |
# print 'test time: %.3f (time) %.3f (cpu)' % ((time() - t), clock() - c) |
|
342 |
||
2923
b97a0f8dd4dc
fix test schema and update some tests to work again with wf changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
343 |
def test_delete_if_singlecard1(self): |
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
344 |
note = self.request().create_entity('Affaire') |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
345 |
p1 = self.request().create_entity('Personne', nom=u'toto') |
2923
b97a0f8dd4dc
fix test schema and update some tests to work again with wf changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
346 |
self.execute('SET A todo_by P WHERE A eid %(x)s, P eid %(p)s', |
b97a0f8dd4dc
fix test schema and update some tests to work again with wf changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
347 |
{'x': note.eid, 'p': p1.eid}) |
b97a0f8dd4dc
fix test schema and update some tests to work again with wf changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
348 |
rset = self.execute('Any P WHERE A todo_by P, A eid %(x)s', |
b97a0f8dd4dc
fix test schema and update some tests to work again with wf changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
349 |
{'x': note.eid}) |
b97a0f8dd4dc
fix test schema and update some tests to work again with wf changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
350 |
self.assertEquals(len(rset), 1) |
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
351 |
p2 = self.request().create_entity('Personne', nom=u'tutu') |
2923
b97a0f8dd4dc
fix test schema and update some tests to work again with wf changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
352 |
self.execute('SET A todo_by P WHERE A eid %(x)s, P eid %(p)s', |
b97a0f8dd4dc
fix test schema and update some tests to work again with wf changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
353 |
{'x': note.eid, 'p': p2.eid}) |
b97a0f8dd4dc
fix test schema and update some tests to work again with wf changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
354 |
rset = self.execute('Any P WHERE A todo_by P, A eid %(x)s', |
b97a0f8dd4dc
fix test schema and update some tests to work again with wf changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
355 |
{'x': note.eid}) |
b97a0f8dd4dc
fix test schema and update some tests to work again with wf changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
356 |
self.assertEquals(len(rset), 1) |
b97a0f8dd4dc
fix test schema and update some tests to work again with wf changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
357 |
self.assertEquals(rset.rows[0][0], p2.eid) |
b97a0f8dd4dc
fix test schema and update some tests to work again with wf changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
358 |
|
0 | 359 |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
360 |
class DataHelpersTC(CubicWebTC): |
1787 | 361 |
|
0 | 362 |
def test_create_eid(self): |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
363 |
self.session.set_pool() |
0 | 364 |
self.assert_(self.repo.system_source.create_eid(self.session)) |
365 |
||
366 |
def test_source_from_eid(self): |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
367 |
self.session.set_pool() |
0 | 368 |
self.assertEquals(self.repo.source_from_eid(1, self.session), |
369 |
self.repo.sources_by_uri['system']) |
|
370 |
||
371 |
def test_source_from_eid_raise(self): |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
372 |
self.session.set_pool() |
0 | 373 |
self.assertRaises(UnknownEid, self.repo.source_from_eid, -2, self.session) |
374 |
||
375 |
def test_type_from_eid(self): |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
376 |
self.session.set_pool() |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
377 |
self.assertEquals(self.repo.type_from_eid(1, self.session), 'CWGroup') |
1787 | 378 |
|
0 | 379 |
def test_type_from_eid_raise(self): |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
380 |
self.session.set_pool() |
0 | 381 |
self.assertRaises(UnknownEid, self.repo.type_from_eid, -2, self.session) |
1787 | 382 |
|
0 | 383 |
def test_add_delete_info(self): |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2642
diff
changeset
|
384 |
entity = self.repo.vreg['etypes'].etype_class('Personne')(self.session) |
0 | 385 |
entity.eid = -1 |
386 |
entity.complete = lambda x: None |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
387 |
self.session.set_pool() |
0 | 388 |
self.repo.add_info(self.session, entity, self.repo.sources_by_uri['system']) |
2200
25bb65dc4559
test fixes, all server tests ok, except unittest_migractions (due to inter-tests-side-effects...)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
389 |
cu = self.session.system_sql('SELECT * FROM entities WHERE eid = -1') |
25bb65dc4559
test fixes, all server tests ok, except unittest_migractions (due to inter-tests-side-effects...)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
390 |
data = cu.fetchall() |
1016
26387b836099
use datetime instead of mx.DateTime
sylvain.thenault@logilab.fr
parents:
17
diff
changeset
|
391 |
self.assertIsInstance(data[0][3], datetime) |
0 | 392 |
data[0] = list(data[0]) |
393 |
data[0][3] = None |
|
394 |
self.assertEquals(tuplify(data), [(-1, 'Personne', 'system', None, None)]) |
|
395 |
self.repo.delete_info(self.session, -1) |
|
396 |
#self.repo.commit() |
|
2200
25bb65dc4559
test fixes, all server tests ok, except unittest_migractions (due to inter-tests-side-effects...)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
397 |
cu = self.session.system_sql('SELECT * FROM entities WHERE eid = -1') |
25bb65dc4559
test fixes, all server tests ok, except unittest_migractions (due to inter-tests-side-effects...)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
398 |
data = cu.fetchall() |
0 | 399 |
self.assertEquals(data, []) |
400 |
||
401 |
||
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
402 |
class FTITC(CubicWebTC): |
1787 | 403 |
|
0 | 404 |
def test_reindex_and_modified_since(self): |
405 |
eidp = self.execute('INSERT Personne X: X nom "toto", X prenom "tutu"')[0][0] |
|
406 |
self.commit() |
|
1016
26387b836099
use datetime instead of mx.DateTime
sylvain.thenault@logilab.fr
parents:
17
diff
changeset
|
407 |
ts = datetime.now() |
0 | 408 |
self.assertEquals(len(self.execute('Personne X WHERE X has_text "tutu"')), 1) |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
409 |
self.session.set_pool() |
2200
25bb65dc4559
test fixes, all server tests ok, except unittest_migractions (due to inter-tests-side-effects...)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
410 |
cu = self.session.system_sql('SELECT mtime, eid FROM entities WHERE eid = %s' % eidp) |
25bb65dc4559
test fixes, all server tests ok, except unittest_migractions (due to inter-tests-side-effects...)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
411 |
omtime = cu.fetchone()[0] |
0 | 412 |
# our sqlite datetime adapter is ignore seconds fraction, so we have to |
413 |
# ensure update is done the next seconds |
|
414 |
time.sleep(1 - (ts.second - int(ts.second))) |
|
415 |
self.execute('SET X nom "tata" WHERE X eid %(x)s', {'x': eidp}, 'x') |
|
416 |
self.commit() |
|
417 |
self.assertEquals(len(self.execute('Personne X WHERE X has_text "tutu"')), 1) |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
418 |
self.session.set_pool() |
2200
25bb65dc4559
test fixes, all server tests ok, except unittest_migractions (due to inter-tests-side-effects...)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
419 |
cu = self.session.system_sql('SELECT mtime FROM entities WHERE eid = %s' % eidp) |
25bb65dc4559
test fixes, all server tests ok, except unittest_migractions (due to inter-tests-side-effects...)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
420 |
mtime = cu.fetchone()[0] |
0 | 421 |
self.failUnless(omtime < mtime) |
422 |
self.commit() |
|
423 |
date, modified, deleted = self.repo.entities_modified_since(('Personne',), omtime) |
|
424 |
self.assertEquals(modified, [('Personne', eidp)]) |
|
425 |
self.assertEquals(deleted, []) |
|
426 |
date, modified, deleted = self.repo.entities_modified_since(('Personne',), mtime) |
|
427 |
self.assertEquals(modified, []) |
|
428 |
self.assertEquals(deleted, []) |
|
429 |
self.execute('DELETE Personne X WHERE X eid %(x)s', {'x': eidp}) |
|
430 |
self.commit() |
|
431 |
date, modified, deleted = self.repo.entities_modified_since(('Personne',), omtime) |
|
432 |
self.assertEquals(modified, []) |
|
433 |
self.assertEquals(deleted, [('Personne', eidp)]) |
|
434 |
||
4806
4f12f59b1a13
[fti] refactor and fix full text indexation handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
435 |
def test_fulltext_container_entity(self): |
0 | 436 |
assert self.schema.rschema('use_email').fulltext_container == 'subject' |
4806
4f12f59b1a13
[fti] refactor and fix full text indexation handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
437 |
req = self.request() |
4f12f59b1a13
[fti] refactor and fix full text indexation handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
438 |
toto = req.create_entity('EmailAddress', address=u'toto@logilab.fr') |
0 | 439 |
self.commit() |
4806
4f12f59b1a13
[fti] refactor and fix full text indexation handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
440 |
rset = req.execute('Any X WHERE X has_text %(t)s', {'t': 'toto'}) |
4f12f59b1a13
[fti] refactor and fix full text indexation handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
441 |
self.assertEquals(rset.rows, []) |
4f12f59b1a13
[fti] refactor and fix full text indexation handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
442 |
req.user.set_relations(use_email=toto) |
4f12f59b1a13
[fti] refactor and fix full text indexation handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
443 |
self.commit() |
4f12f59b1a13
[fti] refactor and fix full text indexation handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
444 |
rset = req.execute('Any X WHERE X has_text %(t)s', {'t': 'toto'}) |
4f12f59b1a13
[fti] refactor and fix full text indexation handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
445 |
self.assertEquals(rset.rows, [[req.user.eid]]) |
4f12f59b1a13
[fti] refactor and fix full text indexation handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
446 |
req.execute('DELETE X use_email Y WHERE X login "admin", Y eid %(y)s', |
4f12f59b1a13
[fti] refactor and fix full text indexation handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
447 |
{'y': toto.eid}) |
0 | 448 |
self.commit() |
4806
4f12f59b1a13
[fti] refactor and fix full text indexation handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
449 |
rset = req.execute('Any X WHERE X has_text %(t)s', {'t': 'toto'}) |
0 | 450 |
self.assertEquals(rset.rows, []) |
4806
4f12f59b1a13
[fti] refactor and fix full text indexation handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
451 |
tutu = req.create_entity('EmailAddress', address=u'tutu@logilab.fr') |
4f12f59b1a13
[fti] refactor and fix full text indexation handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
452 |
req.user.set_relations(use_email=tutu) |
4f12f59b1a13
[fti] refactor and fix full text indexation handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
453 |
self.commit() |
4f12f59b1a13
[fti] refactor and fix full text indexation handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
454 |
rset = req.execute('Any X WHERE X has_text %(t)s', {'t': 'tutu'}) |
4f12f59b1a13
[fti] refactor and fix full text indexation handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
455 |
self.assertEquals(rset.rows, [[req.user.eid]]) |
4f12f59b1a13
[fti] refactor and fix full text indexation handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
456 |
tutu.set_attributes(address=u'hip@logilab.fr') |
0 | 457 |
self.commit() |
4806
4f12f59b1a13
[fti] refactor and fix full text indexation handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
458 |
rset = req.execute('Any X WHERE X has_text %(t)s', {'t': 'tutu'}) |
4f12f59b1a13
[fti] refactor and fix full text indexation handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
459 |
self.assertEquals(rset.rows, []) |
4f12f59b1a13
[fti] refactor and fix full text indexation handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
460 |
rset = req.execute('Any X WHERE X has_text %(t)s', {'t': 'hip'}) |
4f12f59b1a13
[fti] refactor and fix full text indexation handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
461 |
self.assertEquals(rset.rows, [[req.user.eid]]) |
4f12f59b1a13
[fti] refactor and fix full text indexation handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
462 |
|
4f12f59b1a13
[fti] refactor and fix full text indexation handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
463 |
def test_no_uncessary_ftiindex_op(self): |
4f12f59b1a13
[fti] refactor and fix full text indexation handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
464 |
req = self.request() |
4f12f59b1a13
[fti] refactor and fix full text indexation handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
465 |
req.create_entity('Workflow', name=u'dummy workflow', description=u'huuuuu') |
4f12f59b1a13
[fti] refactor and fix full text indexation handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
466 |
self.failIf(any(x for x in self.session.pending_operations |
4f12f59b1a13
[fti] refactor and fix full text indexation handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
467 |
if isinstance(x, native.FTIndexEntityOp))) |
1787 | 468 |
|
469 |
||
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
470 |
class DBInitTC(CubicWebTC): |
1787 | 471 |
|
0 | 472 |
def test_versions_inserted(self): |
473 |
inserted = [r[0] for r in self.execute('Any K ORDERBY K WHERE P pkey K, P pkey ~= "system.version.%"')] |
|
474 |
self.assertEquals(inserted, |
|
1787 | 475 |
[u'system.version.basket', u'system.version.card', u'system.version.comment', |
476 |
u'system.version.cubicweb', u'system.version.email', |
|
477 |
u'system.version.file', u'system.version.folder', |
|
17
62ce3e6126e0
work in progress: fix cubicweb/server tests
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
478 |
u'system.version.tag']) |
1787 | 479 |
|
3445
32492e9e734b
update and simplify test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2968
diff
changeset
|
480 |
CALLED = [] |
32492e9e734b
update and simplify test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2968
diff
changeset
|
481 |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
482 |
class InlineRelHooksTC(CubicWebTC): |
0 | 483 |
"""test relation hooks are called for inlined relations |
484 |
""" |
|
485 |
def setUp(self): |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
486 |
CubicWebTC.setUp(self) |
0 | 487 |
self.hm = self.repo.hm |
3445
32492e9e734b
update and simplify test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2968
diff
changeset
|
488 |
CALLED[:] = () |
0 | 489 |
|
490 |
def _after_relation_hook(self, pool, fromeid, rtype, toeid): |
|
491 |
self.called.append((fromeid, rtype, toeid)) |
|
1787 | 492 |
|
3445
32492e9e734b
update and simplify test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2968
diff
changeset
|
493 |
def test_inline_relation(self): |
32492e9e734b
update and simplify test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2968
diff
changeset
|
494 |
"""make sure <event>_relation hooks are called for inlined relation""" |
4766
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
495 |
class EcritParHook(hook.Hook): |
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
496 |
__regid__ = 'inlinedrelhook' |
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
497 |
__select__ = hook.Hook.__select__ & hook.match_rtype('ecrit_par') |
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
498 |
events = ('before_add_relation', 'after_add_relation', |
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
499 |
'before_delete_relation', 'after_delete_relation') |
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
500 |
def __call__(self): |
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
501 |
CALLED.append((self.event, self.eidfrom, self.rtype, self.eidto)) |
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4680
diff
changeset
|
502 |
|
3445
32492e9e734b
update and simplify test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2968
diff
changeset
|
503 |
self.hm.register(EcritParHook) |
0 | 504 |
eidp = self.execute('INSERT Personne X: X nom "toto"')[0][0] |
505 |
eidn = self.execute('INSERT Note X: X type "T"')[0][0] |
|
506 |
self.execute('SET N ecrit_par Y WHERE N type "T", Y nom "toto"') |
|
3445
32492e9e734b
update and simplify test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2968
diff
changeset
|
507 |
self.assertEquals(CALLED, [('before_add_relation', eidn, 'ecrit_par', eidp), |
32492e9e734b
update and simplify test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2968
diff
changeset
|
508 |
('after_add_relation', eidn, 'ecrit_par', eidp)]) |
32492e9e734b
update and simplify test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2968
diff
changeset
|
509 |
CALLED[:] = () |
32492e9e734b
update and simplify test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2968
diff
changeset
|
510 |
self.execute('DELETE N ecrit_par Y WHERE N type "T", Y nom "toto"') |
32492e9e734b
update and simplify test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2968
diff
changeset
|
511 |
self.assertEquals(CALLED, [('before_delete_relation', eidn, 'ecrit_par', eidp), |
32492e9e734b
update and simplify test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2968
diff
changeset
|
512 |
('after_delete_relation', eidn, 'ecrit_par', eidp)]) |
32492e9e734b
update and simplify test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2968
diff
changeset
|
513 |
CALLED[:] = () |
2923
b97a0f8dd4dc
fix test schema and update some tests to work again with wf changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
514 |
eidn = self.execute('INSERT Note N: N ecrit_par P WHERE P nom "toto"')[0][0] |
3445
32492e9e734b
update and simplify test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2968
diff
changeset
|
515 |
self.assertEquals(CALLED, [('before_add_relation', eidn, 'ecrit_par', eidp), |
32492e9e734b
update and simplify test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2968
diff
changeset
|
516 |
('after_add_relation', eidn, 'ecrit_par', eidp)]) |
0 | 517 |
|
1787 | 518 |
|
0 | 519 |
if __name__ == '__main__': |
520 |
unittest_main() |