web/test/unittest_views_editforms.py
branchtls-sprint
changeset 1300 62d2b890a980
parent 1298 ca02a2b5e9be
child 1359 bef6891393d7
--- 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()