fix tests tls-sprint
authorsylvain.thenault@logilab.fr
Wed, 18 Feb 2009 15:17:04 +0100
branchtls-sprint
changeset 793 06b05dce4831
parent 792 685f020f855f
child 794 b2f962292dbf
fix tests
server/serverconfig.py
web/test/unittest_viewselector.py
--- a/server/serverconfig.py	Wed Feb 18 15:16:54 2009 +0100
+++ b/server/serverconfig.py	Wed Feb 18 15:17:04 2009 +0100
@@ -1,7 +1,7 @@
 """server.serverconfig definition
 
 :organization: Logilab
-:copyright: 2001-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
 """
 __docformat__ = "restructuredtext en"
--- a/web/test/unittest_viewselector.py	Wed Feb 18 15:16:54 2009 +0100
+++ b/web/test/unittest_viewselector.py	Wed Feb 18 15:17:04 2009 +0100
@@ -4,13 +4,13 @@
 from __future__ import with_statement
 
 from logilab.common.testlib import unittest_main
+
 from cubicweb.devtools.apptest import EnvBasedTC
-
-
 from cubicweb import CW_SOFTWARE_ROOT as BASE, Binary
-from cubicweb.selectors import match_user_groups, implements, rql_condition, traced_selection
-
-from cubicweb.web._exceptions import NoSelectableObject
+from cubicweb.selectors import (match_user_groups, implements,
+                                specified_etype_implements, rql_condition,
+                                traced_selection)
+from cubicweb.web import NoSelectableObject
 from cubicweb.web.action import Action
 from cubicweb.web.views import (baseviews, tableview, baseforms, calendar, 
                                 management, embedding, actions, startup, 
@@ -61,8 +61,7 @@
             raise
         
     
-    def test_possible_views(self):
-        # no entity
+    def test_possible_views_none_rset(self):
         req = self.request()
         self.assertListEqual(self.pviews(req, None),
                              [('changelog', wdoc.ChangeLogView),
@@ -74,11 +73,13 @@
                               ('owl', owl.OWLView),
                               ('schema', startup.SchemaView),
                               ('systemepropertiesform', eproperties.SystemEPropertiesForm)])
-        # no entity but etype
+        
+    def test_possible_views_noresult(self):
         rset, req = self.env.get_rset_and_req('Any X WHERE X eid 999999')
         self.assertListEqual(self.pviews(req, rset),
                              [])
-        # one entity
+        
+    def test_possible_views_one_egroup(self):
         rset, req = self.env.get_rset_and_req('EGroup X WHERE X name "managers"')
         self.assertListEqual(self.pviews(req, rset),
                              [('csvexport', baseviews.CSVRsetView),
@@ -99,7 +100,8 @@
                               ('xbel', xbel.XbelView),
                               ('xml', baseviews.XmlView),
                               ])
-        # list of entities of the same type
+            
+    def test_possible_views_multiple_egroups(self):
         rset, req = self.env.get_rset_and_req('EGroup X')
         self.assertListEqual(self.pviews(req, rset),
                              [('csvexport', baseviews.CSVRsetView),
@@ -120,7 +122,8 @@
                               ('xbel', xbel.XbelView),
                               ('xml', baseviews.XmlView),
                               ])
-        # list of entities of different types
+        
+    def test_possible_views_multiple_different_types(self):
         rset, req = self.env.get_rset_and_req('Any X')
         self.assertListEqual(self.pviews(req, rset),
                              [('csvexport', baseviews.CSVRsetView),
@@ -141,7 +144,8 @@
                               ('xbel', xbel.XbelView),
                               ('xml', baseviews.XmlView),
                               ])
-        # whatever
+        
+    def test_possible_views_any_rset(self):
         rset, req = self.env.get_rset_and_req('Any N, X WHERE X in_group Y, Y name N')
         self.assertListEqual(self.pviews(req, rset),
                              [('csvexport', baseviews.CSVRsetView),
@@ -149,7 +153,8 @@
                               ('rsetxml', baseviews.XMLRsetView),
                               ('table', tableview.TableView),
                               ])
-        # list of euser entities
+
+    def test_possible_views_multiple_eusers(self):
         rset, req = self.env.get_rset_and_req('EUser X')
         self.assertListEqual(self.pviews(req, rset),
                              [('csvexport', baseviews.CSVRsetView),
@@ -178,6 +183,7 @@
         self.assertDictEqual(self.pactions(req, None),
                              {'useractions': USERACTIONS,
                               'siteactions': SITEACTIONS,
+                              
                               })
     def test_possible_actions_no_entity(self):
         rset, req = self.env.get_rset_and_req('Any X WHERE X eid 999999')
@@ -185,6 +191,7 @@
                              {'useractions': USERACTIONS,
                               'siteactions': SITEACTIONS,
                               })
+        
     def test_possible_actions_same_type_entities(self):
         rset, req = self.env.get_rset_and_req('EGroup X')
         self.assertDictEqual(self.pactions(req, rset),
@@ -194,6 +201,7 @@
                               'moreactions': [('delete', actions.DeleteAction),
                                               ('addentity', actions.AddNewAction)],
                               })
+        
     def test_possible_actions_different_types_entities(self):
         rset, req = self.env.get_rset_and_req('Any X')
         self.assertDictEqual(self.pactions(req, rset),
@@ -201,6 +209,7 @@
                               'siteactions': SITEACTIONS,
                               'moreactions': [('delete', actions.DeleteAction)],
                               })
+            
     def test_possible_actions_final_entities(self):
         rset, req = self.env.get_rset_and_req('Any N, X WHERE X in_group Y, Y name N')
         self.assertDictEqual(self.pactions(req, rset),
@@ -215,7 +224,8 @@
                               'mainactions': [('edit', actions.ModifyAction),
                                               ('workflow', schemaentities.ViewWorkflowAction),],
                               'moreactions': [('delete', actions.DeleteAction),
-                                              ('copy', actions.CopyAction)],
+                                              ('copy', actions.CopyAction),
+                                              ('managepermission', actions.ManagePermissionsAction)],
                               })
         
 
@@ -229,7 +239,7 @@
         del req.form['etype']
         # custom creation form
         class EUserCreationForm(baseforms.CreationForm):
-            __select__ = implements('EUSer')
+            __select__ = specified_etype_implements('EUser')
         self.vreg.register_vobject_class(EUserCreationForm)
         req.form['etype'] = 'EUser'
         self.assertIsInstance(self.vreg.select_view('creation', req, rset),