move tests where they belong tls-sprint
authorsylvain.thenault@logilab.fr
Wed, 08 Apr 2009 14:11:34 +0200
branchtls-sprint
changeset 1300 62d2b890a980
parent 1298 ca02a2b5e9be
child 1301 4596ce9bb4dc
move tests where they belong
web/test/unittest_form.py
web/test/unittest_views_editforms.py
--- a/web/test/unittest_form.py	Wed Apr 08 13:20:05 2009 +0200
+++ b/web/test/unittest_form.py	Wed Apr 08 14:11:34 2009 +0200
@@ -19,43 +19,12 @@
         
     # form view tests #########################################################
         
-    def test_delete_conf_formview(self):
-        rset = self.execute('EGroup X')
-        self.view('deleteconf', rset, template=None).source
-        
     def test_massmailing_formview(self):
         self.execute('INSERT EmailAddress X: X address L + "@cubicweb.org", '
                      'U use_email X WHERE U is EUser, U login L')
         rset = self.execute('EUser X')
         self.view('massmailing', rset, template=None)
         
-    def test_automatic_edition_formview(self):
-        rset = self.execute('EUser X')
-        self.view('edition', rset, row=0, template=None).source
-        
-    def test_automatic_edition_formview(self):
-        rset = self.execute('EUser X')
-        self.view('copy', rset, row=0, template=None).source
-        
-    def test_automatic_creation_formview(self):
-        self.view('creation', None, etype='EUser', template=None).source
-        
-    def test_automatic_muledit_formview(self):
-        rset = self.execute('EUser X')
-        self.view('muledit', rset, template=None).source
-        
-    def test_automatic_reledit_formview(self):
-        rset = self.execute('EUser X')
-        self.view('reledit', rset, row=0, rtype='login', template=None).source
-        
-    def test_automatic_inline_edit_formview(self):
-        geid = self.execute('EGroup X LIMIT 1')[0][0]
-        rset = self.execute('EUser X LIMIT 1')
-        self.view('inline-edition', rset, row=0, rtype='in_group', peid=geid, template=None).source
-                              
-    def test_automatic_inline_creation_formview(self):
-        geid = self.execute('EGroup X LIMIT 1')[0][0]
-        self.view('inline-creation', None, etype='EUser', rtype='in_group', peid=geid, template=None).source
 
     # form tests ##############################################################
     
@@ -72,13 +41,6 @@
                                entity=self.entity)
         form.form_render(state=123, trcomment=u'')
         
-    def test_edition_form(self):
-        rset = self.execute('EUser X LIMIT 1')
-        form = self.vreg.select_object('forms', 'edition', rset.req, rset, row=0, col=0)
-        # should be also selectable by specifying entity
-        self.vreg.select_object('forms', 'edition', self.request(), entity=rset.get_entity(0, 0))
-        self.failIf(any(f for f in form.fields if f is None))
-        
     # fields tests ############################################################
 
     def _render_entity_field(self, name, form):
@@ -99,10 +61,10 @@
     def test_richtextfield_1(self):
         self.req.use_fckeditor = lambda: False
         self._test_richtextfield('''<select name="content_format:%(eid)s" id="content_format:%(eid)s" tabindex="0">
-<option value="text/rest">text/rest</option>
+<option value="text/cubicweb-page-template">text/cubicweb-page-template</option>
 <option selected="selected" value="text/html">text/html</option>
 <option value="text/plain">text/plain</option>
-<option value="text/cubicweb-page-template">text/cubicweb-page-template</option>
+<option value="text/rest">text/rest</option>
 </select><textarea tabindex="1" id="content:%(eid)s" name="content:%(eid)s" onkeypress="autogrow(this)">&lt;h1&gt;new widgets system&lt;/h1&gt;</textarea>''')
 
     
@@ -163,7 +125,7 @@
         self.assertTextEquals(self._render_entity_field('upassword', form),
                               '''<input id="upassword:%(eid)s" type="password" name="upassword:%(eid)s" value="__cubicweb_internal_field__" tabindex="0"/>
 <br/>
-<input type="password" name="upassword-confirm:%(eid)s" tabindex="0"/>
+<input type="password" name="upassword-confirm:%(eid)s" value="__cubicweb_internal_field__" tabindex="0"/>
 &nbsp;
 <span class="emphasis">confirm password</span>''' % {'eid': self.entity.eid})
 
