7 return [(rschema.type, x) for rschema, tschemas, x in AEF.erelations_by_category(entity, category)] |
7 return [(rschema.type, x) for rschema, tschemas, x in AEF.erelations_by_category(entity, category)] |
8 |
8 |
9 class AutomaticEntityFormTC(EnvBasedTC): |
9 class AutomaticEntityFormTC(EnvBasedTC): |
10 |
10 |
11 def test_custom_widget(self): |
11 def test_custom_widget(self): |
12 AEF.rwidgets.set_rtag(AutoCompletionWidget, 'login', 'subject', 'CWUser') |
12 AEF.rwidgets.tag_relation(AutoCompletionWidget, |
|
13 ('CWUser', 'login', '*'), 'subject') |
13 form = self.vreg.select_object('forms', 'edition', self.request(), None, |
14 form = self.vreg.select_object('forms', 'edition', self.request(), None, |
14 entity=self.user()) |
15 entity=self.user()) |
15 field = form.field_by_name('login') |
16 field = form.field_by_name('login') |
16 self.assertIsInstance(field.widget, AutoCompletionWidget) |
17 self.assertIsInstance(field.widget, AutoCompletionWidget) |
17 AEF.rwidgets.del_rtag('login', 'subject', 'CWUser') |
18 AEF.rwidgets.del_rtag('login', 'subject', 'CWUser') |
18 |
19 |
19 |
20 |
20 def test_euser_relations_by_category(self): |
21 def test_euser_relations_by_category(self): |
21 #for (rtype, role, stype, otype), tag in AEF.rcategories._tagdefs.items(): |
22 #for (rtype, role, stype, otype), tag in AEF.rcategories._tagdefs.items(): |
22 # if rtype == 'tags': |
23 # if rtype == 'tags': |
23 # print rtype, role, stype, otype, ':', tag |
24 # print rtype, role, stype, otype, ':', tag |
39 ('created_by', 'subject'), |
40 ('created_by', 'subject'), |
40 ('creation_date', 'subject'), |
41 ('creation_date', 'subject'), |
41 ('modification_date', 'subject'), |
42 ('modification_date', 'subject'), |
42 ('owned_by', 'subject'), |
43 ('owned_by', 'subject'), |
43 ('bookmarked_by', 'object'), |
44 ('bookmarked_by', 'object'), |
44 ]) |
45 ]) |
45 self.assertListEquals(rbc(e, 'generic'), |
46 self.assertListEquals(rbc(e, 'generic'), |
46 [('primary_email', 'subject'), |
47 [('primary_email', 'subject'), |
47 ('use_email', 'subject'), |
48 ('use_email', 'subject'), |
48 ('connait', 'subject'), |
49 ('connait', 'subject'), |
49 ('checked_by', 'object'), |
50 ('checked_by', 'object'), |
89 self.assertListEquals(rbc(e, 'metadata'), |
90 self.assertListEquals(rbc(e, 'metadata'), |
90 [('created_by', 'subject'), |
91 [('created_by', 'subject'), |
91 ('creation_date', 'subject'), |
92 ('creation_date', 'subject'), |
92 ('modification_date', 'subject'), |
93 ('modification_date', 'subject'), |
93 ('owned_by', 'subject'), |
94 ('owned_by', 'subject'), |
94 ]) |
95 ]) |
95 self.assertListEquals(rbc(e, 'generic'), |
96 self.assertListEquals(rbc(e, 'generic'), |
96 [('travaille', 'subject'), |
97 [('travaille', 'subject'), |
97 ('connait', 'object') |
98 ('connait', 'object') |
98 ]) |
99 ]) |
99 self.assertListEquals(rbc(e, 'generated'), |
100 self.assertListEquals(rbc(e, 'generated'), |
101 ('identity', 'subject'), |
102 ('identity', 'subject'), |
102 ('is', 'subject'), |
103 ('is', 'subject'), |
103 ('is_instance_of', 'subject'), |
104 ('is_instance_of', 'subject'), |
104 ('identity', 'object'), |
105 ('identity', 'object'), |
105 ]) |
106 ]) |
106 |
107 |
107 def test_edition_form(self): |
108 def test_edition_form(self): |
108 rset = self.execute('CWUser X LIMIT 1') |
109 rset = self.execute('CWUser X LIMIT 1') |
109 form = self.vreg.select_object('forms', 'edition', rset.req, rset, |
110 form = self.vreg.select_object('forms', 'edition', rset.req, rset, |
110 row=0, col=0) |
111 row=0, col=0) |
111 # should be also selectable by specifying entity |
112 # should be also selectable by specifying entity |
112 self.vreg.select_object('forms', 'edition', self.request(), None, |
113 self.vreg.select_object('forms', 'edition', self.request(), None, |
113 entity=rset.get_entity(0, 0)) |
114 entity=rset.get_entity(0, 0)) |
114 self.failIf(any(f for f in form.fields if f is None)) |
115 self.failIf(any(f for f in form.fields if f is None)) |
115 |
116 |
116 |
117 |
117 class FormViewsTC(WebTest): |
118 class FormViewsTC(WebTest): |
118 def test_delete_conf_formview(self): |
119 def test_delete_conf_formview(self): |
119 rset = self.execute('CWGroup X') |
120 rset = self.execute('CWGroup X') |
120 self.view('deleteconf', rset, template=None).source |
121 self.view('deleteconf', rset, template=None).source |
121 |
122 |
122 def test_automatic_edition_formview(self): |
123 def test_automatic_edition_formview(self): |
123 rset = self.execute('CWUser X') |
124 rset = self.execute('CWUser X') |
124 self.view('edition', rset, row=0, template=None).source |
125 self.view('edition', rset, row=0, template=None).source |
125 |
126 |
126 def test_automatic_edition_formview(self): |
127 def test_automatic_edition_formview(self): |
127 rset = self.execute('CWUser X') |
128 rset = self.execute('CWUser X') |
128 self.view('copy', rset, row=0, template=None).source |
129 self.view('copy', rset, row=0, template=None).source |
129 |
130 |
130 def test_automatic_creation_formview(self): |
131 def test_automatic_creation_formview(self): |
131 self.view('creation', None, etype='CWUser', template=None).source |
132 self.view('creation', None, etype='CWUser', template=None).source |
132 |
133 |
133 def test_automatic_muledit_formview(self): |
134 def test_automatic_muledit_formview(self): |
134 rset = self.execute('CWUser X') |
135 rset = self.execute('CWUser X') |
135 self.view('muledit', rset, template=None).source |
136 self.view('muledit', rset, template=None).source |
136 |
137 |
137 def test_automatic_reledit_formview(self): |
138 def test_automatic_reledit_formview(self): |
138 rset = self.execute('CWUser X') |
139 rset = self.execute('CWUser X') |
139 self.view('reledit', rset, row=0, rtype='login', template=None).source |
140 self.view('reledit', rset, row=0, rtype='login', template=None).source |
140 |
141 |
141 def test_automatic_inline_edit_formview(self): |
142 def test_automatic_inline_edit_formview(self): |
142 geid = self.execute('CWGroup X LIMIT 1')[0][0] |
143 geid = self.execute('CWGroup X LIMIT 1')[0][0] |
143 rset = self.execute('CWUser X LIMIT 1') |
144 rset = self.execute('CWUser X LIMIT 1') |
144 self.view('inline-edition', rset, row=0, rtype='in_group', peid=geid, template=None).source |
145 self.view('inline-edition', rset, row=0, rtype='in_group', peid=geid, template=None).source |
145 |
146 |
146 def test_automatic_inline_creation_formview(self): |
147 def test_automatic_inline_creation_formview(self): |
147 geid = self.execute('CWGroup X LIMIT 1')[0][0] |
148 geid = self.execute('CWGroup X LIMIT 1')[0][0] |
148 self.view('inline-creation', None, etype='CWUser', rtype='in_group', peid=geid, template=None).source |
149 self.view('inline-creation', None, etype='CWUser', rtype='in_group', peid=geid, template=None).source |
149 |
150 |
150 |
151 |
151 if __name__ == '__main__': |
152 if __name__ == '__main__': |
152 unittest_main() |
153 unittest_main() |