web/test/unittest_views_actions.py
author Aurelien Campeas <aurelien.campeas@logilab.fr>
Mon, 02 Jun 2014 12:36:43 +0200
changeset 9803 5bd395e9649a
parent 9198 c32a21bf88bb
child 9808 d121b74e043f
permissions -rw-r--r--
[tests/repository] use the new connection api (part 2/2) Some notes: * module imports cleanup * the unimplemented `test_transaction_interleaved` is wiped
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9197
9905d9efa4a3 [web test] silent 3.13 warning
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8849
diff changeset
     1
# copyright 2003-2013 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
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    19
from logilab.common.testlib import unittest_main
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    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
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    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
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    25
    def test_view_action(self):
9197
9905d9efa4a3 [web test] silent 3.13 warning
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8849
diff changeset
    26
        req = self.request(vid='rss', rql='CWUser X')
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 0
diff changeset
    27
        rset = self.execute('CWUser X')
2813
0cf6c8005bf6 R propagate deprecation of CWRegistry.possible_vobjects
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2773
diff changeset
    28
        actions = self.vreg['actions'].poss_visible_objects(req, rset=rset)
3466
beabe54a8664 [tests] make unittest_views_actions pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2813
diff changeset
    29
        vaction = [action for action in actions if action.__regid__ == 'view'][0]
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    30
        self.assertEqual(vaction.url(), 'http://testing.fr/cubicweb/view?rql=CWUser%20X')
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    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']
c32a21bf88bb [web] consider inlined relations in has_editable_relation. Closes #3049970
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9197
diff changeset
    37
        with self.temporary_permissions((use_email, {'add': ('guests',)}),
c32a21bf88bb [web] consider inlined relations in has_editable_relation. Closes #3049970
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9197
diff changeset
    38
                                        ):
c32a21bf88bb [web] consider inlined relations in has_editable_relation. Closes #3049970
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9197
diff changeset
    39
            with self.login('anon'):
c32a21bf88bb [web] consider inlined relations in has_editable_relation. Closes #3049970
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9197
diff changeset
    40
                req = self.request()
c32a21bf88bb [web] consider inlined relations in has_editable_relation. Closes #3049970
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9197
diff changeset
    41
                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
    42
                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
    43
                                 1)
1802
d628defebc17 delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1398
diff changeset
    44
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    45
if __name__ == '__main__':
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    46
    unittest_main()