author | Aurelien Campeas <aurelien.campeas@logilab.fr> |
Wed, 11 Jun 2014 15:32:07 +0200 | |
changeset 10364 | 8b35a898b334 |
parent 9808 | d121b74e043f |
child 10635 | 2b1cb1ba8df5 |
permissions | -rw-r--r-- |
9808
d121b74e043f
[webtests/views_actions] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9198
diff
changeset
|
1 |
# copyright 2003-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
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:
4252
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:
4252
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:
4252
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:
4252
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:
4252
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:
4252
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:
4252
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:
4252
diff
changeset
|
10 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
11 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
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:
4252
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:
4252
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:
4252
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:
4252
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:
4252
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:
1802
diff
changeset
|
18 |
|
0 | 19 |
from logilab.common.testlib import unittest_main |
20 |
||
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
21 |
from cubicweb.devtools.testlib import CubicWebTC |
9198
c32a21bf88bb
[web] consider inlined relations in has_editable_relation. Closes #3049970
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9197
diff
changeset
|
22 |
from cubicweb.web.views import actions, uicfg |
0 | 23 |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
24 |
class ActionsTC(CubicWebTC): |
0 | 25 |
def test_view_action(self): |
9808
d121b74e043f
[webtests/views_actions] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9198
diff
changeset
|
26 |
with self.admin_access.web_request(vid='rss', rql='CWUser X') as req: |
d121b74e043f
[webtests/views_actions] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9198
diff
changeset
|
27 |
rset = req.execute('CWUser X') |
d121b74e043f
[webtests/views_actions] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9198
diff
changeset
|
28 |
actions = self.vreg['actions'].poss_visible_objects(req, rset=rset) |
d121b74e043f
[webtests/views_actions] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9198
diff
changeset
|
29 |
vaction = [action for action in actions if action.__regid__ == 'view'][0] |
d121b74e043f
[webtests/views_actions] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9198
diff
changeset
|
30 |
self.assertEqual(vaction.url(), 'http://testing.fr/cubicweb/view?rql=CWUser%20X') |
0 | 31 |
|
9198
c32a21bf88bb
[web] consider inlined relations in has_editable_relation. Closes #3049970
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9197
diff
changeset
|
32 |
def test_has_editable_relations(self): |
c32a21bf88bb
[web] consider inlined relations in has_editable_relation. Closes #3049970
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9197
diff
changeset
|
33 |
"""ensure has_editable_relation predicate used by ModifyAction |
c32a21bf88bb
[web] consider inlined relations in has_editable_relation. Closes #3049970
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9197
diff
changeset
|
34 |
return positive score if there is only some inlined forms |
c32a21bf88bb
[web] consider inlined relations in has_editable_relation. Closes #3049970
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9197
diff
changeset
|
35 |
""" |
c32a21bf88bb
[web] consider inlined relations in has_editable_relation. Closes #3049970
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9197
diff
changeset
|
36 |
use_email = self.schema['use_email'].rdefs['CWUser', 'EmailAddress'] |
9808
d121b74e043f
[webtests/views_actions] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9198
diff
changeset
|
37 |
with self.temporary_permissions((use_email, {'add': ('guests',)})): |
d121b74e043f
[webtests/views_actions] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9198
diff
changeset
|
38 |
with self.new_access('anon').web_request() as req: |
9198
c32a21bf88bb
[web] consider inlined relations in has_editable_relation. Closes #3049970
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9197
diff
changeset
|
39 |
predicate = actions.has_editable_relation() |
c32a21bf88bb
[web] consider inlined relations in has_editable_relation. Closes #3049970
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9197
diff
changeset
|
40 |
self.assertEqual(predicate(None, req, rset=req.user.as_rset()), |
c32a21bf88bb
[web] consider inlined relations in has_editable_relation. Closes #3049970
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9197
diff
changeset
|
41 |
1) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
42 |
|
0 | 43 |
if __name__ == '__main__': |
44 |
unittest_main() |