845
|
1 |
from logilab.common.testlib import TestCase, unittest_main, mock_object |
|
2 |
from cubicweb.web.form import * |
|
3 |
|
|
4 |
class ChangeStateForm(EntityFieldsForm): |
|
5 |
state = TextField(widget=HiddenInput, eidparam=False) |
|
6 |
__method = TextField(widget=HiddenInput, initial='set_state', eidparam=False) |
|
7 |
trcomment = RichTextField() |
|
8 |
|
|
9 |
def buttons(self): |
|
10 |
return [] |
|
11 |
|
|
12 |
class CustomChangeStateForm(ChangeStateForm): |
|
13 |
hello = IntField(name='youlou') |
|
14 |
|
|
15 |
class EntityFieldsFormTC(TestCase): |
|
16 |
|
|
17 |
def test(self): |
|
18 |
req = mock_object(build_url=lambda *args,**kwargs: 'myurl.com') |
|
19 |
form = ChangeStateForm(req, redirect_path='perdu.com') |
|
20 |
entity = mock_object(eid=1) |
|
21 |
self.assertEquals(form.render(entity, state=123), |
|
22 |
'''''') |
|
23 |
|
|
24 |
def test_form_inheritance(self): |
|
25 |
req = mock_object(build_url=lambda *args,**kwargs: 'myurl.com') |
|
26 |
form = CustomChangeStateForm(req, redirect_path='perdu.com') |
|
27 |
entity = mock_object(eid=1) |
|
28 |
self.assertEquals(form.render(entity, state=123), |
|
29 |
'''''') |
|
30 |
|
|
31 |
|
|
32 |
if __name__ == '__main__': |
|
33 |
unittest_main() |