Back to index

plone3  3.1.7
Public Member Functions | Public Attributes
CMFPlone.tests.testFolderButtons.TestObjectActions Class Reference
Inheritance diagram for CMFPlone.tests.testFolderButtons.TestObjectActions:
Inheritance graph
[legend]
Collaboration diagram for CMFPlone.tests.testFolderButtons.TestObjectActions:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def afterSetUp
def assertStatusEqual
def testObjectRenameWithoutVHM
def testObjectRenameWithVHM
def setRequestMethod
def getAuthenticator
def setupAuthenticator

Public Attributes

 basic_auth

Detailed Description

Definition at line 283 of file testFolderButtons.py.


Member Function Documentation

Definition at line 285 of file testFolderButtons.py.

00285 
00286     def afterSetUp(self):
00287         self.basic_auth = '%s:%s' % (default_user, default_password)
    

Definition at line 288 of file testFolderButtons.py.

00288 
00289     def assertStatusEqual(self, a, b, msg=''):
00290         if a != b:
00291             entries = self.portal.error_log.getLogEntries()
00292             if entries:
00293                 msg = entries[0]['tb_text']
00294             else:
00295                 if not msg:
00296                     msg = 'no error log entry available'
00297         self.failUnlessEqual(a, b, msg)
    

Here is the caller graph for this function:

Definition at line 30 of file PloneTestCase.py.

00030 
00031     def getAuthenticator(self):
00032         tag = AuthenticatorView('context', 'request').authenticator()
00033         pattern = '<input .*name="(\w+)".*value="(\w+)"'
00034         return match(pattern, tag).groups()

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFPlone.tests.PloneTestCase.PloneTestCase.setRequestMethod (   self,
  method 
) [inherited]
This is a stub now, but in case you want to try
   something fancy on Your Branch (tm), put it here.

Definition at line 26 of file PloneTestCase.py.

00026 
00027     def setRequestMethod(self, method):
00028         self.app.REQUEST.set('REQUEST_METHOD', method)
00029         self.app.REQUEST.method = method

Here is the caller graph for this function:

Definition at line 35 of file PloneTestCase.py.

00035 
00036     def setupAuthenticator(self):
00037         name, token = self.getAuthenticator()
00038         self.app.REQUEST.form[name] = token
00039 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 298 of file testFolderButtons.py.

00298 
00299     def testObjectRenameWithoutVHM(self):
00300         self.folder.invokeFactory('Document', 'd1', title='Doc1')
00301         folderUrl = self.folder.absolute_url()
00302         objPath = '/'.join(self.folder.d1.getPhysicalPath())
00303         objectUrl = self.folder.d1.absolute_url()
00304         origTemplate = self.folder.d1.absolute_url() + '/document_view?foo=bar'
00305 
00306         response = self.publish(objPath + '/object_rename', self.basic_auth, extra={'HTTP_REFERER' : origTemplate})
00307 
00308         self.assertStatusEqual(response.getStatus(), 302) # Redirect to edit
00309         
00310         location = response.getHeader('Location').split('?')[0]
00311         params = {}
00312         for p in response.getHeader('Location').split('?')[1].split('&'):
00313             key, val = p.split('=')
00314             self.failIf(key in params)
00315             params[key] = val
00316         self.failUnless('paths%3Alist' in params)
00317         self.failUnless('orig_template' in params)
00318 
00319         self.failUnless(location.startswith(objectUrl), location)
00320         self.failUnless(location.endswith('folder_rename_form'), location)
00321 
00322         # Perform the redirect
00323         editFormPath = location[len(self.app.REQUEST.SERVER_URL):]
00324         newParams = "orig_template=%s" % params['orig_template']
00325         newParams += "&paths:list=%s" % params['paths%3Alist']
00326         response = self.publish("%s?%s" % (editFormPath, newParams,), self.basic_auth)
00327         self.assertStatusEqual(response.getStatus(), 200)
00328 
00329         # Set up next set of params, faking user submission
00330         newParams += "&form.submitted=1"
00331         newParams += "&form.button.renameAll=Rename All"
00332         newParams += "&new_ids:list=%s" % 'new-id'
00333         newParams += "&new_titles:list=%s" % 'New title'
00334         newParams += '&%s=%s' % self.getAuthenticator()
00335 
00336         data = StringIO(newParams)
00337         response = self.publish(editFormPath, self.basic_auth,
00338                                 request_method='POST', stdin=data)
00339         self.assertStatusEqual(response.getStatus(), 302)
00340         
00341         # Make sure we landed in the right place
00342         location = response.getHeader('Location').split('?')[0]
00343         self.failUnless(location.startswith(folderUrl + '/new-id'), location)
00344         self.failUnless(location.endswith('document_view'), location)
00345         
00346         self.failUnless('new-id' in self.folder.objectIds())
00347         self.failIf('d1' in self.folder.objectIds())
00348         self.assertEqual(self.folder['new-id'].Title(), 'New title')

