1 from logilab.common.testlib import unittest_main, mock_object |
1 from logilab.common.testlib import unittest_main, mock_object |
|
2 from cubicweb import Binary |
2 from cubicweb.devtools.testlib import WebTest |
3 from cubicweb.devtools.testlib import WebTest |
3 from cubicweb.web.form import * |
4 from cubicweb.web.form import * |
4 from cubicweb.web.views.baseforms import ChangeStateForm |
5 from cubicweb.web.views.baseforms import ChangeStateForm |
5 |
6 |
6 |
7 |
7 class CustomChangeStateForm(ChangeStateForm): |
8 class CustomChangeStateForm(ChangeStateForm): |
8 hello = IntField(name='youlou') |
9 hello = IntField(name='youlou') |
9 creation_date = DateTimeField(widget=DateTimePicker) |
10 creation_date = DateTimeField(widget=DateTimePicker) |
10 |
11 |
11 |
12 |
12 class RTFStateForm(EntityFieldsForm): |
13 class RTFForm(EntityFieldsForm): |
13 content = RichTextField() |
14 content = RichTextField() |
|
15 |
|
16 class FFForm(EntityFieldsForm): |
|
17 data = FileField(format_field=StringField(name='data_format'), |
|
18 encoding_field=StringField(name='data_encoding')) |
|
19 |
|
20 class PFForm(EntityFieldsForm): |
|
21 upassword = StringField(widget=PasswordInput) |
14 |
22 |
15 |
23 |
16 class EntityFieldsFormTC(WebTest): |
24 class EntityFieldsFormTC(WebTest): |
17 |
25 |
18 def setUp(self): |
26 def setUp(self): |
38 '') |
46 '') |
39 |
47 |
40 def test_richtextfield(self): |
48 def test_richtextfield(self): |
41 card = self.add_entity('Card', title=u"tls sprint fev 2009", |
49 card = self.add_entity('Card', title=u"tls sprint fev 2009", |
42 content=u'new widgets system') |
50 content=u'new widgets system') |
43 form = CustomChangeStateForm(self.req, redirect_path='perdu.com', |
51 form = RTFForm(self.req, redirect_path='perdu.com', |
44 entity=card) |
52 entity=card) |
|
53 self.assertEquals(form.form_render(), |
|
54 '''''') |
|
55 |
|
56 def test_filefield(self): |
|
57 file = self.add_entity('File', name=u"pouet.txt", |
|
58 data=Binary('new widgets system')) |
|
59 form = FFForm(self.req, redirect_path='perdu.com', |
|
60 entity=file) |
|
61 self.assertEquals(form.form_render(), |
|
62 '''''') |
|
63 |
|
64 def test_passwordfield(self): |
|
65 form = PFForm(self.req, redirect_path='perdu.com', |
|
66 entity=self.entity) |
45 self.assertEquals(form.form_render(), |
67 self.assertEquals(form.form_render(), |
46 '''''') |
68 '''''') |
47 |
69 |
48 if __name__ == '__main__': |
70 if __name__ == '__main__': |
49 unittest_main() |
71 unittest_main() |