web/test/unittest_form.py
author sylvain.thenault@logilab.fr
Thu, 19 Feb 2009 18:22:55 +0100
branchtls-sprint
changeset 845 6103d0f55a0b
child 847 27c4ebe90d03
permissions -rw-r--r--
simple tags

from logilab.common.testlib import TestCase, unittest_main, mock_object
from cubicweb.web.form import *

class ChangeStateForm(EntityFieldsForm):
    state = TextField(widget=HiddenInput, eidparam=False)
    __method = TextField(widget=HiddenInput, initial='set_state', eidparam=False)
    trcomment = RichTextField()

    def buttons(self):
        return []

class CustomChangeStateForm(ChangeStateForm):
    hello = IntField(name='youlou')

class EntityFieldsFormTC(TestCase):

    def test(self):
        req = mock_object(build_url=lambda *args,**kwargs: 'myurl.com')
        form = ChangeStateForm(req, redirect_path='perdu.com')
        entity = mock_object(eid=1)
        self.assertEquals(form.render(entity, state=123),
                          '''''')

    def test_form_inheritance(self):
        req = mock_object(build_url=lambda *args,**kwargs: 'myurl.com')
        form = CustomChangeStateForm(req, redirect_path='perdu.com')
        entity = mock_object(eid=1)
        self.assertEquals(form.render(entity, state=123),
                          '''''')
        
        
if __name__ == '__main__':
    unittest_main()