author | sylvain.thenault@logilab.fr |
Wed, 11 Mar 2009 11:18:57 +0100 | |
branch | tls-sprint |
changeset 1052 | 4f746935e6b1 |
parent 907 | 192800415f59 |
child 1057 | 6636c75c4aa9 |
permissions | -rw-r--r-- |
866
6fdb029663ca
use EnvBasedTC since we need to access the schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
848
diff
changeset
|
1 |
from logilab.common.testlib import unittest_main, mock_object |
907 | 2 |
from cubicweb import Binary |
869
168ad6d424d1
form to edit multiple entities, use it in DeleteConfForm
sylvain.thenault@logilab.fr
parents:
868
diff
changeset
|
3 |
from cubicweb.devtools.testlib import WebTest |
847
27c4ebe90d03
prefixed form methods to avoid potential conflicts with field names, button related method, a bit more serious renderer
sylvain.thenault@logilab.fr
parents:
845
diff
changeset
|
4 |
from cubicweb.web.form import * |
27c4ebe90d03
prefixed form methods to avoid potential conflicts with field names, button related method, a bit more serious renderer
sylvain.thenault@logilab.fr
parents:
845
diff
changeset
|
5 |
from cubicweb.web.views.baseforms import ChangeStateForm |
845 | 6 |
|
869
168ad6d424d1
form to edit multiple entities, use it in DeleteConfForm
sylvain.thenault@logilab.fr
parents:
868
diff
changeset
|
7 |
|
845 | 8 |
class CustomChangeStateForm(ChangeStateForm): |
9 |
hello = IntField(name='youlou') |
|
868
5d993a0c794c
update test, use a DateTimePicker widget
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
866
diff
changeset
|
10 |
creation_date = DateTimeField(widget=DateTimePicker) |
869
168ad6d424d1
form to edit multiple entities, use it in DeleteConfForm
sylvain.thenault@logilab.fr
parents:
868
diff
changeset
|
11 |
|
894 | 12 |
|
907 | 13 |
class RTFForm(EntityFieldsForm): |
894 | 14 |
content = RichTextField() |
15 |
||
907 | 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) |
|
22 |
||
868
5d993a0c794c
update test, use a DateTimePicker widget
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
866
diff
changeset
|
23 |
|
869
168ad6d424d1
form to edit multiple entities, use it in DeleteConfForm
sylvain.thenault@logilab.fr
parents:
868
diff
changeset
|
24 |
class EntityFieldsFormTC(WebTest): |
845 | 25 |
|
847
27c4ebe90d03
prefixed form methods to avoid potential conflicts with field names, button related method, a bit more serious renderer
sylvain.thenault@logilab.fr
parents:
845
diff
changeset
|
26 |
def setUp(self): |
866
6fdb029663ca
use EnvBasedTC since we need to access the schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
848
diff
changeset
|
27 |
super(EntityFieldsFormTC, self).setUp() |
868
5d993a0c794c
update test, use a DateTimePicker widget
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
866
diff
changeset
|
28 |
self.req = self.request() |
5d993a0c794c
update test, use a DateTimePicker widget
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
866
diff
changeset
|
29 |
self.entity = self.user(self.req) |
847
27c4ebe90d03
prefixed form methods to avoid potential conflicts with field names, button related method, a bit more serious renderer
sylvain.thenault@logilab.fr
parents:
845
diff
changeset
|
30 |
|
869
168ad6d424d1
form to edit multiple entities, use it in DeleteConfForm
sylvain.thenault@logilab.fr
parents:
868
diff
changeset
|
31 |
def test_form_inheritance(self): |
894 | 32 |
form = CustomChangeStateForm(self.req, redirect_path='perdu.com', |
33 |
entity=self.entity) |
|
1052 | 34 |
self.assertTextEquals(form.form_render(state=123), |
35 |
''' ''') |
|
869
168ad6d424d1
form to edit multiple entities, use it in DeleteConfForm
sylvain.thenault@logilab.fr
parents:
868
diff
changeset
|
36 |
|
168ad6d424d1
form to edit multiple entities, use it in DeleteConfForm
sylvain.thenault@logilab.fr
parents:
868
diff
changeset
|
37 |
def test_change_state_form(self): |
894 | 38 |
form = ChangeStateForm(self.req, redirect_path='perdu.com', |
39 |
entity=self.entity) |
|
1052 | 40 |
self.assertTextEquals(form.form_render(state=123, trcomment=u''), |
41 |
''' ''') |
|
894 | 42 |
|
43 |
def test_richtextfield(self): |
|
44 |
card = self.add_entity('Card', title=u"tls sprint fev 2009", |
|
45 |
content=u'new widgets system') |
|
907 | 46 |
form = RTFForm(self.req, redirect_path='perdu.com', |
47 |
entity=card) |
|
1052 | 48 |
self.assertTextEquals(form.form_render(), |
49 |
'''''') |
|
907 | 50 |
|
51 |
def test_filefield(self): |
|
52 |
file = self.add_entity('File', name=u"pouet.txt", |
|
53 |
data=Binary('new widgets system')) |
|
54 |
form = FFForm(self.req, redirect_path='perdu.com', |
|
55 |
entity=file) |
|
1052 | 56 |
self.assertTextEquals(form.form_render(), |
57 |
'''''') |
|
907 | 58 |
|
59 |
def test_passwordfield(self): |
|
60 |
form = PFForm(self.req, redirect_path='perdu.com', |
|
61 |
entity=self.entity) |
|
1052 | 62 |
self.assertTextEquals(form.form_render(), |
63 |
'''''') |
|
64 |
||
65 |
def test_delete_conf_form_multi(self): |
|
66 |
rset = self.execute('EGroup X') |
|
67 |
self.assertTextEquals(self.view('deleteconf', rset, template=None).source, |
|
68 |
'') |
|
69 |
||
845 | 70 |
|
71 |
if __name__ == '__main__': |
|
72 |
unittest_main() |