Here is the call graph for this function:

Definition at line 349 of file testFolderButtons.py.

00349 
00350     def testObjectRenameWithVHM(self):
00351         adding = self.app.manage_addProduct['SiteAccess']
00352         adding.manage_addVirtualHostMonster('vhm')
00353         
00354         vhmBasePath = "/VirtualHostBase/http/example.org:80/%s/VirtualHostRoot/" % self.portal.getId()
00355         vhmBaseUrl = 'http://example.org/'
00356         
00357         self.folder.invokeFactory('Document', 'd1', title='Doc1')
00358         folderPath = vhmBasePath + '/'.join(self.folder.getPhysicalPath()[2:])
00359         folderUrl = vhmBaseUrl + '/'.join(self.folder.getPhysicalPath()[2:]) 
00360         objPath = vhmBasePath + '/'.join(self.folder.d1.getPhysicalPath()[2:])
00361         objectUrl = vhmBaseUrl + '/'.join(self.folder.d1.getPhysicalPath()[2:])
00362         
00363         origTemplate = objectUrl + '/document_view?foo=bar'
00364 
00365         response = self.publish(objPath + '/object_rename', self.basic_auth, extra={'HTTP_REFERER' : origTemplate})
00366 
00367         self.assertStatusEqual(response.getStatus(), 302) # Redirect to edit
00368         
00369         location = response.getHeader('Location').split('?')[0]
00370         params = {}
00371         for p in response.getHeader('Location').split('?')[1].split('&'):
00372             key, val = p.split('=')
00373             self.failIf(key in params)
00374             params[key] = val
00375         self.failUnless('paths%3Alist' in params)
00376         self.failUnless('orig_template' in params)
00377 
00378         self.failUnless(location.startswith(objectUrl), location)
00379         self.failUnless(location.endswith('folder_rename_form'), location)
00380 
00381         # Perform the redirect
00382         editFormPath = vhmBasePath + location[len(vhmBaseUrl):]
00383         newParams = "orig_template=%s" % params['orig_template']
00384         newParams += "&paths:list=%s" % params['paths%3Alist']
00385         response = self.publish("%s?%s" % (editFormPath, newParams,), self.basic_auth)
00386         self.assertStatusEqual(response.getStatus(), 200)
00387 
00388         # Set up next set of params, faking user submission
00389         newParams += "&form.submitted=1"
00390         newParams += "&form.button.renameAll=Rename All"
00391         newParams += "&new_ids:list=%s" % 'new-id'
00392         newParams += "&new_titles:list=%s" % 'New title'
00393         newParams += '&%s=%s' % self.getAuthenticator()
00394 
00395         data = StringIO(newParams)
00396         response = self.publish(editFormPath, self.basic_auth,
00397                                 request_method='POST', stdin=data)
00398         self.assertStatusEqual(response.getStatus(), 302)
00399         
00400         # Make sure we landed in the right place
00401         location = response.getHeader('Location').split('?')[0]
00402         self.failUnless(location.startswith(folderUrl + '/new-id'), location)
00403         self.failUnless(location.endswith('document_view'), location)
00404         
00405         self.failUnless('new-id' in self.folder.objectIds())
00406         self.failIf('d1' in self.folder.objectIds())
00407         self.assertEqual(self.folder['new-id'].Title(), 'New title')
00408 

Here is the call graph for this function:


Member Data Documentation

Definition at line 286 of file testFolderButtons.py.


The documentation for this class was generated from the following file: