author | Adrien Di Mascio <Adrien.DiMascio@logilab.fr> |
Wed, 23 Sep 2009 09:52:52 +0200 | |
changeset 3394 | 51a25bdd7bdc |
parent 3369 | 7b88d12b4ee2 |
child 3589 | a5432f99f2d9 |
permissions | -rw-r--r-- |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1797
diff
changeset
|
1 |
""" |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1797
diff
changeset
|
2 |
|
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1797
diff
changeset
|
3 |
:organization: Logilab |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1797
diff
changeset
|
4 |
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1797
diff
changeset
|
5 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1797
diff
changeset
|
6 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1797
diff
changeset
|
7 |
""" |
1287 | 8 |
from logilab.common.testlib import unittest_main |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
9 |
from cubicweb.devtools.testlib import CubicWebTC |
1654 | 10 |
from cubicweb.web.views.autoform import AutomaticEntityForm as AEF |
1359 | 11 |
from cubicweb.web.formwidgets import AutoCompletionWidget |
1287 | 12 |
def rbc(entity, category): |
13 |
return [(rschema.type, x) for rschema, tschemas, x in AEF.erelations_by_category(entity, category)] |
|
14 |
||
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
15 |
class AutomaticEntityFormTC(CubicWebTC): |
1287 | 16 |
|
1359 | 17 |
def test_custom_widget(self): |
1797
c2a80130b06d
fix some web tests, adjusts rtags
sylvain.thenault@logilab.fr
parents:
1739
diff
changeset
|
18 |
AEF.rfields_kwargs.tag_subject_of(('CWUser', 'login', '*'), |
2643
9976f511003b
web test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2637
diff
changeset
|
19 |
{'widget': AutoCompletionWidget(autocomplete_initfunc='get_logins')}) |
2661
f8df42c9da6b
[vreg api update] remove some deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
20 |
form = self.vreg['forms'].select('edition', self.request(), |
f8df42c9da6b
[vreg api update] remove some deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
21 |
entity=self.user()) |
1359 | 22 |
field = form.field_by_name('login') |
23 |
self.assertIsInstance(field.widget, AutoCompletionWidget) |
|
1797
c2a80130b06d
fix some web tests, adjusts rtags
sylvain.thenault@logilab.fr
parents:
1739
diff
changeset
|
24 |
AEF.rfields_kwargs.del_rtag('CWUser', 'login', '*', 'subject') |
1533 | 25 |
|
1359 | 26 |
|
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2058
diff
changeset
|
27 |
def test_cwuser_relations_by_category(self): |
1287 | 28 |
#for (rtype, role, stype, otype), tag in AEF.rcategories._tagdefs.items(): |
29 |
# if rtype == 'tags': |
|
30 |
# print rtype, role, stype, otype, ':', tag |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
31 |
e = self.vreg['etypes'].etype_class('CWUser')(self.request()) |
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2058
diff
changeset
|
32 |
# see custom configuration in views.cwuser |
1287 | 33 |
self.assertEquals(rbc(e, 'primary'), |
34 |
[('login', 'subject'), |
|
35 |
('upassword', 'subject'), |
|
36 |
('in_group', 'subject'), |
|
37 |
('in_state', 'subject'), |
|
38 |
('eid', 'subject'), |
|
39 |
]) |
|
40 |
self.assertListEquals(rbc(e, 'secondary'), |
|
41 |
[('firstname', 'subject'), |
|
42 |
('surname', 'subject') |
|
43 |
]) |
|
44 |
self.assertListEquals(rbc(e, 'metadata'), |
|
45 |
[('last_login_time', 'subject'), |
|
46 |
('created_by', 'subject'), |
|
47 |
('creation_date', 'subject'), |
|
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2058
diff
changeset
|
48 |
('cwuri', 'subject'), |
1287 | 49 |
('modification_date', 'subject'), |
50 |
('owned_by', 'subject'), |
|
51 |
('bookmarked_by', 'object'), |
|
1533 | 52 |
]) |
1287 | 53 |
self.assertListEquals(rbc(e, 'generic'), |
1797
c2a80130b06d
fix some web tests, adjusts rtags
sylvain.thenault@logilab.fr
parents:
1739
diff
changeset
|
54 |
[('primary_email', 'subject'), |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
55 |
('custom_workflow', 'subject'), |
1797
c2a80130b06d
fix some web tests, adjusts rtags
sylvain.thenault@logilab.fr
parents:
1739
diff
changeset
|
56 |
('connait', 'subject'), |
1287 | 57 |
('checked_by', 'object'), |
58 |
]) |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1359
diff
changeset
|
59 |
# owned_by is defined both as subject and object relations on CWUser |
1287 | 60 |
self.assertListEquals(rbc(e, 'generated'), |
1797
c2a80130b06d
fix some web tests, adjusts rtags
sylvain.thenault@logilab.fr
parents:
1739
diff
changeset
|
61 |
[('use_email', 'subject'), |
1654 | 62 |
('has_text', 'subject'), |
1300 | 63 |
('identity', 'subject'), |
64 |
('is', 'subject'), |
|
1287 | 65 |
('is_instance_of', 'subject'), |
66 |
('tags', 'object'), |
|
67 |
('for_user', 'object'), |
|
68 |
('created_by', 'object'), |
|
69 |
('wf_info_for', 'object'), |
|
70 |
('owned_by', 'object'), |
|
1300 | 71 |
('identity', 'object'), |
1287 | 72 |
]) |
1298 | 73 |
|
74 |
def test_inlined_view(self): |
|
1540
996355824825
more rtags api change propagation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1533
diff
changeset
|
75 |
self.failUnless(AEF.rinlined.etype_get('CWUser', 'use_email', 'subject')) |
996355824825
more rtags api change propagation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1533
diff
changeset
|
76 |
self.failIf(AEF.rinlined.etype_get('CWUser', 'primary_email', 'subject')) |
1533 | 77 |
|
1287 | 78 |
def test_personne_relations_by_category(self): |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
79 |
e = self.vreg['etypes'].etype_class('Personne')(self.request()) |
1287 | 80 |
self.assertListEquals(rbc(e, 'primary'), |
81 |
[('nom', 'subject'), |
|
82 |
('eid', 'subject') |
|
83 |
]) |
|
84 |
self.assertListEquals(rbc(e, 'secondary'), |
|
85 |
[('prenom', 'subject'), |
|
86 |
('sexe', 'subject'), |
|
87 |
('promo', 'subject'), |
|
88 |
('titre', 'subject'), |
|
89 |
('ass', 'subject'), |
|
90 |
('web', 'subject'), |
|
91 |
('tel', 'subject'), |
|
92 |
('fax', 'subject'), |
|
93 |
('datenaiss', 'subject'), |
|
94 |
('test', 'subject'), |
|
95 |
('description', 'subject'), |
|
96 |
('salary', 'subject') |
|
97 |
]) |
|
98 |
self.assertListEquals(rbc(e, 'metadata'), |
|
99 |
[('created_by', 'subject'), |
|
100 |
('creation_date', 'subject'), |
|
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2058
diff
changeset
|
101 |
('cwuri', 'subject'), |
1287 | 102 |
('modification_date', 'subject'), |
103 |
('owned_by', 'subject'), |
|
1533 | 104 |
]) |
1287 | 105 |
self.assertListEquals(rbc(e, 'generic'), |
106 |
[('travaille', 'subject'), |
|
107 |
('connait', 'object') |
|
108 |
]) |
|
109 |
self.assertListEquals(rbc(e, 'generated'), |
|
1300 | 110 |
[('has_text', 'subject'), |
111 |
('identity', 'subject'), |
|
112 |
('is', 'subject'), |
|
1287 | 113 |
('is_instance_of', 'subject'), |
1300 | 114 |
('identity', 'object'), |
1287 | 115 |
]) |
1533 | 116 |
|
1300 | 117 |
def test_edition_form(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1359
diff
changeset
|
118 |
rset = self.execute('CWUser X LIMIT 1') |
2661
f8df42c9da6b
[vreg api update] remove some deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
119 |
form = self.vreg['forms'].select('edition', rset.req, rset=rset, |
2058
7ef12c03447c
nicer vreg api, try to make rset an optional named argument in select and derivated (including selectors)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
120 |
row=0, col=0) |
1300 | 121 |
# should be also selectable by specifying entity |
2661
f8df42c9da6b
[vreg api update] remove some deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
122 |
self.vreg['forms'].select('edition', rset.req, |
2058
7ef12c03447c
nicer vreg api, try to make rset an optional named argument in select and derivated (including selectors)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
123 |
entity=rset.get_entity(0, 0)) |
1300 | 124 |
self.failIf(any(f for f in form.fields if f is None)) |
1533 | 125 |
|
126 |
||
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
127 |
class FormViewsTC(CubicWebTC): |
1300 | 128 |
def test_delete_conf_formview(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1359
diff
changeset
|
129 |
rset = self.execute('CWGroup X') |
1300 | 130 |
self.view('deleteconf', rset, template=None).source |
1533 | 131 |
|
1300 | 132 |
def test_automatic_edition_formview(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1359
diff
changeset
|
133 |
rset = self.execute('CWUser X') |
1300 | 134 |
self.view('edition', rset, row=0, template=None).source |
1533 | 135 |
|
1300 | 136 |
def test_automatic_edition_formview(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1359
diff
changeset
|
137 |
rset = self.execute('CWUser X') |
1300 | 138 |
self.view('copy', rset, row=0, template=None).source |
1533 | 139 |
|
1300 | 140 |
def test_automatic_creation_formview(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1359
diff
changeset
|
141 |
self.view('creation', None, etype='CWUser', template=None).source |
1533 | 142 |
|
1300 | 143 |
def test_automatic_muledit_formview(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1359
diff
changeset
|
144 |
rset = self.execute('CWUser X') |
1300 | 145 |
self.view('muledit', rset, template=None).source |
1533 | 146 |
|
1300 | 147 |
def test_automatic_reledit_formview(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1359
diff
changeset
|
148 |
rset = self.execute('CWUser X') |
1300 | 149 |
self.view('reledit', rset, row=0, rtype='login', template=None).source |
1533 | 150 |
|
1300 | 151 |
def test_automatic_inline_edit_formview(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1359
diff
changeset
|
152 |
geid = self.execute('CWGroup X LIMIT 1')[0][0] |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1359
diff
changeset
|
153 |
rset = self.execute('CWUser X LIMIT 1') |
3361
be0605689fed
[tests] fix inline-creation/edition unit tests
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2920
diff
changeset
|
154 |
self.view('inline-edition', rset, row=0, col=0, rtype='in_group', |
be0605689fed
[tests] fix inline-creation/edition unit tests
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2920
diff
changeset
|
155 |
peid=geid, role='subject', template=None, i18nctx='').source |
1533 | 156 |
|
1300 | 157 |
def test_automatic_inline_creation_formview(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1359
diff
changeset
|
158 |
geid = self.execute('CWGroup X LIMIT 1')[0][0] |
3361
be0605689fed
[tests] fix inline-creation/edition unit tests
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2920
diff
changeset
|
159 |
self.view('inline-creation', None, etype='CWUser', rtype='in_group', |
be0605689fed
[tests] fix inline-creation/edition unit tests
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2920
diff
changeset
|
160 |
peid=geid, template=None, i18nctx='', role='subject').source |
1300 | 161 |
|
1533 | 162 |
|
1287 | 163 |
if __name__ == '__main__': |
164 |
unittest_main() |
|
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2058
diff
changeset
|
165 |