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