1 from logilab.common.testlib import unittest_main |
1 from logilab.common.testlib import unittest_main |
2 from cubicweb.devtools.apptest import EnvBasedTC |
2 from cubicweb.devtools.apptest import EnvBasedTC |
3 from cubicweb.devtools.testlib import WebTest |
3 from cubicweb.devtools.testlib import WebTest |
4 from cubicweb.web.views.editforms import AutomaticEntityForm as AEF |
4 from cubicweb.web.views.editforms import AutomaticEntityForm as AEF |
5 |
5 from cubicweb.web.formwidgets import AutoCompletionWidget |
6 def rbc(entity, category): |
6 def rbc(entity, category): |
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 |
|
11 def test_custom_widget(self): |
|
12 AEF.rwidgets.set_rtag(AutoCompletionWidget, 'login', 'subject', 'EUser') |
|
13 form = self.vreg.select_object('forms', 'edition', self.request(), None, |
|
14 entity=self.user()) |
|
15 field = form.field_by_name('login') |
|
16 self.assertIsInstance(field.widget, AutoCompletionWidget) |
|
17 AEF.rwidgets.del_rtag('login', 'subject', 'EUser') |
|
18 |
10 |
19 |
11 def test_euser_relations_by_category(self): |
20 def test_euser_relations_by_category(self): |
12 #for (rtype, role, stype, otype), tag in AEF.rcategories._tagdefs.items(): |
21 #for (rtype, role, stype, otype), tag in AEF.rcategories._tagdefs.items(): |
13 # if rtype == 'tags': |
22 # if rtype == 'tags': |
14 # print rtype, role, stype, otype, ':', tag |
23 # print rtype, role, stype, otype, ':', tag |