Back to index

plone3  3.1.7
testExternalEditorEnabled.py
Go to the documentation of this file.
00001 #
00002 # Test check_id script
00003 #
00004 
00005 from Products.CMFPlone.tests import PloneTestCase
00006 
00007 
00008 class TestExternalEditorEnabled(PloneTestCase.PloneTestCase):
00009     '''Tests the externalEditorEnabled script'''
00010 
00011     def afterSetUp(self):
00012         PloneTestCase.PloneTestCase.afterSetUp(self)
00013         self.folder.invokeFactory('Document','doc')
00014         self.doc = self.folder.doc
00015         self.folder.invokeFactory('Folder','folder2')
00016         self.folder = self.folder.folder2
00017         self.portal.acl_users._doAddUser('user1', 'secret', ['Member'], [])
00018         self.mtool = self.portal.portal_membership
00019         member = self.mtool.getAuthenticatedMember()
00020         member.setMemberProperties({'ext_editor' : 1})
00021 
00022         self.lockbody = ('<?xml version="1.0" encoding="utf-8"?>\n'
00023                 '<d:lockinfo xmlns:d="DAV:">\n'
00024                 '  <d:lockscope><d:exclusive/></d:lockscope>\n'
00025                 '  <d:locktype><d:write/></d:locktype>\n'
00026                 '  <d:depth>infinity</d:depth>\n'
00027                 '  <d:owner>\n'
00028                 '  <d:href>Zope External Editor</d:href>\n'
00029                 '  </d:owner>\n'
00030                 '</d:lockinfo>'
00031                 )
00032 
00033     def testFailForAnonymous(self):
00034         self.failUnless(self.doc.externalEditorEnabled())
00035         self.logout()
00036         self.failIf(self.doc.externalEditorEnabled())
00037 
00038     def testFailOnDisabledMemberProperty(self):
00039         self.failUnless(self.doc.externalEditorEnabled())
00040         member = self.mtool.getAuthenticatedMember()
00041         member.setMemberProperties({'ext_editor' : 0})
00042         self.failIf(self.doc.externalEditorEnabled())
00043 
00044     def testFailOnUnSupportedObjects(self):
00045         # ATCT Folders are editable by default now
00046         self.failUnless(self.folder.externalEditorEnabled())
00047         # But if __dav_marshall__ is set to False then they aren't.
00048         self.folder.__dav_marshall__ = False
00049         self.failIf(self.folder.externalEditorEnabled())
00050 
00051     def testFailWithoutUseExtEditPermission(self):
00052         self.portal.manage_permission('Use external editor',
00053                                       ('Owner','Manager'), 0)
00054         self.login('user1')
00055         self.failIf(self.doc.externalEditorEnabled())
00056 
00057     def testFailWhenObjectIsLocked(self):
00058         # Should not show if someone already has a webdav lock on the object
00059         self.doc.REQUEST.set('BODY', self.lockbody)
00060         self.doc.LOCK(self.doc.REQUEST, self.doc.REQUEST.RESPONSE)
00061         self.failIf(self.doc.externalEditorEnabled())
00062         self.doc.wl_clearLocks()
00063         self.failUnless(self.doc.externalEditorEnabled())
00064 
00065 
00066 def test_suite():
00067     from unittest import TestSuite, makeSuite
00068     suite = TestSuite()
00069     suite.addTest(makeSuite(TestExternalEditorEnabled))
00070     return suite