author | sylvain.thenault@logilab.fr |
Fri, 20 Feb 2009 17:20:53 +0100 | |
branch | tls-sprint |
changeset 907 | 192800415f59 |
parent 894 | e1f848785e3d |
child 1052 | 4f746935e6b1 |
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) |
|
34 |
self.assertEquals(form.form_render(state=123), |
|
869
168ad6d424d1
form to edit multiple entities, use it in DeleteConfForm
sylvain.thenault@logilab.fr
parents:
868
diff
changeset
|
35 |
''' ''') |
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) |
|
40 |
self.assertEquals(form.form_render(state=123), |
|
866
6fdb029663ca
use EnvBasedTC since we need to access the schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
848
diff
changeset
|
41 |
''' ''') |
845 | 42 |
|
869
168ad6d424d1
form to edit multiple entities, use it in DeleteConfForm
sylvain.thenault@logilab.fr
parents:
868
diff
changeset
|
43 |
def test_delete_conf_form_multi(self): |
168ad6d424d1
form to edit multiple entities, use it in DeleteConfForm
sylvain.thenault@logilab.fr
parents:
868
diff
changeset
|
44 |
rset = self.execute('EGroup X') |
168ad6d424d1
form to edit multiple entities, use it in DeleteConfForm
sylvain.thenault@logilab.fr
parents:
868
diff
changeset
|
45 |
self.assertEquals(self.view('deleteconf', rset).source, |
168ad6d424d1
form to edit multiple entities, use it in DeleteConfForm
sylvain.thenault@logilab.fr
parents:
868
diff
changeset
|
46 |
'') |
894 | 47 |
|
48 |
def test_richtextfield(self): |
|
49 |
card = self.add_entity('Card', title=u"tls sprint fev 2009", |
|
50 |
content=u'new widgets system') |
|
907 | 51 |
form = RTFForm(self.req, redirect_path='perdu.com', |
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) |
|
894 | 67 |
self.assertEquals(form.form_render(), |
68 |
'''''') |
|
845 | 69 |
|
70 |
if __name__ == '__main__': |
|
71 |
unittest_main() |