[Zope-Checkins] CVS: Zope/lib/python/AccessControl/tests - testUserFolder.py:1.5.6.1
Chris McDonough
chrism@zope.com
Wed, 16 Oct 2002 17:35:07 -0400
Update of /cvs-repository/Zope/lib/python/AccessControl/tests
In directory cvs.zope.org:/tmp/cvs-serv27921/AccessControl/tests
Modified Files:
Tag: Zope-2_6-branch
testUserFolder.py
Log Message:
Fix up calls to user objects' getUserName which should really be calls to
getId. This is a change designed to make it possible to disambiguate user names and user ids in subclasses of user folders, while still doing the "right thing" with respect to local data structures that keep pointers to user ids (eg. local roles, etc.)
=== Zope/lib/python/AccessControl/tests/testUserFolder.py 1.5 => 1.5.6.1 ===
--- Zope/lib/python/AccessControl/tests/testUserFolder.py:1.5 Wed Aug 14 17:28:08 2002
+++ Zope/lib/python/AccessControl/tests/testUserFolder.py Wed Oct 16 17:34:36 2002
@@ -19,14 +19,11 @@
import os, sys, unittest
import ZODB
-from DocumentTemplate import HTML
-from DocumentTemplate.tests.testDTML import DTMLTests
-from Products.PythonScripts.standard import DTML
from AccessControl import User, Unauthorized
-from AccessControl.User import BasicUserFolder
+from AccessControl.User import BasicUserFolder, UserFolder, User
from ExtensionClass import Base
-class SecurityTests (DTMLTests):
+class UserFolderTests(unittest.TestCase):
def testMaxListUsers(self):
# create a folder-ish thing which contains a roleManager,
@@ -67,10 +64,38 @@
except OverflowError:
assert 0, "Raised overflow error erroneously"
+class UserTests(unittest.TestCase):
+
+ def testGetUserName(self):
+ f = User('chris', '123', ['Manager'], [])
+ self.assertEqual(f.getUserName(), 'chris')
+
+ def testGetUserId(self):
+ f = User('chris', '123', ['Manager'], [])
+ self.assertEqual(f.getId(), 'chris')
+
+ def testBaseUserGetIdEqualGetName(self):
+ # this is true for the default user type, but will not
+ # always be true for extended user types going forward (post-2.6)
+ f = User('chris', '123', ['Manager'], [])
+ self.assertEqual(f.getId(), f.getUserName())
+
+ def testGetPassword(self):
+ f = User('chris', '123', ['Manager'], [])
+ self.assertEqual(f._getPassword(), '123')
+
+ def testGetRoles(self):
+ f = User('chris', '123', ['Manager'], [])
+ self.assertEqual(f.getRoles(), ('Manager', 'Authenticated'))
+
+ def testGetDomains(self):
+ f = User('chris', '123', ['Manager'], [])
+ self.assertEqual(f.getDomains(), ())
def test_suite():
suite = unittest.TestSuite()
- suite.addTest( unittest.makeSuite( SecurityTests ) )
+ suite.addTest(unittest.makeSuite(UserFolderTests))
+ suite.addTest(unittest.makeSuite(UserTests))
return suite
def main():