author | sylvain.thenault@logilab.fr |
Fri, 17 Apr 2009 16:55:37 +0200 | |
branch | tls-sprint |
changeset 1398 | 5fe84a5f7035 |
parent 1393 | ff6758d7b96f |
child 1570 | 5c40d9fb4e8d |
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 |
1359 | 4 |
from cubicweb.web.form import EntityFieldsForm, FieldsForm, FormRenderer |
1111
bcb81e7c41bc
fix test: form_add_entity_hiddens *must* be called before build context, resulting in slightly different outputs...
sylvain.thenault@logilab.fr
parents:
1074
diff
changeset
|
5 |
from cubicweb.web.formfields import (IntField, StringField, RichTextField, |
bcb81e7c41bc
fix test: form_add_entity_hiddens *must* be called before build context, resulting in slightly different outputs...
sylvain.thenault@logilab.fr
parents:
1074
diff
changeset
|
6 |
DateTimeField, DateTimePicker, |
bcb81e7c41bc
fix test: form_add_entity_hiddens *must* be called before build context, resulting in slightly different outputs...
sylvain.thenault@logilab.fr
parents:
1074
diff
changeset
|
7 |
FileField, EditableFileField) |
bcb81e7c41bc
fix test: form_add_entity_hiddens *must* be called before build context, resulting in slightly different outputs...
sylvain.thenault@logilab.fr
parents:
1074
diff
changeset
|
8 |
from cubicweb.web.formwidgets import PasswordInput |
bcb81e7c41bc
fix test: form_add_entity_hiddens *must* be called before build context, resulting in slightly different outputs...
sylvain.thenault@logilab.fr
parents:
1074
diff
changeset
|
9 |
from cubicweb.web.views.workflow import ChangeStateForm |
845 | 10 |
|
869
168ad6d424d1
form to edit multiple entities, use it in DeleteConfForm
sylvain.thenault@logilab.fr
parents:
868
diff
changeset
|
11 |
|
1359 | 12 |
class FieldsFormTC(WebTest): |
13 |
||
14 |
def test_form_field_format(self): |
|
15 |
form = FieldsForm(self.request(), None) |
|
16 |
self.assertEquals(form.form_field_format(None), 'text/html') |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1393
diff
changeset
|
17 |
self.execute('INSERT CWProperty X: X pkey "ui.default-text-format", X value "text/rest", X for_user U WHERE U login "admin"') |
1359 | 18 |
self.commit() |
19 |
self.assertEquals(form.form_field_format(None), 'text/rest') |
|
20 |
||
21 |
||
869
168ad6d424d1
form to edit multiple entities, use it in DeleteConfForm
sylvain.thenault@logilab.fr
parents:
868
diff
changeset
|
22 |
class EntityFieldsFormTC(WebTest): |
845 | 23 |
|
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
|
24 |
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
|
25 |
super(EntityFieldsFormTC, self).setUp() |
868
5d993a0c794c
update test, use a DateTimePicker widget
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
866
diff
changeset
|
26 |
self.req = self.request() |
5d993a0c794c
update test, use a DateTimePicker widget
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
866
diff
changeset
|
27 |
self.entity = self.user(self.req) |
1057
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
28 |
self.renderer = FormRenderer() |
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
|
29 |
|
1345 | 30 |
def test_form_field_vocabulary_unrelated(self): |
31 |
b = self.add_entity('BlogEntry', title=u'di mascii code', content=u'a best-seller') |
|
32 |
t = self.add_entity('Tag', name=u'x') |
|
33 |
form1 = EntityFieldsForm(self.request(), None, entity=t) |
|
34 |
unrelated = [reid for rview, reid in form1.subject_relation_vocabulary('tags')] |
|
35 |
self.failUnless(b.eid in unrelated, unrelated) |
|
36 |
form2 = EntityFieldsForm(self.request(), None, entity=b) |
|
37 |
unrelated = [reid for rview, reid in form2.object_relation_vocabulary('tags')] |
|
38 |
self.failUnless(t.eid in unrelated, unrelated) |
|
39 |
self.execute('SET X tags Y WHERE X is Tag, Y is BlogEntry') |
|
40 |
unrelated = [reid for rview, reid in form1.subject_relation_vocabulary('tags')] |
|
41 |
self.failIf(b.eid in unrelated, unrelated) |
|
42 |
unrelated = [reid for rview, reid in form2.object_relation_vocabulary('tags')] |
|
43 |
self.failIf(t.eid in unrelated, unrelated) |
|
44 |
||
45 |
def test_form_field_vocabulary_new_entity(self): |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1393
diff
changeset
|
46 |
e = self.etype_instance('CWUser') |
1345 | 47 |
form = EntityFieldsForm(self.request(), None, entity=e) |
48 |
unrelated = [rview for rview, reid in form.subject_relation_vocabulary('in_group')] |
|
49 |
# should be default groups but owners, i.e. managers, users, guests |
|
50 |
self.assertEquals(unrelated, [u'guests', u'managers', u'users']) |
|
51 |
||
1359 | 52 |
def test_subject_in_state_vocabulary(self): |
53 |
# on a new entity |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1393
diff
changeset
|
54 |
e = self.etype_instance('CWUser') |
1359 | 55 |
form = EntityFieldsForm(self.request(), None, entity=e) |
56 |
states = list(form.subject_in_state_vocabulary('in_state')) |
|
57 |
self.assertEquals(len(states), 1) |
|
58 |
self.assertEquals(states[0][0], u'activated') # list of (combobox view, state eid) |
|
59 |
# on an existant entity |
|
60 |
e = self.user() |
|
61 |
form = EntityFieldsForm(self.request(), None, entity=e) |
|
62 |
states = list(form.subject_in_state_vocabulary('in_state')) |
|
63 |
self.assertEquals(len(states), 1) |
|
64 |
self.assertEquals(states[0][0], u'deactivated') # list of (combobox view, state eid) |
|
65 |
||
66 |
||
1345 | 67 |
|
1181
620ec8e6ae19
cleanup, various fix to get something working
sylvain.thenault@logilab.fr
parents:
1147
diff
changeset
|
68 |
# form view tests ######################################################### |
620ec8e6ae19
cleanup, various fix to get something working
sylvain.thenault@logilab.fr
parents:
1147
diff
changeset
|
69 |
|
620ec8e6ae19
cleanup, various fix to get something working
sylvain.thenault@logilab.fr
parents:
1147
diff
changeset
|
70 |
def test_massmailing_formview(self): |
620ec8e6ae19
cleanup, various fix to get something working
sylvain.thenault@logilab.fr
parents:
1147
diff
changeset
|
71 |
self.execute('INSERT EmailAddress X: X address L + "@cubicweb.org", ' |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1393
diff
changeset
|
72 |
'U use_email X WHERE U is CWUser, U login L') |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1393
diff
changeset
|
73 |
rset = self.execute('CWUser X') |
1181
620ec8e6ae19
cleanup, various fix to get something working
sylvain.thenault@logilab.fr
parents:
1147
diff
changeset
|
74 |
self.view('massmailing', rset, template=None) |
620ec8e6ae19
cleanup, various fix to get something working
sylvain.thenault@logilab.fr
parents:
1147
diff
changeset
|
75 |
|
620ec8e6ae19
cleanup, various fix to get something working
sylvain.thenault@logilab.fr
parents:
1147
diff
changeset
|
76 |
|
1057
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
77 |
# form tests ############################################################## |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
78 |
|
869
168ad6d424d1
form to edit multiple entities, use it in DeleteConfForm
sylvain.thenault@logilab.fr
parents:
868
diff
changeset
|
79 |
def test_form_inheritance(self): |
1057
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
80 |
class CustomChangeStateForm(ChangeStateForm): |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
81 |
hello = IntField(name='youlou') |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
82 |
creation_date = DateTimeField(widget=DateTimePicker) |
894 | 83 |
form = CustomChangeStateForm(self.req, redirect_path='perdu.com', |
84 |
entity=self.entity) |
|
1147 | 85 |
form.form_render(state=123, trcomment=u'') |
869
168ad6d424d1
form to edit multiple entities, use it in DeleteConfForm
sylvain.thenault@logilab.fr
parents:
868
diff
changeset
|
86 |
|
168ad6d424d1
form to edit multiple entities, use it in DeleteConfForm
sylvain.thenault@logilab.fr
parents:
868
diff
changeset
|
87 |
def test_change_state_form(self): |
894 | 88 |
form = ChangeStateForm(self.req, redirect_path='perdu.com', |
89 |
entity=self.entity) |
|
1147 | 90 |
form.form_render(state=123, trcomment=u'') |
1052 | 91 |
|
1057
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
92 |
# fields tests ############################################################ |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
93 |
|
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
94 |
def _render_entity_field(self, name, form): |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
95 |
form.form_build_context({}) |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
96 |
return form.field_by_name(name).render(form, self.renderer) |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
97 |
|
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
98 |
def _test_richtextfield(self, expected): |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
99 |
class RTFForm(EntityFieldsForm): |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
100 |
content = RichTextField() |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
101 |
card = self.add_entity('Card', title=u"tls sprint fev 2009", |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
102 |
content=u'<h1>new widgets system</h1>', |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
103 |
content_format=u'text/html') |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
104 |
form = RTFForm(self.req, redirect_path='perdu.com', entity=card) |
1111
bcb81e7c41bc
fix test: form_add_entity_hiddens *must* be called before build context, resulting in slightly different outputs...
sylvain.thenault@logilab.fr
parents:
1074
diff
changeset
|
105 |
self.assertTextEquals(self._render_entity_field('content', form), expected % {'eid': card.eid}) |
bcb81e7c41bc
fix test: form_add_entity_hiddens *must* be called before build context, resulting in slightly different outputs...
sylvain.thenault@logilab.fr
parents:
1074
diff
changeset
|
106 |
|
1057
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
107 |
|
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
108 |
def test_richtextfield_1(self): |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
109 |
self.req.use_fckeditor = lambda: False |
1111
bcb81e7c41bc
fix test: form_add_entity_hiddens *must* be called before build context, resulting in slightly different outputs...
sylvain.thenault@logilab.fr
parents:
1074
diff
changeset
|
110 |
self._test_richtextfield('''<select name="content_format:%(eid)s" id="content_format:%(eid)s" tabindex="0"> |
1300 | 111 |
<option value="text/cubicweb-page-template">text/cubicweb-page-template</option> |
1057
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
112 |
<option selected="selected" value="text/html">text/html</option> |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
113 |
<option value="text/plain">text/plain</option> |
1300 | 114 |
<option value="text/rest">text/rest</option> |
1111
bcb81e7c41bc
fix test: form_add_entity_hiddens *must* be called before build context, resulting in slightly different outputs...
sylvain.thenault@logilab.fr
parents:
1074
diff
changeset
|
115 |
</select><textarea tabindex="1" id="content:%(eid)s" name="content:%(eid)s" onkeypress="autogrow(this)"><h1>new widgets system</h1></textarea>''') |
bcb81e7c41bc
fix test: form_add_entity_hiddens *must* be called before build context, resulting in slightly different outputs...
sylvain.thenault@logilab.fr
parents:
1074
diff
changeset
|
116 |
|
1057
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
117 |
|
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
118 |
def test_richtextfield_2(self): |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
119 |
self.req.use_fckeditor = lambda: True |
1111
bcb81e7c41bc
fix test: form_add_entity_hiddens *must* be called before build context, resulting in slightly different outputs...
sylvain.thenault@logilab.fr
parents:
1074
diff
changeset
|
120 |
self._test_richtextfield('''<input type="hidden" name="content_format:%(eid)s" value="text/html"/><textarea tabindex="0" cubicweb:type="wysiwyg" id="content:%(eid)s" name="content:%(eid)s" onkeypress="autogrow(this)"><h1>new widgets system</h1></textarea>''') |
1057
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
121 |
|
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
122 |
|
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
123 |
def test_filefield(self): |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
124 |
class FFForm(EntityFieldsForm): |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
125 |
data = FileField(format_field=StringField(name='data_format'), |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
126 |
encoding_field=StringField(name='data_encoding')) |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
127 |
file = self.add_entity('File', name=u"pouet.txt", |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
128 |
data=Binary('new widgets system')) |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
129 |
form = FFForm(self.req, redirect_path='perdu.com', entity=file) |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
130 |
self.assertTextEquals(self._render_entity_field('data', form), |
1111
bcb81e7c41bc
fix test: form_add_entity_hiddens *must* be called before build context, resulting in slightly different outputs...
sylvain.thenault@logilab.fr
parents:
1074
diff
changeset
|
131 |
'''<input id="data:%(eid)s" type="file" name="data:%(eid)s" value="" tabindex="0"/> |
bcb81e7c41bc
fix test: form_add_entity_hiddens *must* be called before build context, resulting in slightly different outputs...
sylvain.thenault@logilab.fr
parents:
1074
diff
changeset
|
132 |
<a href="javascript: toggleVisibility('data:%(eid)s-advanced')" title="show advanced fields"><img src="http://testing.fr/cubicweb/data/puce_down.png" alt="show advanced fields"/></a> |
bcb81e7c41bc
fix test: form_add_entity_hiddens *must* be called before build context, resulting in slightly different outputs...
sylvain.thenault@logilab.fr
parents:
1074
diff
changeset
|
133 |
<div id="data:%(eid)s-advanced" class="hidden"> |
bcb81e7c41bc
fix test: form_add_entity_hiddens *must* be called before build context, resulting in slightly different outputs...
sylvain.thenault@logilab.fr
parents:
1074
diff
changeset
|
134 |
<label for="data_format:%(eid)s">data_format</label><input id="data_format:%(eid)s" type="text" name="data_format:%(eid)s" value="text/plain" tabindex="1"/><br/><br/> |
bcb81e7c41bc
fix test: form_add_entity_hiddens *must* be called before build context, resulting in slightly different outputs...
sylvain.thenault@logilab.fr
parents:
1074
diff
changeset
|
135 |
<label for="data_encoding:%(eid)s">data_encoding</label><input id="data_encoding:%(eid)s" type="text" name="data_encoding:%(eid)s" value="UTF-8" tabindex="2"/><br/><br/> |
bcb81e7c41bc
fix test: form_add_entity_hiddens *must* be called before build context, resulting in slightly different outputs...
sylvain.thenault@logilab.fr
parents:
1074
diff
changeset
|
136 |
</div> |
bcb81e7c41bc
fix test: form_add_entity_hiddens *must* be called before build context, resulting in slightly different outputs...
sylvain.thenault@logilab.fr
parents:
1074
diff
changeset
|
137 |
<br/> |
bcb81e7c41bc
fix test: form_add_entity_hiddens *must* be called before build context, resulting in slightly different outputs...
sylvain.thenault@logilab.fr
parents:
1074
diff
changeset
|
138 |
<input type="checkbox" name="data:594__detach"/> |
bcb81e7c41bc
fix test: form_add_entity_hiddens *must* be called before build context, resulting in slightly different outputs...
sylvain.thenault@logilab.fr
parents:
1074
diff
changeset
|
139 |
detach attached file |
bcb81e7c41bc
fix test: form_add_entity_hiddens *must* be called before build context, resulting in slightly different outputs...
sylvain.thenault@logilab.fr
parents:
1074
diff
changeset
|
140 |
''' % {'eid': file.eid}) |
1057
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
141 |
|
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
142 |
|
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
143 |
def test_editablefilefield(self): |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
144 |
class EFFForm(EntityFieldsForm): |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
145 |
data = EditableFileField(format_field=StringField(name='data_format'), |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
146 |
encoding_field=StringField(name='data_encoding')) |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
147 |
def form_field_encoding(self, field): |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
148 |
return 'ascii' |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
149 |
def form_field_format(self, field): |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
150 |
return 'text/plain' |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
151 |
file = self.add_entity('File', name=u"pouet.txt", |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
152 |
data=Binary('new widgets system')) |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
153 |
form = EFFForm(self.req, redirect_path='perdu.com', entity=file) |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
154 |
self.assertTextEquals(self._render_entity_field('data', form), |
1111
bcb81e7c41bc
fix test: form_add_entity_hiddens *must* be called before build context, resulting in slightly different outputs...
sylvain.thenault@logilab.fr
parents:
1074
diff
changeset
|
155 |
'''<input id="data:%(eid)s" type="file" name="data:%(eid)s" value="" tabindex="0"/> |
bcb81e7c41bc
fix test: form_add_entity_hiddens *must* be called before build context, resulting in slightly different outputs...
sylvain.thenault@logilab.fr
parents:
1074
diff
changeset
|
156 |
<a href="javascript: toggleVisibility('data:%(eid)s-advanced')" title="show advanced fields"><img src="http://testing.fr/cubicweb/data/puce_down.png" alt="show advanced fields"/></a> |
bcb81e7c41bc
fix test: form_add_entity_hiddens *must* be called before build context, resulting in slightly different outputs...
sylvain.thenault@logilab.fr
parents:
1074
diff
changeset
|
157 |
<div id="data:%(eid)s-advanced" class="hidden"> |
bcb81e7c41bc
fix test: form_add_entity_hiddens *must* be called before build context, resulting in slightly different outputs...
sylvain.thenault@logilab.fr
parents:
1074
diff
changeset
|
158 |
<label for="data_format:%(eid)s">data_format</label><input id="data_format:%(eid)s" type="text" name="data_format:%(eid)s" value="text/plain" tabindex="1"/><br/><br/> |
bcb81e7c41bc
fix test: form_add_entity_hiddens *must* be called before build context, resulting in slightly different outputs...
sylvain.thenault@logilab.fr
parents:
1074
diff
changeset
|
159 |
<label for="data_encoding:%(eid)s">data_encoding</label><input id="data_encoding:%(eid)s" type="text" name="data_encoding:%(eid)s" value="UTF-8" tabindex="2"/><br/><br/> |
1057
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
160 |
</div> |
1111
bcb81e7c41bc
fix test: form_add_entity_hiddens *must* be called before build context, resulting in slightly different outputs...
sylvain.thenault@logilab.fr
parents:
1074
diff
changeset
|
161 |
<br/> |
bcb81e7c41bc
fix test: form_add_entity_hiddens *must* be called before build context, resulting in slightly different outputs...
sylvain.thenault@logilab.fr
parents:
1074
diff
changeset
|
162 |
<input type="checkbox" name="data:594__detach"/> |
bcb81e7c41bc
fix test: form_add_entity_hiddens *must* be called before build context, resulting in slightly different outputs...
sylvain.thenault@logilab.fr
parents:
1074
diff
changeset
|
163 |
detach attached file |
1057
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
164 |
<p><b>You can either submit a new file using the browse button above, or choose to remove already uploaded file by checking the "detach attached file" check-box, or edit file content online with the widget below.</b></p> |
1111
bcb81e7c41bc
fix test: form_add_entity_hiddens *must* be called before build context, resulting in slightly different outputs...
sylvain.thenault@logilab.fr
parents:
1074
diff
changeset
|
165 |
<textarea tabindex="3" name="data:%(eid)s" onkeypress="autogrow(this)">new widgets system</textarea>''' % {'eid': file.eid}) |
bcb81e7c41bc
fix test: form_add_entity_hiddens *must* be called before build context, resulting in slightly different outputs...
sylvain.thenault@logilab.fr
parents:
1074
diff
changeset
|
166 |
|
1057
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
167 |
|
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
168 |
def test_passwordfield(self): |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
169 |
class PFForm(EntityFieldsForm): |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
170 |
upassword = StringField(widget=PasswordInput) |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
171 |
form = PFForm(self.req, redirect_path='perdu.com', entity=self.entity) |
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
172 |
self.assertTextEquals(self._render_entity_field('upassword', form), |
1111
bcb81e7c41bc
fix test: form_add_entity_hiddens *must* be called before build context, resulting in slightly different outputs...
sylvain.thenault@logilab.fr
parents:
1074
diff
changeset
|
173 |
'''<input id="upassword:%(eid)s" type="password" name="upassword:%(eid)s" value="__cubicweb_internal_field__" tabindex="0"/> |
1057
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
174 |
<br/> |
1300 | 175 |
<input type="password" name="upassword-confirm:%(eid)s" value="__cubicweb_internal_field__" tabindex="0"/> |
1057
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
176 |
|
1111
bcb81e7c41bc
fix test: form_add_entity_hiddens *must* be called before build context, resulting in slightly different outputs...
sylvain.thenault@logilab.fr
parents:
1074
diff
changeset
|
177 |
<span class="emphasis">confirm password</span>''' % {'eid': self.entity.eid}) |
1057
6636c75c4aa9
actual fields test, though it's still to early for form tests
sylvain.thenault@logilab.fr
parents:
1052
diff
changeset
|
178 |
|
845 | 179 |
|
180 |
if __name__ == '__main__': |
|
181 |
unittest_main() |