equal
deleted
inserted
replaced
18 |
18 |
19 from logilab.common import tempattr, attrdict |
19 from logilab.common import tempattr, attrdict |
20 |
20 |
21 from cubicweb.devtools.testlib import CubicWebTC |
21 from cubicweb.devtools.testlib import CubicWebTC |
22 from cubicweb.web.views.autoform import InlinedFormField |
22 from cubicweb.web.views.autoform import InlinedFormField |
|
23 from cubicweb.web.views.forms import EntityFieldsForm |
|
24 |
23 |
25 |
24 class InlinedFormTC(CubicWebTC): |
26 class InlinedFormTC(CubicWebTC): |
25 |
27 |
26 def test_linked_to(self): |
28 def test_linked_to(self): |
27 with self.admin_access.web_request() as req: |
29 with self.admin_access.web_request() as req: |
66 # formview isn't first, can be removed |
68 # formview isn't first, can be removed |
67 formview.pform = attrdict(fields=[InlinedFormField(view=fakeview), |
69 formview.pform = attrdict(fields=[InlinedFormField(view=fakeview), |
68 InlinedFormField(view=formview)]) |
70 InlinedFormField(view=formview)]) |
69 self.assertTrue(formview._get_removejs()) |
71 self.assertTrue(formview._get_removejs()) |
70 |
72 |
|
73 def test_field_by_name_consider_aff(self): |
|
74 class MyField(object): |
|
75 def __init__(self, *args, **kwargs): |
|
76 pass |
|
77 |
|
78 EntityFieldsForm.uicfg_aff.tag_attribute(('CWUser', 'firstname'), MyField) |
|
79 try: |
|
80 with self.admin_access.web_request() as req: |
|
81 form = req.vreg['forms'].select('base', req, entity=req.user) |
|
82 self.assertIsInstance(form.field_by_name('firstname', 'subject', req.user.e_schema), |
|
83 MyField) |
|
84 finally: |
|
85 EntityFieldsForm.uicfg_aff.del_rtag('CWUser', 'firstname', '*', 'subject') |
|
86 |
71 |
87 |
72 if __name__ == '__main__': |
88 if __name__ == '__main__': |
73 import unittest |
89 import unittest |
74 unittest.main() |
90 unittest.main() |