[Zope-CVS] CVS: Products/PluggableAuthService/tests - test_PluggableAuthService.py:1.6

Zachery Bir zbir at urbanape.com
Tue Sep 7 14:17:40 EDT 2004


Update of /cvs-repository/Products/PluggableAuthService/tests
In directory cvs.zope.org:/tmp/cvs-serv22148

Modified Files:
	test_PluggableAuthService.py 
Log Message:
  - Since we're creating the Dummy Plugins to hold one value, it is
    easier to test if we also make the PLUGINID the id the plugin
    holds.

  - enumerate[Users|Groups] returns a tuple, not a list

  - test the new __before_traverse__ registration (and beef up the
    FauxObject to accommodate)


=== Products/PluggableAuthService/tests/test_PluggableAuthService.py 1.5 => 1.6 ===
--- Products/PluggableAuthService/tests/test_PluggableAuthService.py:1.5	Mon Aug 30 11:31:55 2004
+++ Products/PluggableAuthService/tests/test_PluggableAuthService.py	Tue Sep  7 14:17:39 2004
@@ -1,4 +1,4 @@
-##############################################################################
+1##############################################################################
 #
 # Copyright (c) 2001 Zope Corporation and Contributors. All Rights
 # Reserved.
@@ -28,11 +28,9 @@
 
 class DummyUserEnumerator( DummyPlugin ):
 
-    PLUGINID = 'users'
-
     def __init__( self, user_id, login=None ):
 
-        self._user_id = user_id
+        self._user_id = self.PLUGINID = user_id
 
         if login is None:
             login = user_id
@@ -47,20 +45,18 @@
                    } ]
 
         if kw.get( 'id' ) == self._user_id:
-            return result
+            return tuple(result)
 
         if kw.get( 'login' ) == self._login:
-            return result
+            return tuple(result)
 
-        return []
+        return ()
 
 class DummyGroupEnumerator( DummyPlugin ):
 
-    PLUGINID = 'groups'
-
     def __init__( self, group_id ):
 
-        self._group_id = group_id
+        self._group_id = self.PLUGINID = group_id
 
     def enumerateGroups( self
                        , id=None
@@ -76,8 +72,8 @@
 
         if id:
             if self._group_id.find( id ) >= 0:
-                return result
-        return []
+                return tuple(result)
+        return ()
 
 class DummySuperEnumerator(DummyUserEnumerator, DummyGroupEnumerator):
 
@@ -153,6 +149,9 @@
 
         return 'Args: %s\nKeywords: %s' % ( args, kw )
 
+    def this(self):
+        return self
+
 class FauxContainer( FauxObject, ObjectManager ):
 
     pass
@@ -160,7 +159,7 @@
 class FauxRoot( FauxContainer ):
 
     isTopLevelPrincipiaApplicationObject = 1
-    
+
     def getPhysicalRoot( self ):
         return self
 
@@ -341,6 +340,16 @@
 
         self.assertEqual( zcuf.getId(), 'acl_users' )
 
+    def test_checkBeforeTraverse( self ):
+
+        rc, root, folder, object = self._makeTree()
+
+        zcuf = self._makeOne()
+
+        root._setObject('acl_users', zcuf)
+
+        self.assertEqual( len(root.__before_traverse__), 1)
+
     def test__extractUserIds_simple( self ):
 
         from Products.PluggableAuthService.interfaces.plugins \
@@ -1149,12 +1158,12 @@
         self.assertEqual( zcuf.getUser( 'zope' ), None )
 
         user = zcuf.getUser( 'foo' )
-        self.assertEqual( user.getId(), 'users__foo' )
+        self.assertEqual( user.getId(), 'foo__foo' )
 
-        self.assertEqual( zcuf.getUser( 'users__bar' ), None )
+        self.assertEqual( zcuf.getUser( 'foo__bar' ), None )
 
         user = zcuf.getUser( 'bar at example.com' )
-        self.assertEqual( user.getId(), 'users__bar' )
+        self.assertEqual( user.getId(), 'bar__bar' )
 
     def test_simple_getUserGroups_with_Groupplugin(self):
 



More information about the Zope-CVS mailing list