--- a/web/test/unittest_views_editforms.py	Wed Apr 08 13:20:05 2009 +0200
+++ b/web/test/unittest_views_editforms.py	Wed Apr 08 14:11:34 2009 +0200
@@ -1,5 +1,6 @@
 from logilab.common.testlib import unittest_main
 from cubicweb.devtools.apptest import EnvBasedTC
+from cubicweb.devtools.testlib import WebTest
 from cubicweb.web.views.editforms import AutomaticEntityForm as AEF
 
 def rbc(entity, category):
@@ -40,19 +41,22 @@
                                ])
         # owned_by is defined both as subject and object relations on EUser
         self.assertListEquals(rbc(e, 'generated'),
-                              [('is', 'subject'),
+                              [('has_text', 'subject'),
+                               ('identity', 'subject'),
+                               ('is', 'subject'),
                                ('is_instance_of', 'subject'),
                                ('tags', 'object'),
                                ('for_user', 'object'),
                                ('created_by', 'object'),
                                ('wf_info_for', 'object'),
                                ('owned_by', 'object'),
+                               ('identity', 'object'),
                                ])
 
     def test_inlined_view(self):
         self.failUnless(AEF.rinlined.etype_rtag('EUser', 'use_email', 'subject'))
         self.failIf(AEF.rinlined.etype_rtag('EUser', 'primary_email', 'subject'))
-                        
+        
     def test_personne_relations_by_category(self):
         e = self.etype_instance('Personne')
         self.assertListEquals(rbc(e, 'primary'),
@@ -84,8 +88,56 @@
                                ('connait', 'object')
                                ])
         self.assertListEquals(rbc(e, 'generated'),
-                              [('is', 'subject'),
+                              [('has_text', 'subject'),
+                               ('identity', 'subject'),
+                               ('is', 'subject'),
                                ('is_instance_of', 'subject'),
+                               ('identity', 'object'),
                                ])
+        
+    def test_edition_form(self):
+        rset = self.execute('EUser X LIMIT 1')
+        form = self.vreg.select_object('forms', 'edition', rset.req, rset,
+                                       row=0, col=0)
+        # should be also selectable by specifying entity
+        self.vreg.select_object('forms', 'edition', self.request(), None,
+                                entity=rset.get_entity(0, 0))
+        self.failIf(any(f for f in form.fields if f is None))
+        
+        
+class FormViewsTC(WebTest):
+    def test_delete_conf_formview(self):
+        rset = self.execute('EGroup X')
+        self.view('deleteconf', rset, template=None).source
+        
+    def test_automatic_edition_formview(self):
+        rset = self.execute('EUser X')
+        self.view('edition', rset, row=0, template=None).source
+        
+    def test_automatic_edition_formview(self):
+        rset = self.execute('EUser X')
+        self.view('copy', rset, row=0, template=None).source
+        
+    def test_automatic_creation_formview(self):
+        self.view('creation', None, etype='EUser', template=None).source
+        
+    def test_automatic_muledit_formview(self):
+        rset = self.execute('EUser X')
+        self.view('muledit', rset, template=None).source
+        
+    def test_automatic_reledit_formview(self):
+        rset = self.execute('EUser X')
+        self.view('reledit', rset, row=0, rtype='login', template=None).source
+        
+    def test_automatic_inline_edit_formview(self):
+        geid = self.execute('EGroup X LIMIT 1')[0][0]
+        rset = self.execute('EUser X LIMIT 1')
+        self.view('inline-edition', rset, row=0, rtype='in_group', peid=geid, template=None).source
+                              
+    def test_automatic_inline_creation_formview(self):
+        geid = self.execute('EGroup X LIMIT 1')[0][0]
+        self.view('inline-creation', None, etype='EUser', rtype='in_group', peid=geid, template=None).source
+
+        
 if __name__ == '__main__':
     unittest_main()