[Zope-CVS] CVS: Products/PluggableAuthService/plugins/tests -
test_ZODBGroupManager.py:1.4
Zachery Bir
zbir at urbanape.com
Mon Aug 30 11:29:19 EDT 2004
Update of /cvs-repository/Products/PluggableAuthService/plugins/tests
In directory cvs.zope.org:/tmp/cvs-serv19939
Modified Files:
test_ZODBGroupManager.py
Log Message:
Moved some of the dummy classes to the helpers module
=== Products/PluggableAuthService/plugins/tests/test_ZODBGroupManager.py 1.3 => 1.4 ===
--- Products/PluggableAuthService/plugins/tests/test_ZODBGroupManager.py:1.3 Thu Aug 12 11:15:55 2004
+++ Products/PluggableAuthService/plugins/tests/test_ZODBGroupManager.py Mon Aug 30 11:29:19 2004
@@ -19,17 +19,8 @@
from Products.PluggableAuthService.tests.conformance \
import IGroupsPlugin_conformance
-from Products.PluggableAuthService.tests.test_PluggableAuthService \
- import FauxContainer
-
-class FauxPAS( FauxContainer ):
-
- def __init__( self ):
- self._id = 'acl_users'
-
- def searchPrincipals( self, **kw ):
- id = kw.get( 'id' )
- return [ { 'id': id } ]
+from Products.PluggableAuthService.plugins.tests.helpers \
+ import FauxPAS, FauxSmartPAS, DummyUser
class DummyGroup:
@@ -39,14 +30,6 @@
def getId( self ):
return self._id
-class DummyUser:
-
- def __init__( self, id ):
- self._id = id
-
- def getId( self ):
- return self._id
-
class ZODBGroupManagerTests( unittest.TestCase
, IGroupEnumerationPlugin_conformance
, IGroupsPlugin_conformance
@@ -119,10 +102,36 @@
zgm.addGroup( 'group' )
user = DummyUser( 'userid' )
-
+
zgm.addPrincipalToGroup( user.getId(), 'group' )
groups = zgm.getGroupsForPrincipal( user )
self.assertEqual( groups, ( 'group', ) )
+
+ def test_addPrincipalToGroupThenRemovePrincipal( self ):
+
+ root = FauxSmartPAS()
+ root.user_ids['foo'] = 'foo'
+
+ zgm = self._makeOne( id='groups' ).__of__( root )
+
+ zgm.addGroup( 'group', 'group_title', 'group_desc' )
+ self.assertEqual( len( zgm.listAssignedPrincipals( 'group' ) ), 0 )
+
+ new = zgm.addPrincipalToGroup( 'foo', 'group' )
+
+ self.failUnless( new )
+
+ assigned = [x[1] for x in zgm.listAssignedPrincipals( 'group' )]
+
+ self.assertEqual( len( assigned ), 1 )
+ self.assertEqual( assigned[0], 'foo' )
+
+ del root.user_ids['foo']
+
+ assigned = [x[1] for x in zgm.listAssignedPrincipals( 'group' )]
+
+ self.assertEqual( len( assigned ), 1 )
+ self.assertEqual( assigned[0], '<foo: not found>' )
def test_removePrincipalFromGroup( self ):
More information about the Zope-CVS
mailing list