web/test/unittest_form.py
author sylvain.thenault@logilab.fr
Thu, 19 Feb 2009 22:48:50 +0100
branchtls-sprint
changeset 869 168ad6d424d1
parent 868 5d993a0c794c
child 894 e1f848785e3d
permissions -rw-r--r--
form to edit multiple entities, use it in DeleteConfForm
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
869
168ad6d424d1 form to edit multiple entities, use it in DeleteConfForm
sylvain.thenault@logilab.fr
parents: 868
diff changeset
     2
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
     3
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
     4
from cubicweb.web.views.baseforms import ChangeStateForm
845
6103d0f55a0b simple tags
sylvain.thenault@logilab.fr
parents:
diff changeset
     5
869
168ad6d424d1 form to edit multiple entities, use it in DeleteConfForm
sylvain.thenault@logilab.fr
parents: 868
diff changeset
     6
845
6103d0f55a0b simple tags
sylvain.thenault@logilab.fr
parents:
diff changeset
     7
class CustomChangeStateForm(ChangeStateForm):
6103d0f55a0b simple tags
sylvain.thenault@logilab.fr
parents:
diff changeset
     8
    hello = IntField(name='youlou')
868
5d993a0c794c update test, use a DateTimePicker widget
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 866
diff changeset
     9
    creation_date = DateTimeField(widget=DateTimePicker)
869
168ad6d424d1 form to edit multiple entities, use it in DeleteConfForm
sylvain.thenault@logilab.fr
parents: 868
diff changeset
    10
868
5d993a0c794c update test, use a DateTimePicker widget
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 866
diff changeset
    11
    
869
168ad6d424d1 form to edit multiple entities, use it in DeleteConfForm
sylvain.thenault@logilab.fr
parents: 868
diff changeset
    12
class EntityFieldsFormTC(WebTest):
845
6103d0f55a0b simple tags
sylvain.thenault@logilab.fr
parents:
diff changeset
    13
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
    14
    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
    15
        super(EntityFieldsFormTC, self).setUp()
868
5d993a0c794c update test, use a DateTimePicker widget
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 866
diff changeset
    16
        self.req = self.request()
5d993a0c794c update test, use a DateTimePicker widget
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 866
diff changeset
    17
        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
    18
        
869
168ad6d424d1 form to edit multiple entities, use it in DeleteConfForm
sylvain.thenault@logilab.fr
parents: 868
diff changeset
    19
    def test_form_inheritance(self):
168ad6d424d1 form to edit multiple entities, use it in DeleteConfForm
sylvain.thenault@logilab.fr
parents: 868
diff changeset
    20
        form = CustomChangeStateForm(self.req, redirect_path='perdu.com')
168ad6d424d1 form to edit multiple entities, use it in DeleteConfForm
sylvain.thenault@logilab.fr
parents: 868
diff changeset
    21
        self.assertEquals(form.form_render(self.entity, state=123),
168ad6d424d1 form to edit multiple entities, use it in DeleteConfForm
sylvain.thenault@logilab.fr
parents: 868
diff changeset
    22
                          ''' ''')
168ad6d424d1 form to edit multiple entities, use it in DeleteConfForm
sylvain.thenault@logilab.fr
parents: 868
diff changeset
    23
168ad6d424d1 form to edit multiple entities, use it in DeleteConfForm
sylvain.thenault@logilab.fr
parents: 868
diff changeset
    24
    def test_change_state_form(self):
868
5d993a0c794c update test, use a DateTimePicker widget
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 866
diff changeset
    25
        form = ChangeStateForm(self.req, redirect_path='perdu.com')
5d993a0c794c update test, use a DateTimePicker widget
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 866
diff changeset
    26
        self.assertEquals(form.form_render(self.entity, state=123),
866
6fdb029663ca use EnvBasedTC since we need to access the schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 848
diff changeset
    27
                          ''' ''')
845
6103d0f55a0b simple tags
sylvain.thenault@logilab.fr
parents:
diff changeset
    28
869
168ad6d424d1 form to edit multiple entities, use it in DeleteConfForm
sylvain.thenault@logilab.fr
parents: 868
diff changeset
    29
    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
    30
        rset = self.execute('EGroup X')
168ad6d424d1 form to edit multiple entities, use it in DeleteConfForm
sylvain.thenault@logilab.fr
parents: 868
diff changeset
    31
        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
    32
                          '')
845
6103d0f55a0b simple tags
sylvain.thenault@logilab.fr
parents:
diff changeset
    33
        
6103d0f55a0b simple tags
sylvain.thenault@logilab.fr
parents:
diff changeset
    34
if __name__ == '__main__':
6103d0f55a0b simple tags
sylvain.thenault@logilab.fr
parents:
diff changeset
    35
    unittest_main()