author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Wed, 28 Apr 2010 12:14:22 +0200 | |
changeset 5423 | e15abfdcce38 |
parent 5408 | 120db445c179 |
parent 5421 | 8167de96c523 |
child 5426 | 0d4853a6e5ee |
permissions | -rw-r--r-- |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
1 |
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
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:
5389
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:
5389
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:
5389
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:
5389
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:
5389
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:
5389
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:
5389
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:
5389
diff
changeset
|
10 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
11 |
# logilab-common is distributed in the hope that it will be useful, but WITHOUT |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
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:
5389
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:
5389
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:
5389
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:
5389
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:
5389
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1901
diff
changeset
|
18 |
"""cubicweb.web.views.basecontrollers unit tests |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1901
diff
changeset
|
19 |
|
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1901
diff
changeset
|
20 |
""" |
0 | 21 |
|
1899
361774742f3e
[test] fix test after xhml_wrap changed signature
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1797
diff
changeset
|
22 |
from logilab.common.testlib import unittest_main, mock_object |
0 | 23 |
|
2559
46859078c866
[R xhtml] remove xhtml_wrap* function, use instead a single req.document_surrounding_div method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2058
diff
changeset
|
24 |
from cubicweb import Binary, NoSelectableObject, ValidationError |
46859078c866
[R xhtml] remove xhtml_wrap* function, use instead a single req.document_surrounding_div method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2058
diff
changeset
|
25 |
from cubicweb.view import STRICT_DOCTYPE |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
26 |
from cubicweb.devtools.testlib import CubicWebTC |
4023
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
27 |
from cubicweb.uilib import rql_for_eid |
5389
809d3b5b3d31
[python2.6] careful: json-py provides a json package. We don't want that.
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
5377
diff
changeset
|
28 |
from cubicweb.web import INTERNAL_FIELD_VALUE, Redirect, RequestError, json |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
29 |
from cubicweb.entities.authobjs import CWUser |
4390 | 30 |
from cubicweb.web.views.autoform import get_pending_inserts, get_pending_deletes |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
31 |
u = unicode |
0 | 32 |
|
4292
3fc808b0490b
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4266
diff
changeset
|
33 |
def req_form(user): |
3fc808b0490b
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4266
diff
changeset
|
34 |
return {'eid': [str(user.eid)], |
3fc808b0490b
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4266
diff
changeset
|
35 |
'_cw_edited_fields:%s' % user.eid: '_cw_generic_field', |
3fc808b0490b
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4266
diff
changeset
|
36 |
'__type:%s' % user.eid: user.__regid__ |
3fc808b0490b
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4266
diff
changeset
|
37 |
} |
0 | 38 |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
39 |
class EditControllerTC(CubicWebTC): |
0 | 40 |
def setUp(self): |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
41 |
CubicWebTC.setUp(self) |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
42 |
self.failUnless('users' in self.schema.eschema('CWGroup').get_groups('read')) |
1426 | 43 |
|
0 | 44 |
def tearDown(self): |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
45 |
CubicWebTC.tearDown(self) |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
46 |
self.failUnless('users' in self.schema.eschema('CWGroup').get_groups('read')) |
1426 | 47 |
|
0 | 48 |
def test_noparam_edit(self): |
49 |
"""check behaviour of this controller without any form parameter |
|
50 |
""" |
|
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
51 |
ex = self.assertRaises(ValidationError, self.ctrl_publish, self.request()) |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
52 |
self.assertEquals(ex.errors, {None: u'no selected entities'}) |
1426 | 53 |
|
0 | 54 |
def test_validation_unique(self): |
55 |
"""test creation of two linked entities |
|
1426 | 56 |
""" |
0 | 57 |
user = self.user() |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
58 |
req = self.request() |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
59 |
req.form = {'eid': 'X', '__type:X': 'CWUser', |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
60 |
'_cw_edited_fields:X': 'login-subject,upassword-subject', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
61 |
'login-subject:X': u'admin', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
62 |
'upassword-subject:X': u'toto', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
63 |
'upassword-subject-confirm:X': u'toto', |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
64 |
} |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
65 |
ex = self.assertRaises(ValidationError, self.ctrl_publish, req) |
5030
5238d9a8dfee
[form] put qualified name on validation error, should fix #784299
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4918
diff
changeset
|
66 |
self.assertEquals(ex.errors, {'login-subject': 'the value "admin" is already used, use another one'}) |
0 | 67 |
|
68 |
def test_user_editing_itself(self): |
|
69 |
"""checking that a manager user can edit itself |
|
70 |
""" |
|
71 |
user = self.user() |
|
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
72 |
basegroups = [u(eid) for eid, in self.execute('CWGroup G WHERE X in_group G, X eid %(x)s', {'x': user.eid})] |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
73 |
groupeids = [eid for eid, in self.execute('CWGroup G WHERE G name in ("managers", "users")')] |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
74 |
groups = [u(eid) for eid in groupeids] |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
75 |
req = self.request() |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
76 |
eid = u(user.eid) |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
77 |
req.form = { |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
78 |
'eid': eid, '__type:'+eid: 'CWUser', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
79 |
'_cw_edited_fields:'+eid: 'login-subject,firstname-subject,surname-subject,in_group-subject', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
80 |
'login-subject:'+eid: u(user.login), |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
81 |
'surname-subject:'+eid: u'Th\xe9nault', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
82 |
'firstname-subject:'+eid: u'Sylvain', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
83 |
'in_group-subject:'+eid: groups, |
0 | 84 |
} |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
85 |
path, params = self.expect_redirect_publish(req, 'edit') |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5038
diff
changeset
|
86 |
e = self.execute('Any X WHERE X eid %(x)s', {'x': user.eid}).get_entity(0, 0) |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
87 |
self.assertEquals(e.firstname, u'Sylvain') |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
88 |
self.assertEquals(e.surname, u'Th\xe9nault') |
0 | 89 |
self.assertEquals(e.login, user.login) |
90 |
self.assertEquals([g.eid for g in e.in_group], groupeids) |
|
91 |
||
92 |
def test_user_can_change_its_password(self): |
|
93 |
user = self.create_user('user') |
|
94 |
cnx = self.login('user') |
|
95 |
req = self.request() |
|
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
96 |
eid = u(user.eid) |
0 | 97 |
req.form = { |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
98 |
'eid': eid, '__maineid' : eid, |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
99 |
'__type:'+eid: 'CWUser', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
100 |
'_cw_edited_fields:'+eid: 'upassword-subject', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
101 |
'upassword-subject:'+eid: 'tournicoton', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
102 |
'upassword-subject-confirm:'+eid: 'tournicoton', |
0 | 103 |
} |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
104 |
path, params = self.expect_redirect_publish(req, 'edit') |
0 | 105 |
cnx.commit() # commit to check we don't get late validation error for instance |
1654 | 106 |
self.assertEquals(path, 'cwuser/user') |
0 | 107 |
self.failIf('vid' in params) |
108 |
||
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
109 |
def test_user_editing_itself_no_relation(self): |
0 | 110 |
"""checking we can edit an entity without specifying some required |
111 |
relations (meaning no changes) |
|
112 |
""" |
|
113 |
user = self.user() |
|
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
114 |
groupeids = [g.eid for g in user.in_group] |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
115 |
req = self.request() |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
116 |
eid = u(user.eid) |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
117 |
req.form = { |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
118 |
'eid': eid, |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
119 |
'__type:'+eid: 'CWUser', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
120 |
'_cw_edited_fields:'+eid: 'login-subject,firstname-subject,surname-subject', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
121 |
'login-subject:'+eid: u(user.login), |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
122 |
'firstname-subject:'+eid: u'Th\xe9nault', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
123 |
'surname-subject:'+eid: u'Sylvain', |
0 | 124 |
} |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
125 |
path, params = self.expect_redirect_publish(req, 'edit') |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5038
diff
changeset
|
126 |
e = self.execute('Any X WHERE X eid %(x)s', {'x': user.eid}).get_entity(0, 0) |
0 | 127 |
self.assertEquals(e.login, user.login) |
128 |
self.assertEquals(e.firstname, u'Th\xe9nault') |
|
129 |
self.assertEquals(e.surname, u'Sylvain') |
|
130 |
self.assertEquals([g.eid for g in e.in_group], groupeids) |
|
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
131 |
self.assertEquals(e.state, 'activated') |
1426 | 132 |
|
133 |
||
0 | 134 |
def test_create_multiple_linked(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
135 |
gueid = self.execute('CWGroup G WHERE G name "users"')[0][0] |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
136 |
req = self.request() |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
137 |
req.form = {'eid': ['X', 'Y'], '__maineid' : 'X', |
0 | 138 |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
139 |
'__type:X': 'CWUser', |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
140 |
'_cw_edited_fields:X': 'login-subject,upassword-subject,surname-subject,in_group-subject', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
141 |
'login-subject:X': u'adim', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
142 |
'upassword-subject:X': u'toto', 'upassword-subject-confirm:X': u'toto', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
143 |
'surname-subject:X': u'Di Mascio', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
144 |
'in_group-subject:X': u(gueid), |
1426 | 145 |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
146 |
'__type:Y': 'EmailAddress', |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
147 |
'_cw_edited_fields:Y': 'address-subject,use_email-object', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
148 |
'address-subject:Y': u'dima@logilab.fr', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
149 |
'use_email-object:Y': 'X', |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
150 |
} |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
151 |
path, params = self.expect_redirect_publish(req, 'edit') |
0 | 152 |
# should be redirected on the created person |
1654 | 153 |
self.assertEquals(path, 'cwuser/adim') |
0 | 154 |
e = self.execute('Any P WHERE P surname "Di Mascio"').get_entity(0, 0) |
155 |
self.assertEquals(e.surname, 'Di Mascio') |
|
156 |
email = e.use_email[0] |
|
157 |
self.assertEquals(email.address, 'dima@logilab.fr') |
|
1426 | 158 |
|
0 | 159 |
def test_edit_multiple_linked(self): |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
160 |
peid = u(self.create_user('adim').eid) |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
161 |
req = self.request() |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
162 |
req.form = {'eid': [peid, 'Y'], '__maineid': peid, |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
163 |
|
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
164 |
'__type:'+peid: u'CWUser', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
165 |
'_cw_edited_fields:'+peid: u'surname-subject', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
166 |
'surname-subject:'+peid: u'Di Masci', |
1426 | 167 |
|
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
168 |
'__type:Y': u'EmailAddress', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
169 |
'_cw_edited_fields:Y': u'address-subject,use_email-object', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
170 |
'address-subject:Y': u'dima@logilab.fr', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
171 |
'use_email-object:Y': peid, |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
172 |
} |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
173 |
path, params = self.expect_redirect_publish(req, 'edit') |
0 | 174 |
# should be redirected on the created person |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
175 |
self.assertEquals(path, 'cwuser/adim') |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
176 |
e = self.execute('Any P WHERE P surname "Di Masci"').get_entity(0, 0) |
0 | 177 |
email = e.use_email[0] |
178 |
self.assertEquals(email.address, 'dima@logilab.fr') |
|
1426 | 179 |
|
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
180 |
emaileid = u(email.eid) |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
181 |
req = self.request() |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
182 |
req.form = {'eid': [peid, emaileid], |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
183 |
|
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
184 |
'__type:'+peid: u'CWUser', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
185 |
'_cw_edited_fields:'+peid: u'surname-subject', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
186 |
'surname-subject:'+peid: u'Di Masci', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
187 |
|
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
188 |
'__type:'+emaileid: u'EmailAddress', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
189 |
'_cw_edited_fields:'+emaileid: u'address-subject,use_email-object', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
190 |
'address-subject:'+emaileid: u'adim@logilab.fr', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
191 |
'use_email-object:'+emaileid: peid, |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
192 |
} |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
193 |
path, params = self.expect_redirect_publish(req, 'edit') |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
194 |
email.clear_all_caches() |
0 | 195 |
self.assertEquals(email.address, 'adim@logilab.fr') |
196 |
||
1426 | 197 |
|
0 | 198 |
def test_password_confirm(self): |
199 |
"""test creation of two linked entities |
|
1426 | 200 |
""" |
0 | 201 |
user = self.user() |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
202 |
req = self.request() |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
203 |
req.form = {'eid': 'X', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
204 |
'__cloned_eid:X': u(user.eid), '__type:X': 'CWUser', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
205 |
'_cw_edited_fields:X': 'login-subject,upassword-subject', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
206 |
'login-subject:X': u'toto', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
207 |
'upassword-subject:X': u'toto', |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
208 |
} |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
209 |
ex = self.assertRaises(ValidationError, self.ctrl_publish, req) |
4266 | 210 |
self.assertEquals(ex.errors, {'upassword-subject': u'password and confirmation don\'t match'}) |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
211 |
req = self.request() |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
212 |
req.form = {'__cloned_eid:X': u(user.eid), |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
213 |
'eid': 'X', '__type:X': 'CWUser', |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
214 |
'_cw_edited_fields:X': 'login-subject,upassword-subject', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
215 |
'login-subject:X': u'toto', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
216 |
'upassword-subject:X': u'toto', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
217 |
'upassword-subject-confirm:X': u'tutu', |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
218 |
} |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
219 |
ex = self.assertRaises(ValidationError, self.ctrl_publish, req) |
4266 | 220 |
self.assertEquals(ex.errors, {'upassword-subject': u'password and confirmation don\'t match'}) |
0 | 221 |
|
222 |
||
223 |
def test_interval_bound_constraint_success(self): |
|
3587 | 224 |
feid = self.execute('INSERT File X: X data_name "toto.txt", X data %(data)s', |
0 | 225 |
{'data': Binary('yo')})[0][0] |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
226 |
req = self.request() |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
227 |
req.form = {'eid': ['X'], |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
228 |
'__type:X': 'Salesterm', |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
229 |
'_cw_edited_fields:X': 'amount-subject,described_by_test-subject', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
230 |
'amount-subject:X': u'-10', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
231 |
'described_by_test-subject:X': u(feid), |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
232 |
} |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
233 |
ex = self.assertRaises(ValidationError, self.ctrl_publish, req) |
5387
aed0c441923a
[i18n] yams constraint messages updated
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5385
diff
changeset
|
234 |
self.assertEquals(ex.errors, {'amount-subject': 'value must be >= 0'}) |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
235 |
req = self.request() |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
236 |
req.form = {'eid': ['X'], |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
237 |
'__type:X': 'Salesterm', |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
238 |
'_cw_edited_fields:X': 'amount-subject,described_by_test-subject', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
239 |
'amount-subject:X': u'110', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
240 |
'described_by_test-subject:X': u(feid), |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
241 |
} |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
242 |
ex = self.assertRaises(ValidationError, self.ctrl_publish, req) |
5387
aed0c441923a
[i18n] yams constraint messages updated
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5385
diff
changeset
|
243 |
self.assertEquals(ex.errors, {'amount-subject': 'value must be <= 100'}) |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
244 |
req = self.request() |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
245 |
req.form = {'eid': ['X'], |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
246 |
'__type:X': 'Salesterm', |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
247 |
'_cw_edited_fields:X': 'amount-subject,described_by_test-subject', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
248 |
'amount-subject:X': u'10', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
249 |
'described_by_test-subject:X': u(feid), |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
250 |
} |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
251 |
self.expect_redirect_publish(req, 'edit') |
1426 | 252 |
# should be redirected on the created |
0 | 253 |
#eid = params['rql'].split()[-1] |
254 |
e = self.execute('Salesterm X').get_entity(0, 0) |
|
255 |
self.assertEquals(e.amount, 10) |
|
256 |
||
257 |
def test_req_pending_insert(self): |
|
258 |
"""make sure req's pending insertions are taken into account""" |
|
4083
3b285889b8e9
3.6 api update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4023
diff
changeset
|
259 |
tmpgroup = self.request().create_entity('CWGroup', name=u"test") |
0 | 260 |
user = self.user() |
4292
3fc808b0490b
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4266
diff
changeset
|
261 |
req = self.request(**req_form(user)) |
5223
6abd6e3599f4
#773448: refactor session and 'no connection' handling, by introducing proper web session. We should now be able to see page even when no anon is configured, and be redirected to the login form as soon as one tries to do a query.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
262 |
req.session.data['pending_insert'] = set([(user.eid, 'in_group', tmpgroup.eid)]) |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
263 |
path, params = self.expect_redirect_publish(req, 'edit') |
0 | 264 |
usergroups = [gname for gname, in |
265 |
self.execute('Any N WHERE G name N, U in_group G, U eid %(u)s', {'u': user.eid})] |
|
266 |
self.assertUnorderedIterableEquals(usergroups, ['managers', 'test']) |
|
4292
3fc808b0490b
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4266
diff
changeset
|
267 |
self.assertEquals(get_pending_inserts(req), []) |
0 | 268 |
|
269 |
||
270 |
def test_req_pending_delete(self): |
|
271 |
"""make sure req's pending deletions are taken into account""" |
|
272 |
user = self.user() |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
273 |
groupeid = self.execute('INSERT CWGroup G: G name "test", U in_group G WHERE U eid %(x)s', |
0 | 274 |
{'x': user.eid})[0][0] |
275 |
usergroups = [gname for gname, in |
|
276 |
self.execute('Any N WHERE G name N, U in_group G, U eid %(u)s', {'u': user.eid})] |
|
277 |
# just make sure everything was set correctly |
|
278 |
self.assertUnorderedIterableEquals(usergroups, ['managers', 'test']) |
|
279 |
# now try to delete the relation |
|
4292
3fc808b0490b
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4266
diff
changeset
|
280 |
req = self.request(**req_form(user)) |
5223
6abd6e3599f4
#773448: refactor session and 'no connection' handling, by introducing proper web session. We should now be able to see page even when no anon is configured, and be redirected to the login form as soon as one tries to do a query.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
281 |
req.session.data['pending_delete'] = set([(user.eid, 'in_group', groupeid)]) |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
282 |
path, params = self.expect_redirect_publish(req, 'edit') |
0 | 283 |
usergroups = [gname for gname, in |
284 |
self.execute('Any N WHERE G name N, U in_group G, U eid %(u)s', {'u': user.eid})] |
|
285 |
self.assertUnorderedIterableEquals(usergroups, ['managers']) |
|
4292
3fc808b0490b
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4266
diff
changeset
|
286 |
self.assertEquals(get_pending_deletes(req), []) |
0 | 287 |
|
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
288 |
# def test_custom_attribute_handler(self): |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
289 |
# def custom_login_edit(self, formparams, value, relations): |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
290 |
# formparams['login'] = value.upper() |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
291 |
# relations.append('X login %(login)s') |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
292 |
# CWUser.custom_login_edit = custom_login_edit |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
293 |
# try: |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
294 |
# user = self.user() |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
295 |
# eid = repr(user.eid) |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
296 |
# req = self.request() |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
297 |
# req.form = { |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
298 |
# 'eid': eid, |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
299 |
# '__type:'+eid: 'CWUser', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
300 |
# 'login:'+eid: u'foo', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
301 |
# } |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
302 |
# path, params = self.expect_redirect_publish(req, 'edit') |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
303 |
# rset = self.execute('Any L WHERE X eid %(x)s, X login L', {'x': user.eid}, 'x') |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
304 |
# self.assertEquals(rset[0][0], 'FOO') |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
305 |
# finally: |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
306 |
# del CWUser.custom_login_edit |
1426 | 307 |
|
0 | 308 |
def test_redirect_apply_button(self): |
309 |
redirectrql = rql_for_eid(4012) # whatever |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
310 |
req = self.request() |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
311 |
req.form = { |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
312 |
'eid': 'A', '__maineid' : 'A', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
313 |
'__type:A': 'BlogEntry', '_cw_edited_fields:A': 'content-subject,title-subject', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
314 |
'content-subject:A': u'"13:03:43"', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
315 |
'title-subject:A': u'huuu', |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
316 |
'__redirectrql': redirectrql, |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
317 |
'__redirectvid': 'primary', |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
318 |
'__redirectparams': 'toto=tutu&tata=titi', |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
319 |
'__form_id': 'edition', |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
320 |
'__action_apply': '', |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
321 |
} |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
322 |
path, params = self.expect_redirect_publish(req, 'edit') |
0 | 323 |
self.failUnless(path.startswith('blogentry/')) |
324 |
eid = path.split('/')[1] |
|
325 |
self.assertEquals(params['vid'], 'edition') |
|
326 |
self.assertNotEquals(int(eid), 4012) |
|
327 |
self.assertEquals(params['__redirectrql'], redirectrql) |
|
328 |
self.assertEquals(params['__redirectvid'], 'primary') |
|
329 |
self.assertEquals(params['__redirectparams'], 'toto=tutu&tata=titi') |
|
330 |
||
331 |
def test_redirect_ok_button(self): |
|
332 |
redirectrql = rql_for_eid(4012) # whatever |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
333 |
req = self.request() |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
334 |
req.form = { |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
335 |
'eid': 'A', '__maineid' : 'A', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
336 |
'__type:A': 'BlogEntry', '_cw_edited_fields:A': 'content-subject,title-subject', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
337 |
'content-subject:A': u'"13:03:43"', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
338 |
'title-subject:A': u'huuu', |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
339 |
'__redirectrql': redirectrql, |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
340 |
'__redirectvid': 'primary', |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
341 |
'__redirectparams': 'toto=tutu&tata=titi', |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
342 |
'__form_id': 'edition', |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
343 |
} |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
344 |
path, params = self.expect_redirect_publish(req, 'edit') |
0 | 345 |
self.assertEquals(path, 'view') |
346 |
self.assertEquals(params['rql'], redirectrql) |
|
347 |
self.assertEquals(params['vid'], 'primary') |
|
348 |
self.assertEquals(params['tata'], 'titi') |
|
349 |
self.assertEquals(params['toto'], 'tutu') |
|
350 |
||
351 |
def test_redirect_delete_button(self): |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
352 |
req = self.request() |
4083
3b285889b8e9
3.6 api update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4023
diff
changeset
|
353 |
eid = req.create_entity('BlogEntry', title=u'hop', content=u'hop').eid |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
354 |
req.form = {'eid': u(eid), '__type:%s'%eid: 'BlogEntry', |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
355 |
'__action_delete': ''} |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
356 |
path, params = self.expect_redirect_publish(req, 'edit') |
0 | 357 |
self.assertEquals(path, 'blogentry') |
4918 | 358 |
self.assertIn('_cwmsgid', params) |
4083
3b285889b8e9
3.6 api update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4023
diff
changeset
|
359 |
eid = req.create_entity('EmailAddress', address=u'hop@logilab.fr').eid |
0 | 360 |
self.execute('SET X use_email E WHERE E eid %(e)s, X eid %(x)s', |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5038
diff
changeset
|
361 |
{'x': self.session.user.eid, 'e': eid}) |
0 | 362 |
self.commit() |
4083
3b285889b8e9
3.6 api update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4023
diff
changeset
|
363 |
req = req |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
364 |
req.form = {'eid': u(eid), '__type:%s'%eid: 'EmailAddress', |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
365 |
'__action_delete': ''} |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
366 |
path, params = self.expect_redirect_publish(req, 'edit') |
1654 | 367 |
self.assertEquals(path, 'cwuser/admin') |
4918 | 368 |
self.assertIn('_cwmsgid', params) |
4083
3b285889b8e9
3.6 api update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4023
diff
changeset
|
369 |
eid1 = req.create_entity('BlogEntry', title=u'hop', content=u'hop').eid |
3b285889b8e9
3.6 api update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4023
diff
changeset
|
370 |
eid2 = req.create_entity('EmailAddress', address=u'hop@logilab.fr').eid |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
371 |
req = self.request() |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
372 |
req.form = {'eid': [u(eid1), u(eid2)], |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
373 |
'__type:%s'%eid1: 'BlogEntry', |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
374 |
'__type:%s'%eid2: 'EmailAddress', |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
375 |
'__action_delete': ''} |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
376 |
path, params = self.expect_redirect_publish(req, 'edit') |
0 | 377 |
self.assertEquals(path, 'view') |
4918 | 378 |
self.assertIn('_cwmsgid', params) |
0 | 379 |
|
380 |
def test_nonregr_eetype_etype_editing(self): |
|
4389
14a993bc8d1e
useless, same as test_nonregr_eetype_etype_editing
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4292
diff
changeset
|
381 |
"""non-regression test checking that a manager user can edit a CWEType entity |
0 | 382 |
""" |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
383 |
groupeids = sorted(eid for eid, in self.execute('CWGroup G WHERE G name in ("managers", "users")')) |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
384 |
groups = [u(eid) for eid in groupeids] |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
385 |
cwetypeeid = self.execute('CWEType X WHERE X name "CWEType"')[0][0] |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
386 |
basegroups = [u(eid) for eid, in self.execute('CWGroup G WHERE X read_permission G, X eid %(x)s', {'x': cwetypeeid})] |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
387 |
cwetypeeid = u(cwetypeeid) |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
388 |
req = self.request() |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
389 |
req.form = { |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
390 |
'eid': cwetypeeid, |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
391 |
'__type:'+cwetypeeid: 'CWEType', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
392 |
'_cw_edited_fields:'+cwetypeeid: 'name-subject,final-subject,description-subject,read_permission-subject', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
393 |
'name-subject:'+cwetypeeid: u'CWEType', |
4390 | 394 |
'final-subject:'+cwetypeeid: '', |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
395 |
'description-subject:'+cwetypeeid: u'users group', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
396 |
'read_permission-subject:'+cwetypeeid: groups, |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
397 |
} |
0 | 398 |
try: |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
399 |
path, params = self.expect_redirect_publish(req, 'edit') |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5038
diff
changeset
|
400 |
e = self.execute('Any X WHERE X eid %(x)s', {'x': cwetypeeid}).get_entity(0, 0) |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
401 |
self.assertEquals(e.name, 'CWEType') |
0 | 402 |
self.assertEquals(sorted(g.eid for g in e.read_permission), groupeids) |
403 |
finally: |
|
404 |
# restore |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
405 |
self.execute('SET X read_permission Y WHERE X name "CWEType", Y eid IN (%s), NOT X read_permission Y' % (','.join(basegroups))) |
0 | 406 |
self.commit() |
1426 | 407 |
|
0 | 408 |
def test_nonregr_strange_text_input(self): |
409 |
"""non-regression test checking text input containing "13:03:43" |
|
410 |
||
411 |
this seems to be postgres (tsearch?) specific |
|
1426 | 412 |
""" |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
413 |
req = self.request() |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
414 |
req.form = { |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
415 |
'eid': 'A', '__maineid' : 'A', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
416 |
'__type:A': 'BlogEntry', '_cw_edited_fields:A': 'title-subject,content-subject', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
417 |
'title-subject:A': u'"13:03:40"', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
418 |
'content-subject:A': u'"13:03:43"',} |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
419 |
path, params = self.expect_redirect_publish(req, 'edit') |
0 | 420 |
self.failUnless(path.startswith('blogentry/')) |
421 |
eid = path.split('/')[1] |
|
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5038
diff
changeset
|
422 |
e = self.execute('Any C, T WHERE C eid %(x)s, C content T', {'x': eid}).get_entity(0, 0) |
0 | 423 |
self.assertEquals(e.title, '"13:03:40"') |
424 |
self.assertEquals(e.content, '"13:03:43"') |
|
425 |
||
426 |
||
427 |
def test_nonregr_multiple_empty_email_addr(self): |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
428 |
gueid = self.execute('CWGroup G WHERE G name "users"')[0][0] |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
429 |
req = self.request() |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
430 |
req.form = {'eid': ['X', 'Y'], |
1426 | 431 |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
432 |
'__type:X': 'CWUser', |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
433 |
'_cw_edited_fields:X': 'login-subject,upassword-subject,in_group-subject', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
434 |
'login-subject:X': u'adim', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
435 |
'upassword-subject:X': u'toto', 'upassword-subject-confirm:X': u'toto', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
436 |
'in_group-subject:X': `gueid`, |
1426 | 437 |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
438 |
'__type:Y': 'EmailAddress', |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
439 |
'_cw_edited_fields:Y': 'address-subject,alias-subject,use_email-object', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
440 |
'address-subject:Y': u'', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
441 |
'alias-subject:Y': u'', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
442 |
'use_email-object:Y': 'X', |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
443 |
} |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
444 |
ex = self.assertRaises(ValidationError, self.ctrl_publish, req) |
5038
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
445 |
self.assertEquals(ex.errors, {'address-subject': u'required field'}) |
0 | 446 |
|
447 |
def test_nonregr_copy(self): |
|
448 |
user = self.user() |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
449 |
req = self.request() |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
450 |
req.form = {'__maineid' : 'X', 'eid': 'X', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
451 |
'__cloned_eid:X': user.eid, '__type:X': 'CWUser', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
452 |
'_cw_edited_fields:X': 'login-subject,upassword-subject', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
453 |
'login-subject:X': u'toto', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
454 |
'upassword-subject:X': u'toto', 'upassword-subject-confirm:X': u'toto', |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
455 |
} |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
456 |
path, params = self.expect_redirect_publish(req, 'edit') |
1654 | 457 |
self.assertEquals(path, 'cwuser/toto') |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
458 |
e = self.execute('Any X WHERE X is CWUser, X login "toto"').get_entity(0, 0) |
0 | 459 |
self.assertEquals(e.login, 'toto') |
460 |
self.assertEquals(e.in_group[0].name, 'managers') |
|
461 |
||
462 |
||
463 |
def test_nonregr_rollback_on_validation_error(self): |
|
464 |
p = self.create_user("doe") |
|
465 |
# do not try to skip 'primary_email' for this test |
|
466 |
old_skips = p.__class__.skip_copy_for |
|
467 |
p.__class__.skip_copy_for = () |
|
468 |
try: |
|
4083
3b285889b8e9
3.6 api update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4023
diff
changeset
|
469 |
e = self.request().create_entity('EmailAddress', address=u'doe@doe.com') |
0 | 470 |
self.execute('SET P use_email E, P primary_email E WHERE P eid %(p)s, E eid %(e)s', |
471 |
{'p' : p.eid, 'e' : e.eid}) |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
472 |
req = self.request() |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
473 |
req.form = {'eid': 'X', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
474 |
'__cloned_eid:X': p.eid, '__type:X': 'CWUser', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
475 |
'_cw_edited_fields:X': 'login-subject,surname-subject', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
476 |
'login-subject': u'dodo', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
477 |
'surname-subject:X': u'Boom', |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
478 |
'__errorurl' : "whatever but required", |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
479 |
} |
0 | 480 |
# try to emulate what really happens in the web application |
481 |
# 1/ validate form => EditController.publish raises a ValidationError |
|
482 |
# which fires a Redirect |
|
483 |
# 2/ When re-publishing the copy form, the publisher implicitly commits |
|
484 |
try: |
|
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
485 |
self.app_publish(req, 'edit') |
0 | 486 |
except Redirect: |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
487 |
req = self.request() |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
488 |
req.form['rql'] = 'Any X WHERE X eid %s' % p.eid |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
489 |
req.form['vid'] = 'copy' |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
490 |
self.app_publish(req, 'view') |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
491 |
rset = self.execute('CWUser P WHERE P surname "Boom"') |
0 | 492 |
self.assertEquals(len(rset), 0) |
493 |
finally: |
|
494 |
p.__class__.skip_copy_for = old_skips |
|
495 |
||
496 |
||
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
497 |
class EmbedControllerTC(CubicWebTC): |
0 | 498 |
|
499 |
def test_nonregr_embed_publish(self): |
|
500 |
# This test looks a bit stupid but at least it will probably |
|
501 |
# fail if the controller API changes and if EmbedController is not |
|
502 |
# updated (which is what happened before this test) |
|
503 |
req = self.request() |
|
4824
b01973eff0f7
[test] don't use an internal url for test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4390
diff
changeset
|
504 |
req.form['url'] = 'http://www.logilab.fr/' |
2661
f8df42c9da6b
[vreg api update] remove some deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2559
diff
changeset
|
505 |
controller = self.vreg['controllers'].select('embed', req) |
0 | 506 |
result = controller.publish(rset=None) |
507 |
||
508 |
||
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
509 |
class ReportBugControllerTC(CubicWebTC): |
0 | 510 |
|
511 |
def test_usable_by_guets(self): |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
512 |
self.login('anon') |
4918 | 513 |
self.assertRaises(NoSelectableObject, |
514 |
self.vreg['controllers'].select, 'reportbug', self.request()) |
|
515 |
self.vreg['controllers'].select('reportbug', self.request(description='hop')) |
|
0 | 516 |
|
517 |
||
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
518 |
class SendMailControllerTC(CubicWebTC): |
0 | 519 |
|
520 |
def test_not_usable_by_guets(self): |
|
4918 | 521 |
self.assertRaises(NoSelectableObject, |
522 |
self.vreg['controllers'].select, 'sendmail', self.request()) |
|
523 |
self.vreg['controllers'].select('sendmail', |
|
524 |
self.request(subject='toto', |
|
525 |
recipient='toto@logilab.fr', |
|
526 |
mailbody='hop')) |
|
0 | 527 |
self.login('anon') |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
528 |
self.assertRaises(NoSelectableObject, |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
529 |
self.vreg['controllers'].select, 'sendmail', self.request()) |
1426 | 530 |
|
0 | 531 |
|
532 |
||
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
533 |
class JSONControllerTC(CubicWebTC): |
0 | 534 |
|
535 |
def ctrl(self, req=None): |
|
536 |
req = req or self.request(url='http://whatever.fr/') |
|
2661
f8df42c9da6b
[vreg api update] remove some deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2559
diff
changeset
|
537 |
return self.vreg['controllers'].select('json', req) |
0 | 538 |
|
539 |
def setup_database(self): |
|
4083
3b285889b8e9
3.6 api update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4023
diff
changeset
|
540 |
req = self.request() |
3b285889b8e9
3.6 api update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4023
diff
changeset
|
541 |
self.pytag = req.create_entity('Tag', name=u'python') |
3b285889b8e9
3.6 api update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4023
diff
changeset
|
542 |
self.cubicwebtag = req.create_entity('Tag', name=u'cubicweb') |
0 | 543 |
self.john = self.create_user(u'John') |
544 |
||
545 |
||
546 |
## tests ################################################################## |
|
547 |
def test_simple_exec(self): |
|
1654 | 548 |
req = self.request(rql='CWUser P WHERE P login "John"', |
549 |
pageid='123', fname='view') |
|
550 |
ctrl = self.ctrl(req) |
|
551 |
rset = self.john.as_rset() |
|
1797
c2a80130b06d
fix some web tests, adjusts rtags
sylvain.thenault@logilab.fr
parents:
1654
diff
changeset
|
552 |
rset.req = req |
2559
46859078c866
[R xhtml] remove xhtml_wrap* function, use instead a single req.document_surrounding_div method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2058
diff
changeset
|
553 |
source = ctrl.publish() |
46859078c866
[R xhtml] remove xhtml_wrap* function, use instead a single req.document_surrounding_div method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2058
diff
changeset
|
554 |
self.failUnless(source.startswith('<?xml version="1.0"?>\n' + STRICT_DOCTYPE + |
46859078c866
[R xhtml] remove xhtml_wrap* function, use instead a single req.document_surrounding_div method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2058
diff
changeset
|
555 |
u'<div xmlns="http://www.w3.org/1999/xhtml" xmlns:cubicweb="http://www.logilab.org/2008/cubicweb">') |
46859078c866
[R xhtml] remove xhtml_wrap* function, use instead a single req.document_surrounding_div method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2058
diff
changeset
|
556 |
) |
46859078c866
[R xhtml] remove xhtml_wrap* function, use instead a single req.document_surrounding_div method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2058
diff
changeset
|
557 |
req.xhtml_browser = lambda: False |
46859078c866
[R xhtml] remove xhtml_wrap* function, use instead a single req.document_surrounding_div method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2058
diff
changeset
|
558 |
source = ctrl.publish() |
46859078c866
[R xhtml] remove xhtml_wrap* function, use instead a single req.document_surrounding_div method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2058
diff
changeset
|
559 |
self.failUnless(source.startswith('<div>')) |
0 | 560 |
|
1654 | 561 |
# def test_json_exec(self): |
562 |
# rql = 'Any T,N WHERE T is Tag, T name N' |
|
563 |
# ctrl = self.ctrl(self.request(mode='json', rql=rql, pageid='123')) |
|
564 |
# self.assertEquals(ctrl.publish(), |
|
5377
84d14ddfae13
[python2.6] prefer python2.6's builtin json module over simplejson
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
5038
diff
changeset
|
565 |
# json.dumps(self.execute(rql).rows)) |
0 | 566 |
|
567 |
def test_remote_add_existing_tag(self): |
|
568 |
self.remote_call('tag_entity', self.john.eid, ['python']) |
|
5223
6abd6e3599f4
#773448: refactor session and 'no connection' handling, by introducing proper web session. We should now be able to see page even when no anon is configured, and be redirected to the login form as soon as one tries to do a query.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
569 |
self.assertUnorderedIterableEquals( |
6abd6e3599f4
#773448: refactor session and 'no connection' handling, by introducing proper web session. We should now be able to see page even when no anon is configured, and be redirected to the login form as soon as one tries to do a query.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
570 |
[tname for tname, in self.execute('Any N WHERE T is Tag, T name N')], |
6abd6e3599f4
#773448: refactor session and 'no connection' handling, by introducing proper web session. We should now be able to see page even when no anon is configured, and be redirected to the login form as soon as one tries to do a query.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
571 |
['python', 'cubicweb']) |
6abd6e3599f4
#773448: refactor session and 'no connection' handling, by introducing proper web session. We should now be able to see page even when no anon is configured, and be redirected to the login form as soon as one tries to do a query.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
572 |
self.assertEquals( |
6abd6e3599f4
#773448: refactor session and 'no connection' handling, by introducing proper web session. We should now be able to see page even when no anon is configured, and be redirected to the login form as soon as one tries to do a query.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
573 |
self.execute('Any N WHERE T tags P, P is CWUser, T name N').rows, |
6abd6e3599f4
#773448: refactor session and 'no connection' handling, by introducing proper web session. We should now be able to see page even when no anon is configured, and be redirected to the login form as soon as one tries to do a query.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
574 |
[['python']]) |
1426 | 575 |
|
0 | 576 |
def test_remote_add_new_tag(self): |
577 |
self.remote_call('tag_entity', self.john.eid, ['javascript']) |
|
5223
6abd6e3599f4
#773448: refactor session and 'no connection' handling, by introducing proper web session. We should now be able to see page even when no anon is configured, and be redirected to the login form as soon as one tries to do a query.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
578 |
self.assertUnorderedIterableEquals( |
6abd6e3599f4
#773448: refactor session and 'no connection' handling, by introducing proper web session. We should now be able to see page even when no anon is configured, and be redirected to the login form as soon as one tries to do a query.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
579 |
[tname for tname, in self.execute('Any N WHERE T is Tag, T name N')], |
6abd6e3599f4
#773448: refactor session and 'no connection' handling, by introducing proper web session. We should now be able to see page even when no anon is configured, and be redirected to the login form as soon as one tries to do a query.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
580 |
['python', 'cubicweb', 'javascript']) |
6abd6e3599f4
#773448: refactor session and 'no connection' handling, by introducing proper web session. We should now be able to see page even when no anon is configured, and be redirected to the login form as soon as one tries to do a query.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
581 |
self.assertEquals( |
6abd6e3599f4
#773448: refactor session and 'no connection' handling, by introducing proper web session. We should now be able to see page even when no anon is configured, and be redirected to the login form as soon as one tries to do a query.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
582 |
self.execute('Any N WHERE T tags P, P is CWUser, T name N').rows, |
6abd6e3599f4
#773448: refactor session and 'no connection' handling, by introducing proper web session. We should now be able to see page even when no anon is configured, and be redirected to the login form as soon as one tries to do a query.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
583 |
[['javascript']]) |
0 | 584 |
|
585 |
def test_pending_insertion(self): |
|
1654 | 586 |
res, req = self.remote_call('add_pending_inserts', [['12', 'tags', '13']]) |
4292
3fc808b0490b
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4266
diff
changeset
|
587 |
deletes = get_pending_deletes(req) |
0 | 588 |
self.assertEquals(deletes, []) |
4292
3fc808b0490b
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4266
diff
changeset
|
589 |
inserts = get_pending_inserts(req) |
0 | 590 |
self.assertEquals(inserts, ['12:tags:13']) |
1654 | 591 |
res, req = self.remote_call('add_pending_inserts', [['12', 'tags', '14']]) |
4292
3fc808b0490b
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4266
diff
changeset
|
592 |
deletes = get_pending_deletes(req) |
0 | 593 |
self.assertEquals(deletes, []) |
4292
3fc808b0490b
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4266
diff
changeset
|
594 |
inserts = get_pending_inserts(req) |
0 | 595 |
self.assertEquals(inserts, ['12:tags:13', '12:tags:14']) |
4292
3fc808b0490b
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4266
diff
changeset
|
596 |
inserts = get_pending_inserts(req, 12) |
0 | 597 |
self.assertEquals(inserts, ['12:tags:13', '12:tags:14']) |
4292
3fc808b0490b
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4266
diff
changeset
|
598 |
inserts = get_pending_inserts(req, 13) |
0 | 599 |
self.assertEquals(inserts, ['12:tags:13']) |
4292
3fc808b0490b
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4266
diff
changeset
|
600 |
inserts = get_pending_inserts(req, 14) |
0 | 601 |
self.assertEquals(inserts, ['12:tags:14']) |
602 |
req.remove_pending_operations() |
|
603 |
||
604 |
def test_pending_deletion(self): |
|
605 |
res, req = self.remote_call('add_pending_delete', ['12', 'tags', '13']) |
|
4292
3fc808b0490b
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4266
diff
changeset
|
606 |
inserts = get_pending_inserts(req) |
0 | 607 |
self.assertEquals(inserts, []) |
4292
3fc808b0490b
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4266
diff
changeset
|
608 |
deletes = get_pending_deletes(req) |
0 | 609 |
self.assertEquals(deletes, ['12:tags:13']) |
610 |
res, req = self.remote_call('add_pending_delete', ['12', 'tags', '14']) |
|
4292
3fc808b0490b
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4266
diff
changeset
|
611 |
inserts = get_pending_inserts(req) |
0 | 612 |
self.assertEquals(inserts, []) |
4292
3fc808b0490b
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4266
diff
changeset
|
613 |
deletes = get_pending_deletes(req) |
0 | 614 |
self.assertEquals(deletes, ['12:tags:13', '12:tags:14']) |
4292
3fc808b0490b
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4266
diff
changeset
|
615 |
deletes = get_pending_deletes(req, 12) |
0 | 616 |
self.assertEquals(deletes, ['12:tags:13', '12:tags:14']) |
4292
3fc808b0490b
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4266
diff
changeset
|
617 |
deletes = get_pending_deletes(req, 13) |
0 | 618 |
self.assertEquals(deletes, ['12:tags:13']) |
4292
3fc808b0490b
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4266
diff
changeset
|
619 |
deletes = get_pending_deletes(req, 14) |
0 | 620 |
self.assertEquals(deletes, ['12:tags:14']) |
621 |
req.remove_pending_operations() |
|
622 |
||
623 |
def test_remove_pending_operations(self): |
|
624 |
self.remote_call('add_pending_delete', ['12', 'tags', '13']) |
|
1654 | 625 |
_, req = self.remote_call('add_pending_inserts', [['12', 'tags', '14']]) |
4292
3fc808b0490b
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4266
diff
changeset
|
626 |
inserts = get_pending_inserts(req) |
0 | 627 |
self.assertEquals(inserts, ['12:tags:14']) |
4292
3fc808b0490b
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4266
diff
changeset
|
628 |
deletes = get_pending_deletes(req) |
0 | 629 |
self.assertEquals(deletes, ['12:tags:13']) |
630 |
req.remove_pending_operations() |
|
4292
3fc808b0490b
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4266
diff
changeset
|
631 |
self.assertEquals(get_pending_deletes(req), []) |
3fc808b0490b
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4266
diff
changeset
|
632 |
self.assertEquals(get_pending_inserts(req), []) |
1426 | 633 |
|
0 | 634 |
|
635 |
def test_add_inserts(self): |
|
636 |
res, req = self.remote_call('add_pending_inserts', |
|
637 |
[('12', 'tags', '13'), ('12', 'tags', '14')]) |
|
4292
3fc808b0490b
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4266
diff
changeset
|
638 |
inserts = get_pending_inserts(req) |
0 | 639 |
self.assertEquals(inserts, ['12:tags:13', '12:tags:14']) |
640 |
req.remove_pending_operations() |
|
1426 | 641 |
|
0 | 642 |
|
643 |
# silly tests |
|
644 |
def test_external_resource(self): |
|
645 |
self.assertEquals(self.remote_call('external_resource', 'RSS_LOGO')[0], |
|
5377
84d14ddfae13
[python2.6] prefer python2.6's builtin json module over simplejson
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
5038
diff
changeset
|
646 |
json.dumps(self.request().external_resource('RSS_LOGO'))) |
0 | 647 |
def test_i18n(self): |
648 |
self.assertEquals(self.remote_call('i18n', ['bimboom'])[0], |
|
5377
84d14ddfae13
[python2.6] prefer python2.6's builtin json module over simplejson
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
5038
diff
changeset
|
649 |
json.dumps(['bimboom'])) |
0 | 650 |
|
651 |
def test_format_date(self): |
|
1654 | 652 |
self.assertEquals(self.remote_call('format_date', '2007-01-01 12:00:00')[0], |
5377
84d14ddfae13
[python2.6] prefer python2.6's builtin json module over simplejson
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
5038
diff
changeset
|
653 |
json.dumps('2007/01/01')) |
0 | 654 |
|
1426 | 655 |
|
0 | 656 |
|
1426 | 657 |
|
0 | 658 |
if __name__ == '__main__': |
659 |
unittest_main() |