web/test/unittest_views_editforms.py
branchtls-sprint
changeset 1654 57b9fd2462b8
parent 1540 996355824825
child 1721 694f6a50e138
equal deleted inserted replaced
1653:8b82227719f0 1654:57b9fd2462b8
     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.autoform import AutomaticEntityForm as AEF
     5 from cubicweb.web.formwidgets import AutoCompletionWidget
     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):
    13                                   ('CWUser', 'login', '*'), 'subject')
    13                                   ('CWUser', 'login', '*'), 'subject')
    14         form = self.vreg.select_object('forms', 'edition', self.request(), None,
    14         form = self.vreg.select_object('forms', 'edition', self.request(), None,
    15                                        entity=self.user())
    15                                        entity=self.user())
    16         field = form.field_by_name('login')
    16         field = form.field_by_name('login')
    17         self.assertIsInstance(field.widget, AutoCompletionWidget)
    17         self.assertIsInstance(field.widget, AutoCompletionWidget)
    18         AEF.rwidgets.del_rtag('login', 'subject', 'CWUser')
    18         AEF.rwidgets.del_rtag(('CWUser', 'login', '*'),'subject')
    19 
    19 
    20 
    20 
    21     def test_euser_relations_by_category(self):
    21     def test_euser_relations_by_category(self):
    22         #for (rtype, role, stype, otype), tag in AEF.rcategories._tagdefs.items():
    22         #for (rtype, role, stype, otype), tag in AEF.rcategories._tagdefs.items():
    23         #    if rtype == 'tags':
    23         #    if rtype == 'tags':
    42                                ('modification_date', 'subject'),
    42                                ('modification_date', 'subject'),
    43                                ('owned_by', 'subject'),
    43                                ('owned_by', 'subject'),
    44                                ('bookmarked_by', 'object'),
    44                                ('bookmarked_by', 'object'),
    45                                ])
    45                                ])
    46         self.assertListEquals(rbc(e, 'generic'),
    46         self.assertListEquals(rbc(e, 'generic'),
    47                               [('primary_email', 'subject'),
    47                               [('connait', 'subject'),
    48                                ('use_email', 'subject'),
       
    49                                ('connait', 'subject'),
       
    50                                ('checked_by', 'object'),
    48                                ('checked_by', 'object'),
    51                                ])
    49                                ])
    52         # owned_by is defined both as subject and object relations on CWUser
    50         # owned_by is defined both as subject and object relations on CWUser
    53         self.assertListEquals(rbc(e, 'generated'),
    51         self.assertListEquals(rbc(e, 'generated'),
    54                               [('has_text', 'subject'),
    52                               [('primary_email', 'subject'),
       
    53                                ('use_email', 'subject'),
       
    54                                ('has_text', 'subject'),
    55                                ('identity', 'subject'),
    55                                ('identity', 'subject'),
    56                                ('is', 'subject'),
    56                                ('is', 'subject'),
    57                                ('is_instance_of', 'subject'),
    57                                ('is_instance_of', 'subject'),
    58                                ('tags', 'object'),
    58                                ('tags', 'object'),
    59                                ('for_user', 'object'),
    59                                ('for_user', 'object'),