author | Julien Cristau <julien.cristau@logilab.fr> |
Thu, 03 Jul 2014 12:18:34 +0200 | |
changeset 9867 | 7f36f31d8828 |
parent 9842 | 78d1beebdebc |
child 9897 | fa44db7da2dc |
child 9976 | 457efde98629 |
permissions | -rw-r--r-- |
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/>. |
3930
c0ae3148b893
fix test: required to fake parent form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3771
diff
changeset
|
18 |
from logilab.common.testlib import unittest_main, mock_object |
3722 | 19 |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
20 |
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
|
21 |
from cubicweb.web.views import uicfg |
1359 | 22 |
from cubicweb.web.formwidgets import AutoCompletionWidget |
3722 | 23 |
|
4080 | 24 |
AFFK = uicfg.autoform_field_kwargs |
25 |
AFS = uicfg.autoform_section |
|
1287 | 26 |
|
4080 | 27 |
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
|
28 |
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
|
29 |
permission = 'update' |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
30 |
else: |
ede247bbbf62
follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
31 |
permission = 'add' |
9842
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
32 |
return [(rschema.type, x) |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
33 |
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
|
34 |
formtype, |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
35 |
section, |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
36 |
permission)] |
1287 | 37 |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
38 |
class AutomaticEntityFormTC(CubicWebTC): |
1287 | 39 |
|
1359 | 40 |
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
|
41 |
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
|
42 |
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
|
43 |
{'widget': AutoCompletionWidget(autocomplete_initfunc='get_logins')}) |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
44 |
form = self.vreg['forms'].select('edition', req, entity=self.user(req)) |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
45 |
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
|
46 |
self.assertIsInstance(field.widget, AutoCompletionWidget) |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
47 |
AFFK.del_rtag('CWUser', 'login', '*', 'subject') |
1533 | 48 |
|
1359 | 49 |
|
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2058
diff
changeset
|
50 |
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
|
51 |
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
|
52 |
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
|
53 |
# 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
|
54 |
self.assertEqual(rbc(e, 'main', 'attributes'), |
4080 | 55 |
[('login', 'subject'), |
56 |
('upassword', 'subject'), |
|
9842
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
57 |
('firstname', 'subject'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
58 |
('surname', 'subject'), |
4080 | 59 |
('in_group', 'subject'), |
1287 | 60 |
]) |
9842
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
61 |
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
|
62 |
[('login', 'subject'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
63 |
('upassword', 'subject'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
64 |
('in_group', 'subject'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
65 |
]) |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
66 |
self.assertListEqual(rbc(e, 'main', 'metadata'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
67 |
[('last_login_time', 'subject'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
68 |
('cw_source', 'subject'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
69 |
('creation_date', 'subject'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
70 |
('cwuri', 'subject'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
71 |
('modification_date', 'subject'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
72 |
('created_by', 'subject'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
73 |
('owned_by', 'subject'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
74 |
('bookmarked_by', 'object'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
75 |
]) |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
76 |
# 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
|
77 |
# 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
|
78 |
# (appears here while expected in hidden |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
79 |
self.assertListEqual([x for x in rbc(e, 'main', 'relations') |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
80 |
if x != ('tags', 'object')], |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
81 |
[('connait', 'subject'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
82 |
('custom_workflow', 'subject'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
83 |
('primary_email', 'subject'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
84 |
('checked_by', 'object'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
85 |
]) |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
86 |
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
|
87 |
[('use_email', 'subject'), |
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 |
# 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
|
90 |
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
|
91 |
if x != ('tags', 'object')), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
92 |
sorted([('for_user', 'object'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
93 |
('created_by', 'object'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
94 |
('wf_info_for', 'object'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
95 |
('owned_by', 'object'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
96 |
])) |
1298 | 97 |
|
98 |
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
|
99 |
self.assertIn('main_inlined', |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
100 |
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
|
101 |
self.assertNotIn('main_inlined', |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
102 |
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
|
103 |
self.assertIn('main_relations', |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
104 |
AFS.etype_get('CWUser', 'primary_email', 'subject', 'EmailAddress')) |
1533 | 105 |
|
1287 | 106 |
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
|
107 |
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
|
108 |
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
|
109 |
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
|
110 |
[('nom', 'subject'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
111 |
('prenom', 'subject'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
112 |
('sexe', 'subject'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
113 |
('promo', 'subject'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
114 |
('titre', 'subject'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
115 |
('ass', 'subject'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
116 |
('web', 'subject'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
117 |
('tel', 'subject'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
118 |
('fax', 'subject'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
119 |
('datenaiss', 'subject'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
120 |
('test', 'subject'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
121 |
('description', 'subject'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
122 |
('salary', 'subject'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
123 |
]) |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
124 |
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
|
125 |
[('nom', '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, 'main', 'metadata'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
128 |
[('cw_source', 'subject'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
129 |
('creation_date', 'subject'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
130 |
('cwuri', 'subject'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
131 |
('modification_date', 'subject'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
132 |
('created_by', 'subject'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
133 |
('owned_by', 'subject'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
134 |
]) |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
135 |
self.assertListEqual(rbc(e, 'main', 'relations'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
136 |
[('travaille', 'subject'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
137 |
('manager', 'object'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
138 |
('connait', 'object'), |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
139 |
]) |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
140 |
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
|
141 |
[]) |
1533 | 142 |
|
1300 | 143 |
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
|
144 |
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
|
145 |
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
|
146 |
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
|
147 |
# 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
|
148 |
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
|
149 |
self.assertFalse(any(f for f in form.fields if f is None)) |
1533 | 150 |
|
151 |
||
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
152 |
class FormViewsTC(CubicWebTC): |
9842
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
153 |
|
1300 | 154 |
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
|
155 |
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
|
156 |
rset = req.execute('CWGroup X') |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
157 |
self.view('deleteconf', rset, template=None, req=req).source |
1533 | 158 |
|
1300 | 159 |
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
|
160 |
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
|
161 |
rset = req.execute('CWUser X') |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
162 |
self.view('edition', rset, row=0, template=None, req=req).source |
1533 | 163 |
|
9842
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
164 |
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
|
165 |
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
|
166 |
rset = req.execute('CWUser X') |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
167 |
self.view('copy', rset, row=0, template=None, req=req).source |
1533 | 168 |
|
1300 | 169 |
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
|
170 |
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
|
171 |
self.view('creation', None, etype='CWUser', template=None, req=req).source |
1533 | 172 |
|
1300 | 173 |
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
|
174 |
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
|
175 |
rset = req.execute('CWUser X') |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
176 |
self.view('muledit', rset, template=None, req=req).source |
1533 | 177 |
|
1300 | 178 |
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
|
179 |
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
|
180 |
rset = req.execute('CWUser X') |
78d1beebdebc
[webtests/views_editforms] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
181 |
self.view('reledit', rset, row=0, rtype='login', template=None, req=req).source |
1533 | 182 |
|
1300 | 183 |
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
|
184 |
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
|
185 |
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
|
186 |
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
|
187 |
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
|
188 |
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
|
189 |
template=None, req=req).source |
1533 | 190 |
|
1300 | 191 |
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
|
192 |
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
|
193 |
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
|
194 |
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
|
195 |
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
|
196 |
template=None, req=req) |
1300 | 197 |
|
3930
c0ae3148b893
fix test: required to fake parent form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3771
diff
changeset
|
198 |
MOCKPFORM = mock_object(form_previous_values={}, form_valerror=None) |
1533 | 199 |
|
1287 | 200 |
if __name__ == '__main__': |
201 |
unittest_main() |
|
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2058
diff
changeset
|
202 |