[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/RoleService/tests - __init__.py:1.1.2.1 testRoleService.py:1.1.2.1
Jim Fulton
jim@zope.com
Mon, 4 Mar 2002 17:19:29 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/RoleService/tests
In directory cvs.zope.org:/tmp/cvs-serv32696/RoleService/tests
Added Files:
Tag: Zope-3x-branch
__init__.py testRoleService.py
Log Message:
Added first-cut role service
=== Added File Zope3/lib/python/Zope/App/OFS/RoleService/tests/__init__.py ===
=== Added File Zope3/lib/python/Zope/App/OFS/RoleService/tests/testRoleService.py ===
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
"""
Revision information:
$Id: testRoleService.py,v 1.1.2.1 2002/03/04 22:19:29 jim Exp $
"""
from unittest import TestCase, TestLoader, TextTestRunner
from Zope.App.OFS.Container.tests.testIContainer import BaseTestIContainer
from Interface import Interface
from Zope.App.OFS.Folder.RootFolder import RootFolder
from Zope.App.OFS.Folder.Folder import Folder
from Zope.ContextWrapper import Wrapper
from Zope.App.OFS.RoleService.RoleService import RoleService
from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
from Zope.ComponentArchitecture import getService
from Zope.App.Security.RoleRegistry import roleRegistry
class ITestService(Interface): pass
class TestService:
__implements__ = ITestService
class RoleServiceTests(BaseTestIContainer, CleanUp, TestCase):
def _Test__new(self):
return RoleService()
def testGetRole(self):
roleRegistry.defineRole('Manager', 'Manager', '')
from Zope.App.OFS.RoleService.Role import Role
rs = self._Test__new()
r = Role()
r.setId("Hacker")
rs.setObject("Hacker", r)
self.assertEqual(rs.getRole('Hacker').getId(), 'Hacker')
self.assertEqual(rs.getRole('Manager').getId(), 'Manager')
roles = [role.getId() for role in rs.getRoles()]
roles.sort()
self.assertEqual(roles, ['Anonymous', 'Hacker', 'Manager'])
def test_suite():
loader=TestLoader()
return loader.loadTestsFromTestCase(RoleServiceTests)
if __name__=='__main__':
TextTestRunner().run(test_suite())