use EnvBasedTC since we need to access the schema tls-sprint
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
Thu, 19 Feb 2009 21:38:04 +0100
branchtls-sprint
changeset 866 6fdb029663ca
parent 865 90a1aea85637
child 867 14a79faa3a56
use EnvBasedTC since we need to access the schema
web/test/unittest_form.py
--- a/web/test/unittest_form.py	Thu Feb 19 21:36:39 2009 +0100
+++ b/web/test/unittest_form.py	Thu Feb 19 21:38:04 2009 +0100
@@ -1,32 +1,34 @@
-from logilab.common.testlib import TestCase, unittest_main, mock_object
-
+from logilab.common.testlib import unittest_main, mock_object
+from cubicweb.devtools.apptest import EnvBasedTC
 from cubicweb.web.form import *
 from cubicweb.web.views.baseforms import ChangeStateForm
 
 class CustomChangeStateForm(ChangeStateForm):
     hello = IntField(name='youlou')
 
-class EntityFieldsFormTC(TestCase):
+class EntityFieldsFormTC(EnvBasedTC):
 
     def setUp(self):
-        def next_tabindex(self):
-            self.count += 1
-            return self.count
-        self.req = mock_object(build_url=lambda *args,**kwargs: 'myurl.com/pouet',
-                               url=lambda *args,**kwargs: 'myurl.com/form',
-                               _=lambda s,x: x, form={},
-                               next_tabindex=next_tabindex, count=0)
-        self.entity = mock_object(eid=1, has_eid=lambda x: False, id='Entity')
+        super(EntityFieldsFormTC, self).setUp()
+##         def next_tabindex(self):
+##             self.count += 1
+##             return self.count
+##         self.req = mock_object(build_url=lambda *args,**kwargs: 'myurl.com/pouet',
+##                                url=lambda *args,**kwargs: 'myurl.com/form',
+##                                _=lambda s,x: x, form={}, data={},
+##                                next_tabindex=next_tabindex, count=0)
+##         self.entity = mock_object(eid=1, has_eid=lambda x: False, id='Entity')
         
     def test(self):
-        form = ChangeStateForm(self.req, redirect_path='perdu.com')
-        self.assertEquals(form.form_render(self.entity, state=123),
-                          '''''')
+        req = self.request()
+        form = ChangeStateForm(req, redirect_path='perdu.com')
+        self.assertEquals(form.form_render(self.user(req), state=123),
+                          ''' ''')
 
     def test_form_inheritance(self):
         form = CustomChangeStateForm(self.req, redirect_path='perdu.com')
         self.assertEquals(form.form_render(self.entity, state=123),
-                          '''''')
+                          ''' ''')
         
         
 if __name__ == '__main__':