web/test/unittest_views_editforms.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 04 Feb 2016 12:00:23 +0100
changeset 11100 5758ba784ebd
parent 10907 9ae707db5265
child 11145 d3edefdeddb4
permissions -rw-r--r--
[autoform] when building inlined-form view for a relation, consider related entities intead of other views by considering previous form-views, we may miss that there exists related entities but which are not editable. Closes #10495602
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9842
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
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: 4758
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: 4758
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: 4758
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: 4758
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: 4758
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: 4758
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: 4758
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: 4758
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: 4758
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: 4758
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: 4758
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: 4758
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: 4758
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: 4758
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: 4758
diff changeset
    17
# with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
11100
5758ba784ebd [autoform] when building inlined-form view for a relation, consider related entities intead of other views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10907
diff changeset
    18
3930
c0ae3148b893 fix test: required to fake parent form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3771
diff changeset
    19
from logilab.common.testlib import unittest_main, mock_object
11100
5758ba784ebd [autoform] when building inlined-form view for a relation, consider related entities intead of other views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10907
diff changeset
    20
from logilab.common import tempattr
3722
c414f402cbff 2.4 compat
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3589
diff changeset
    21
2773
b2530e3e0afb [testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2661
diff changeset
    22
from cubicweb.devtools.testlib import CubicWebTC
8665
e65af61bde7d [uicfg] uicfg.py moves from web/ to web/views/ (prepares #2406609)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
    23
from cubicweb.web.views import uicfg
1359
bef6891393d7 backport some tests
sylvain.thenault@logilab.fr
parents: 1300
diff changeset
    24
from cubicweb.web.formwidgets import AutoCompletionWidget
10637
a8b33789b982 [autoform] fix appearance of link to add inlined creation form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10634
diff changeset
    25
from cubicweb.schema import RRQLExpression
a8b33789b982 [autoform] fix appearance of link to add inlined creation form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10634
diff changeset
    26
3722
c414f402cbff 2.4 compat
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3589
diff changeset
    27
4080
f88331eb374c test fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3998
diff changeset
    28
AFFK = uicfg.autoform_field_kwargs
f88331eb374c test fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3998
diff changeset
    29
AFS = uicfg.autoform_section
1287
984e249764d1 test rcategories
sylvain.thenault@logilab.fr
parents:
diff changeset
    30
4080
f88331eb374c test fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3998
diff changeset
    31
def rbc(entity, formtype, section):
4570
ede247bbbf62 follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    32
    if section in ('attributes', 'metadata', 'hidden'):
ede247bbbf62 follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    33
        permission = 'update'
ede247bbbf62 follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    34
    else:
ede247bbbf62 follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    35
        permission = 'add'
9842
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    36
    return [(rschema.type, x)
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    37
            for rschema, tschemas, x in AFS.relations_by_section(entity,
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    38
                                                                 formtype,
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    39
                                                                 section,
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    40
                                                                 permission)]
1287
984e249764d1 test rcategories
sylvain.thenault@logilab.fr
parents:
diff changeset
    41
2773
b2530e3e0afb [testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2661
diff changeset
    42
class AutomaticEntityFormTC(CubicWebTC):
1287
984e249764d1 test rcategories
sylvain.thenault@logilab.fr
parents:
diff changeset
    43
1359
bef6891393d7 backport some tests
sylvain.thenault@logilab.fr
parents: 1300
diff changeset
    44
    def test_custom_widget(self):
9842
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    45
        with self.admin_access.web_request() as req:
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    46
            AFFK.tag_subject_of(('CWUser', 'login', '*'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    47
                                {'widget': AutoCompletionWidget(autocomplete_initfunc='get_logins')})
10241
9d2f53777430 [web/test] fix 3.19 deprecation warning
Julien Cristau <julien.cristau@logilab.fr>
parents: 9990
diff changeset
    48
            form = self.vreg['forms'].select('edition', req, entity=req.user)
9842
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    49
            field = form.field_by_name('login', 'subject')
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    50
            self.assertIsInstance(field.widget, AutoCompletionWidget)
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    51
            AFFK.del_rtag('CWUser', 'login', '*', 'subject')
1533
bcd4bfff658b update rtags api
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    52
1359
bef6891393d7 backport some tests
sylvain.thenault@logilab.fr
parents: 1300
diff changeset
    53
2637
07103211e511 R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2058
diff changeset
    54
    def test_cwuser_relations_by_category(self):
9842
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    55
        with self.admin_access.web_request() as req:
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    56
            e = self.vreg['etypes'].etype_class('CWUser')(req)
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    57
            # see custom configuration in views.cwuser
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    58
            self.assertEqual(rbc(e, 'main', 'attributes'),
10243
60789eabc3b7 [web/test] don't depend on dict iteration ordering
Julien Cristau <julien.cristau@logilab.fr>
parents: 10242
diff changeset
    59
                             [('login', 'subject'),
60789eabc3b7 [web/test] don't depend on dict iteration ordering
Julien Cristau <julien.cristau@logilab.fr>
parents: 10242
diff changeset
    60
                              ('upassword', 'subject'),
60789eabc3b7 [web/test] don't depend on dict iteration ordering
Julien Cristau <julien.cristau@logilab.fr>
parents: 10242
diff changeset
    61
                              ('firstname', 'subject'),
60789eabc3b7 [web/test] don't depend on dict iteration ordering
Julien Cristau <julien.cristau@logilab.fr>
parents: 10242
diff changeset
    62
                              ('surname', 'subject'),
60789eabc3b7 [web/test] don't depend on dict iteration ordering
Julien Cristau <julien.cristau@logilab.fr>
parents: 10242
diff changeset
    63
                              ('in_group', 'subject'),
60789eabc3b7 [web/test] don't depend on dict iteration ordering
Julien Cristau <julien.cristau@logilab.fr>
parents: 10242
diff changeset
    64
                              ])
60789eabc3b7 [web/test] don't depend on dict iteration ordering
Julien Cristau <julien.cristau@logilab.fr>
parents: 10242
diff changeset
    65
            self.assertEqual(rbc(e, 'muledit', 'attributes'),
9842
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    66
                                  [('login', 'subject'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    67
                                   ('upassword', 'subject'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    68
                                   ('in_group', 'subject'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    69
                                   ])
10243
60789eabc3b7 [web/test] don't depend on dict iteration ordering
Julien Cristau <julien.cristau@logilab.fr>
parents: 10242
diff changeset
    70
            self.assertCountEqual(rbc(e, 'main', 'metadata'),
9842
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    71
                                  [('last_login_time', 'subject'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    72
                                   ('cw_source', 'subject'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    73
                                   ('creation_date', 'subject'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    74
                                   ('modification_date', 'subject'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    75
                                   ('created_by', 'subject'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    76
                                   ('owned_by', 'subject'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    77
                                   ('bookmarked_by', 'object'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    78
                                   ])
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    79
            # XXX skip 'tags' relation here and in the hidden category because
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    80
            # of some test interdependancy when pytest is launched on whole cw
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    81
            # (appears here while expected in hidden
10243
60789eabc3b7 [web/test] don't depend on dict iteration ordering
Julien Cristau <julien.cristau@logilab.fr>
parents: 10242
diff changeset
    82
            self.assertCountEqual([x for x in rbc(e, 'main', 'relations')
9842
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    83
                                   if x != ('tags', 'object')],
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    84
                                  [('connait', 'subject'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    85
                                   ('custom_workflow', 'subject'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    86
                                   ('primary_email', 'subject'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    87
                                   ('checked_by', 'object'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    88
                                   ])
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    89
            self.assertListEqual(rbc(e, 'main', 'inlined'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    90
                                  [('use_email', 'subject'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    91
                                   ])
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    92
            # owned_by is defined both as subject and object relations on CWUser
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    93
            self.assertListEqual(sorted(x for x in rbc(e, 'main', 'hidden')
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    94
                                         if x != ('tags', 'object')),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    95
                                  sorted([('for_user', 'object'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    96
                                          ('created_by', 'object'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    97
                                          ('wf_info_for', 'object'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    98
                                          ('owned_by', 'object'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
    99
                                          ]))
1298
ca02a2b5e9be test inlined rtags
sylvain.thenault@logilab.fr
parents: 1287
diff changeset
   100
ca02a2b5e9be test inlined rtags
sylvain.thenault@logilab.fr
parents: 1287
diff changeset
   101
    def test_inlined_view(self):
9842
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   102
        self.assertIn('main_inlined',
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   103
                      AFS.etype_get('CWUser', 'use_email', 'subject', 'EmailAddress'))
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   104
        self.assertNotIn('main_inlined',
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   105
                         AFS.etype_get('CWUser', 'primary_email', 'subject', 'EmailAddress'))
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   106
        self.assertIn('main_relations',
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   107
                      AFS.etype_get('CWUser', 'primary_email', 'subject', 'EmailAddress'))
1533
bcd4bfff658b update rtags api
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   108
1287
984e249764d1 test rcategories
sylvain.thenault@logilab.fr
parents:
diff changeset
   109
    def test_personne_relations_by_category(self):
9842
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   110
        with self.admin_access.web_request() as req:
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   111
            e = self.vreg['etypes'].etype_class('Personne')(req)
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   112
            self.assertListEqual(rbc(e, 'main', 'attributes'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   113
                                  [('nom', 'subject'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   114
                                   ('prenom', 'subject'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   115
                                   ('sexe', 'subject'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   116
                                   ('promo', 'subject'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   117
                                   ('titre', 'subject'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   118
                                   ('ass', 'subject'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   119
                                   ('web', 'subject'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   120
                                   ('tel', 'subject'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   121
                                   ('fax', 'subject'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   122
                                   ('datenaiss', 'subject'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   123
                                   ('test', 'subject'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   124
                                   ('description', 'subject'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   125
                                   ('salary', 'subject'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   126
                                   ])
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   127
            self.assertListEqual(rbc(e, 'muledit', 'attributes'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   128
                                  [('nom', 'subject'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   129
                                   ])
10243
60789eabc3b7 [web/test] don't depend on dict iteration ordering
Julien Cristau <julien.cristau@logilab.fr>
parents: 10242
diff changeset
   130
            self.assertCountEqual(rbc(e, 'main', 'metadata'),
9842
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   131
                                  [('cw_source', 'subject'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   132
                                   ('creation_date', 'subject'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   133
                                   ('modification_date', 'subject'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   134
                                   ('created_by', 'subject'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   135
                                   ('owned_by', 'subject'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   136
                                   ])
10243
60789eabc3b7 [web/test] don't depend on dict iteration ordering
Julien Cristau <julien.cristau@logilab.fr>
parents: 10242
diff changeset
   137
            self.assertCountEqual(rbc(e, 'main', 'relations'),
9842
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   138
                                  [('travaille', 'subject'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   139
                                   ('manager', 'object'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   140
                                   ('connait', 'object'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   141
                                   ])
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   142
            self.assertListEqual(rbc(e, 'main', 'hidden'),
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   143
                                  [])
1533
bcd4bfff658b update rtags api
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   144
1300
62d2b890a980 move tests where they belong
sylvain.thenault@logilab.fr
parents: 1298
diff changeset
   145
    def test_edition_form(self):
9842
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   146
        with self.admin_access.web_request() as req:
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   147
            rset = req.execute('CWUser X LIMIT 1')
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   148
            form = self.vreg['forms'].select('edition', req, rset=rset, row=0, col=0)
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   149
            # should be also selectable by specifying entity
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   150
            self.vreg['forms'].select('edition', req, entity=rset.get_entity(0, 0))
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   151
            self.assertFalse(any(f for f in form.fields if f is None))
1533
bcd4bfff658b update rtags api
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   152
10223
fbb370195199 [web/views] Honor 'action' attribute on AutomaticEntityForm, closes #4943392
Rémi Cardona <remi.cardona@logilab.fr>
parents: 9984
diff changeset
   153
    def test_edition_form_with_action(self):
fbb370195199 [web/views] Honor 'action' attribute on AutomaticEntityForm, closes #4943392
Rémi Cardona <remi.cardona@logilab.fr>
parents: 9984
diff changeset
   154
        with self.admin_access.web_request() as req:
fbb370195199 [web/views] Honor 'action' attribute on AutomaticEntityForm, closes #4943392
Rémi Cardona <remi.cardona@logilab.fr>
parents: 9984
diff changeset
   155
            rset = req.execute('CWUser X LIMIT 1')
fbb370195199 [web/views] Honor 'action' attribute on AutomaticEntityForm, closes #4943392
Rémi Cardona <remi.cardona@logilab.fr>
parents: 9984
diff changeset
   156
            form = self.vreg['forms'].select('edition', req, rset=rset, row=0,
fbb370195199 [web/views] Honor 'action' attribute on AutomaticEntityForm, closes #4943392
Rémi Cardona <remi.cardona@logilab.fr>
parents: 9984
diff changeset
   157
                                             col=0, action='my_custom_action')
fbb370195199 [web/views] Honor 'action' attribute on AutomaticEntityForm, closes #4943392
Rémi Cardona <remi.cardona@logilab.fr>
parents: 9984
diff changeset
   158
            self.assertEqual(form.form_action(), 'my_custom_action')
fbb370195199 [web/views] Honor 'action' attribute on AutomaticEntityForm, closes #4943392
Rémi Cardona <remi.cardona@logilab.fr>
parents: 9984
diff changeset
   159
9976
457efde98629 [views] Display attributes in entity creation form based on "add" permission
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 9842
diff changeset
   160
    def test_attribute_add_permissions(self):
457efde98629 [views] Display attributes in entity creation form based on "add" permission
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 9842
diff changeset
   161
        # https://www.cubicweb.org/ticket/4342844
457efde98629 [views] Display attributes in entity creation form based on "add" permission
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 9842
diff changeset
   162
        with self.admin_access.repo_cnx() as cnx:
10242
3efd572a137a [web/test] pass login as unicode string
Julien Cristau <julien.cristau@logilab.fr>
parents: 10241
diff changeset
   163
            self.create_user(cnx, u'toto')
9976
457efde98629 [views] Display attributes in entity creation form based on "add" permission
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 9842
diff changeset
   164
            cnx.commit()
10242
3efd572a137a [web/test] pass login as unicode string
Julien Cristau <julien.cristau@logilab.fr>
parents: 10241
diff changeset
   165
        with self.new_access(u'toto').web_request() as req:
9976
457efde98629 [views] Display attributes in entity creation form based on "add" permission
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 9842
diff changeset
   166
            e = self.vreg['etypes'].etype_class('Personne')(req)
457efde98629 [views] Display attributes in entity creation form based on "add" permission
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 9842
diff changeset
   167
            cform = self.vreg['forms'].select('edition', req, entity=e)
457efde98629 [views] Display attributes in entity creation form based on "add" permission
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 9842
diff changeset
   168
            self.assertIn('sexe',
457efde98629 [views] Display attributes in entity creation form based on "add" permission
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 9842
diff changeset
   169
                          [rschema.type
457efde98629 [views] Display attributes in entity creation form based on "add" permission
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 9842
diff changeset
   170
                           for rschema, _ in cform.editable_attributes()])
10242
3efd572a137a [web/test] pass login as unicode string
Julien Cristau <julien.cristau@logilab.fr>
parents: 10241
diff changeset
   171
            with self.new_access(u'toto').repo_cnx() as cnx:
9976
457efde98629 [views] Display attributes in entity creation form based on "add" permission
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 9842
diff changeset
   172
                person_eid = cnx.create_entity('Personne', nom=u'Robert').eid
457efde98629 [views] Display attributes in entity creation form based on "add" permission
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 9842
diff changeset
   173
                cnx.commit()
457efde98629 [views] Display attributes in entity creation form based on "add" permission
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 9842
diff changeset
   174
            person = req.entity_from_eid(person_eid)
457efde98629 [views] Display attributes in entity creation form based on "add" permission
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 9842
diff changeset
   175
            mform = self.vreg['forms'].select('edition', req, entity=person)
457efde98629 [views] Display attributes in entity creation form based on "add" permission
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 9842
diff changeset
   176
            self.assertNotIn('sexe',
457efde98629 [views] Display attributes in entity creation form based on "add" permission
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 9842
diff changeset
   177
                             [rschema.type
457efde98629 [views] Display attributes in entity creation form based on "add" permission
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 9842
diff changeset
   178
                              for rschema, _ in mform.editable_attributes()])
1533
bcd4bfff658b update rtags api
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   179
10634
06a43f727601 [web/views] avoid propagation of NoSelectableObject in some case of inlined relations / permissions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10386
diff changeset
   180
    def test_inlined_relations(self):
06a43f727601 [web/views] avoid propagation of NoSelectableObject in some case of inlined relations / permissions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10386
diff changeset
   181
        with self.admin_access.web_request() as req:
06a43f727601 [web/views] avoid propagation of NoSelectableObject in some case of inlined relations / permissions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10386
diff changeset
   182
            with self.temporary_permissions(EmailAddress={'add': ()}):
06a43f727601 [web/views] avoid propagation of NoSelectableObject in some case of inlined relations / permissions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10386
diff changeset
   183
                autoform = self.vreg['forms'].select('edition', req, entity=req.user)
06a43f727601 [web/views] avoid propagation of NoSelectableObject in some case of inlined relations / permissions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10386
diff changeset
   184
                self.assertEqual(list(autoform.inlined_form_views()), [])
06a43f727601 [web/views] avoid propagation of NoSelectableObject in some case of inlined relations / permissions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10386
diff changeset
   185
11100
5758ba784ebd [autoform] when building inlined-form view for a relation, consider related entities intead of other views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10907
diff changeset
   186
    def test_inlined_form_views(self):
5758ba784ebd [autoform] when building inlined-form view for a relation, consider related entities intead of other views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10907
diff changeset
   187
        # when some relation has + cardinality, and some already linked entities which are not
5758ba784ebd [autoform] when building inlined-form view for a relation, consider related entities intead of other views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10907
diff changeset
   188
        # updatable, a link to optionally add a new sub-entity should be displayed, not a sub-form
5758ba784ebd [autoform] when building inlined-form view for a relation, consider related entities intead of other views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10907
diff changeset
   189
        # forcing creation of a sub-entity
5758ba784ebd [autoform] when building inlined-form view for a relation, consider related entities intead of other views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10907
diff changeset
   190
        from cubicweb.web.views import autoform
5758ba784ebd [autoform] when building inlined-form view for a relation, consider related entities intead of other views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10907
diff changeset
   191
        with self.admin_access.web_request() as req:
5758ba784ebd [autoform] when building inlined-form view for a relation, consider related entities intead of other views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10907
diff changeset
   192
            req.create_entity('EmailAddress', address=u'admin@cubicweb.org',
5758ba784ebd [autoform] when building inlined-form view for a relation, consider related entities intead of other views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10907
diff changeset
   193
                              reverse_use_email=req.user.eid)
5758ba784ebd [autoform] when building inlined-form view for a relation, consider related entities intead of other views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10907
diff changeset
   194
            use_email_schema = self.vreg.schema['CWUser'].rdef('use_email')
5758ba784ebd [autoform] when building inlined-form view for a relation, consider related entities intead of other views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10907
diff changeset
   195
            with tempattr(use_email_schema, 'cardinality', '+1'):
5758ba784ebd [autoform] when building inlined-form view for a relation, consider related entities intead of other views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10907
diff changeset
   196
                with self.temporary_permissions(EmailAddress={'update': ()}):
5758ba784ebd [autoform] when building inlined-form view for a relation, consider related entities intead of other views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10907
diff changeset
   197
                    form = self.vreg['forms'].select('edition', req, entity=req.user)
5758ba784ebd [autoform] when building inlined-form view for a relation, consider related entities intead of other views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10907
diff changeset
   198
                    formviews = list(form.inlined_form_views())
5758ba784ebd [autoform] when building inlined-form view for a relation, consider related entities intead of other views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10907
diff changeset
   199
                    self.assertEqual(len(formviews), 1, formviews)
5758ba784ebd [autoform] when building inlined-form view for a relation, consider related entities intead of other views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10907
diff changeset
   200
                    self.assertIsInstance(formviews[0], autoform.InlineAddNewLinkView)
5758ba784ebd [autoform] when building inlined-form view for a relation, consider related entities intead of other views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10907
diff changeset
   201
10637
a8b33789b982 [autoform] fix appearance of link to add inlined creation form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10634
diff changeset
   202
    def test_check_inlined_rdef_permissions(self):
a8b33789b982 [autoform] fix appearance of link to add inlined creation form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10634
diff changeset
   203
        # try to check permissions when creating an entity ('user' below is a
a8b33789b982 [autoform] fix appearance of link to add inlined creation form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10634
diff changeset
   204
        # fresh entity without an eid)
a8b33789b982 [autoform] fix appearance of link to add inlined creation form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10634
diff changeset
   205
        with self.admin_access.web_request() as req:
a8b33789b982 [autoform] fix appearance of link to add inlined creation form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10634
diff changeset
   206
            ttype = 'EmailAddress'
a8b33789b982 [autoform] fix appearance of link to add inlined creation form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10634
diff changeset
   207
            rschema = self.schema['use_email']
a8b33789b982 [autoform] fix appearance of link to add inlined creation form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10634
diff changeset
   208
            rdef =  rschema.rdefs[('CWUser', ttype)]
a8b33789b982 [autoform] fix appearance of link to add inlined creation form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10634
diff changeset
   209
            tschema = self.schema[ttype]
a8b33789b982 [autoform] fix appearance of link to add inlined creation form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10634
diff changeset
   210
            role = 'subject'
a8b33789b982 [autoform] fix appearance of link to add inlined creation form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10634
diff changeset
   211
            with self.temporary_permissions((rdef, {'add': ()})):
a8b33789b982 [autoform] fix appearance of link to add inlined creation form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10634
diff changeset
   212
                user = self.vreg['etypes'].etype_class('CWUser')(req)
a8b33789b982 [autoform] fix appearance of link to add inlined creation form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10634
diff changeset
   213
                autoform = self.vreg['forms'].select('edition', req, entity=user)
a8b33789b982 [autoform] fix appearance of link to add inlined creation form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10634
diff changeset
   214
                self.assertFalse(autoform.check_inlined_rdef_permissions(rschema, role,
a8b33789b982 [autoform] fix appearance of link to add inlined creation form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10634
diff changeset
   215
                                                                         tschema, ttype))
a8b33789b982 [autoform] fix appearance of link to add inlined creation form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10634
diff changeset
   216
            # we actually don't care about the actual expression,
a8b33789b982 [autoform] fix appearance of link to add inlined creation form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10634
diff changeset
   217
            # may_have_permission only checks the presence of such expressions
a8b33789b982 [autoform] fix appearance of link to add inlined creation form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10634
diff changeset
   218
            expr = RRQLExpression('S use_email O')
a8b33789b982 [autoform] fix appearance of link to add inlined creation form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10634
diff changeset
   219
            with self.temporary_permissions((rdef, {'add': (expr,)})):
a8b33789b982 [autoform] fix appearance of link to add inlined creation form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10634
diff changeset
   220
                user = self.vreg['etypes'].etype_class('CWUser')(req)
a8b33789b982 [autoform] fix appearance of link to add inlined creation form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10634
diff changeset
   221
                autoform = self.vreg['forms'].select('edition', req, entity=user)
a8b33789b982 [autoform] fix appearance of link to add inlined creation form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10634
diff changeset
   222
                self.assertTrue(autoform.check_inlined_rdef_permissions(rschema, role,
a8b33789b982 [autoform] fix appearance of link to add inlined creation form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10634
diff changeset
   223
                                                                        tschema, ttype))
a8b33789b982 [autoform] fix appearance of link to add inlined creation form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10634
diff changeset
   224
1533
bcd4bfff658b update rtags api
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   225
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
class FormViewsTC(CubicWebTC):
9842
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   227
1300
62d2b890a980 move tests where they belong
sylvain.thenault@logilab.fr
parents: 1298
diff changeset
   228
    def test_delete_conf_formview(self):
9842
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   229
        with self.admin_access.web_request() as req:
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   230
            rset = req.execute('CWGroup X')
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   231
            self.view('deleteconf', rset, template=None, req=req).source
1533
bcd4bfff658b update rtags api
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   232
1300
62d2b890a980 move tests where they belong
sylvain.thenault@logilab.fr
parents: 1298
diff changeset
   233
    def test_automatic_edition_formview(self):
9842
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   234
        with self.admin_access.web_request() as req:
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   235
            rset = req.execute('CWUser X')
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   236
            self.view('edition', rset, row=0, template=None, req=req).source
1533
bcd4bfff658b update rtags api
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   237
9842
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   238
    def test_automatic_edition_copyformview(self):
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   239
        with self.admin_access.web_request() as req:
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   240
            rset = req.execute('CWUser X')
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   241
            self.view('copy', rset, row=0, template=None, req=req).source
1533
bcd4bfff658b update rtags api
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   242
1300
62d2b890a980 move tests where they belong
sylvain.thenault@logilab.fr
parents: 1298
diff changeset
   243
    def test_automatic_creation_formview(self):
9842
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   244
        with self.admin_access.web_request() as req:
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   245
            self.view('creation', None, etype='CWUser', template=None, req=req).source
1533
bcd4bfff658b update rtags api
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   246
1300
62d2b890a980 move tests where they belong
sylvain.thenault@logilab.fr
parents: 1298
diff changeset
   247
    def test_automatic_muledit_formview(self):
9842
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   248
        with self.admin_access.web_request() as req:
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   249
            rset = req.execute('CWUser X')
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   250
            self.view('muledit', rset, template=None, req=req).source
1533
bcd4bfff658b update rtags api
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   251
1300
62d2b890a980 move tests where they belong
sylvain.thenault@logilab.fr
parents: 1298
diff changeset
   252
    def test_automatic_reledit_formview(self):
9842
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   253
        with self.admin_access.web_request() as req:
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   254
            rset = req.execute('CWUser X')
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   255
            self.view('reledit', rset, row=0, rtype='login', template=None, req=req).source
1533
bcd4bfff658b update rtags api
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   256
1300
62d2b890a980 move tests where they belong
sylvain.thenault@logilab.fr
parents: 1298
diff changeset
   257
    def test_automatic_inline_edit_formview(self):
9842
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   258
        with self.admin_access.web_request() as req:
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   259
            geid = req.execute('CWGroup X LIMIT 1')[0][0]
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   260
            rset = req.execute('CWUser X LIMIT 1')
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   261
            self.view('inline-edition', rset, row=0, col=0, rtype='in_group',
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   262
                      peid=geid, role='object', i18nctx='', pform=MOCKPFORM,
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   263
                      template=None, req=req).source
1533
bcd4bfff658b update rtags api
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   264
1300
62d2b890a980 move tests where they belong
sylvain.thenault@logilab.fr
parents: 1298
diff changeset
   265
    def test_automatic_inline_creation_formview(self):
9842
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   266
        with self.admin_access.web_request() as req:
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   267
            geid = req.execute('CWGroup X LIMIT 1')[0][0]
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   268
            self.view('inline-creation', None, etype='CWUser', rtype='in_group',
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   269
                      peid=geid, petype='CWGroup', i18nctx='', role='object', pform=MOCKPFORM,
78d1beebdebc [webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8665
diff changeset
   270
                      template=None, req=req)
1300
62d2b890a980 move tests where they belong
sylvain.thenault@logilab.fr
parents: 1298
diff changeset
   271
3930
c0ae3148b893 fix test: required to fake parent form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3771
diff changeset
   272
MOCKPFORM = mock_object(form_previous_values={}, form_valerror=None)
1533
bcd4bfff658b update rtags api
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   273
1287
984e249764d1 test rcategories
sylvain.thenault@logilab.fr
parents:
diff changeset
   274
if __name__ == '__main__':
984e249764d1 test rcategories
sylvain.thenault@logilab.fr
parents:
diff changeset
   275
    unittest_main()