Back to index

plone3  3.1.7
test_FSMetadata.py
Go to the documentation of this file.
00001 ##############################################################################
00002 #
00003 # Copyright (c) 2002 Zope Corporation and Contributors. All Rights Reserved.
00004 #
00005 # This software is subject to the provisions of the Zope Public License,
00006 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
00007 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
00008 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00009 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
00010 # FOR A PARTICULAR PURPOSE.
00011 #
00012 ##############################################################################
00013 """ Unit tests for FSMetadata module.
00014 
00015 $Id: test_FSMetadata.py 68496 2006-06-05 16:30:18Z yuppie $
00016 """
00017 
00018 import unittest
00019 import Testing
00020 
00021 from test_FSSecurity import FSSecurityBase
00022 
00023 
00024 class FSMetadata(FSSecurityBase):
00025 
00026     def _checkProxyRoles(self, obj, roles):
00027         # Test proxy roles on the object
00028         for role in roles:
00029             if not obj.manage_haveProxy(role):
00030                 raise 'Object does not have the "%s" role' % role
00031 
00032     def test_basicPermissions(self):
00033         # Test basic FS permissions
00034         # check it has a title
00035         assert(self.ob.fake_skin.test6.title == 'Test object')
00036         self._checkSettings(
00037             self.ob.fake_skin.test6,
00038             'Access contents information',
00039             1,
00040             ['Manager','Anonymous'])
00041         self._checkSettings(
00042             self.ob.fake_skin.test6,
00043             'View management screens',
00044             0,
00045             ['Manager'])
00046         self._checkProxyRoles(
00047             self.ob.fake_skin.test6,
00048             ['Manager', 'Anonymous'])
00049 
00050     def test_basicPermissionsOnImage(self):
00051         # Test basic FS permissions on Image
00052         test_image = getattr(self.ob.fake_skin, 'test_image.gif')
00053         assert(test_image.title == 'Test image')
00054         self._checkSettings(
00055             test_image,
00056             'Access contents information',
00057             1,
00058             ['Manager','Anonymous'])
00059         self._checkSettings(
00060             test_image,
00061             'View management screens',
00062             0,
00063             ['Manager'])
00064 
00065     def test_basicPermissionsOnFile(self):
00066         # Test basic FS permissions on File
00067         test_file = getattr(self.ob.fake_skin, 'test_file.swf')
00068         assert(test_file.title == 'Test file')
00069         self._checkSettings(
00070             test_file,
00071             'Access contents information',
00072             1,
00073             ['Manager','Anonymous'])
00074         self._checkSettings(
00075             test_file,
00076             'View management screens',
00077             0,
00078             ['Manager'])
00079 
00080     def test_proxy(self):
00081         # Test roles
00082         ob = self.ob.fake_skin.test_dtml
00083         self._checkProxyRoles(ob, ['Manager', 'Anonymous'])
00084 
00085 
00086 def test_suite():
00087     return unittest.TestSuite((
00088         unittest.makeSuite(FSMetadata),
00089         ))
00090 
00091 if __name__ == '__main__':
00092     unittest.main(defaultTest='test_suite')