Back to index

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

List of all members.

Public Member Functions

def afterSetUp
def testTitleIsUpdatedOnTitleChange
def testCatalogTitleIsUpdatedOnFolderTitleChange
def testTitleAndIdAreUpdatedOnFolderRename
def testCatalogTitleAndIdAreUpdatedOnFolderRename
def testUpdateMultiplePaths
def testNoErrorOnBadPaths
def testGETRaises
def setRequestMethod
def getAuthenticator
def setupAuthenticator

Public Attributes

 catalog

Detailed Description

Definition at line 20 of file testFolderButtons.py.


Member Function Documentation

Definition at line 23 of file testFolderButtons.py.

00023 
00024     def afterSetUp(self):
00025         self.catalog = self.portal.portal_catalog
00026         self.folder.invokeFactory('Folder', id='foo')
00027         self.folder.invokeFactory('Folder', id='bar')
00028         self.folder.foo.invokeFactory('Document', id='doc1')
00029         self.folder.bar.invokeFactory('Document', id='doc2')
00030         # folder_rename requires a non-GET request
00031         self.setRequestMethod('POST')
00032         self.setupAuthenticator()

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 62 of file testFolderButtons.py.

00062 
00063     def testCatalogTitleAndIdAreUpdatedOnFolderRename(self):
00064         # Make sure catalog updates title on rename
00065         title = 'Test Folder - Snooze!'
00066         transaction.savepoint(optimistic=True) # make rename work
00067         doc_path = '/'.join(self.folder.foo.doc1.getPhysicalPath())
00068         self.folder.folder_rename(paths=[doc_path], new_ids=['baz'], new_titles=[title])
00069         results = self.catalog(Title='Snooze')
00070         self.failUnless(results)
00071         for result in results:
00072             self.assertEqual(result.Title, title)
00073             self.assertEqual(result.id, 'baz')

Definition at line 41 of file testFolderButtons.py.

00041 
00042     def testCatalogTitleIsUpdatedOnFolderTitleChange(self):
00043         # Make sure our title is updated in the catalog
00044         title = 'Test Doc - Snooze!'
00045         doc_path = '/'.join(self.folder.foo.doc1.getPhysicalPath())
00046         self.folder.folder_rename(paths=[doc_path], new_ids=['doc1'], new_titles=[title])
00047         results = self.catalog(Title='Snooze')
00048         self.failUnless(results)
00049         for result in results:
00050             self.assertEqual(result.Title, title)
00051             self.assertEqual(result.id, 'doc1')

Definition at line 93 of file testFolderButtons.py.

00093 
00094     def testGETRaises(self):
00095         # folder_rename requires a non-GET request and will fail otherwise
00096         self.setRequestMethod('GET')
00097         doc1_path = '/'.join(self.folder.foo.doc1.getPhysicalPath())
00098         self.assertRaises(Forbidden, self.folder.folder_rename,
00099                           [doc1_path], ['bar'], ['Baz'])
00100 

Here is the call graph for this function:

Definition at line 88 of file testFolderButtons.py.

00088 
00089     def testNoErrorOnBadPaths(self):
00090         # Ensure we don't fail on a bad path
00091         self.app.REQUEST.set('paths', ['/garbage/path'])
00092         self.folder.folder_rename_form()

Definition at line 52 of file testFolderButtons.py.

00052 
00053     def testTitleAndIdAreUpdatedOnFolderRename(self):
00054         # Make sure rename updates both title and id
00055         title = 'Test Folder - Snooze!'
00056         transaction.savepoint(optimistic=True) # make rename work
00057         doc_path = '/'.join(self.folder.foo.doc1.getPhysicalPath())
00058         self.folder.folder_rename(paths=[doc_path], new_ids=['baz'], new_titles=[title])
00059         self.assertEqual(getattr(self.folder.foo, 'doc1', None), None)
00060         self.failUnless(getattr(self.folder.foo, 'baz', None) is not None)
00061         self.assertEqual(self.folder.foo.baz.Title(),title)

Definition at line 33 of file testFolderButtons.py.

00033 
00034     def testTitleIsUpdatedOnTitleChange(self):
00035         # Make sure our title is updated on the object
00036         title = 'Test Doc - Snooze!'
00037         doc_path = '/'.join(self.folder.foo.doc1.getPhysicalPath())
00038         self.folder.folder_rename(paths=[doc_path], new_ids=['doc1'], new_titles=[title])
00039         obj = self.folder.foo.doc1
00040         self.assertEqual(obj.Title(), title)

Definition at line 74 of file testFolderButtons.py.

00074 
00075     def testUpdateMultiplePaths(self):
00076         # Ensure this works for multiple paths
00077         title = 'Test Folder - Snooze!'
00078         transaction.savepoint(optimistic=True) # make rename work
00079         doc1_path = '/'.join(self.folder.foo.doc1.getPhysicalPath())
00080         doc2_path = '/'.join(self.folder.bar.doc2.getPhysicalPath())
00081         self.folder.folder_rename(paths=[doc1_path,doc2_path], new_ids=['baz','blah'], new_titles=[title,title])
00082         self.assertEqual(getattr(self.folder.foo, 'doc1', None), None)
00083         self.assertEqual(getattr(self.folder.bar, 'doc2', None), None)
00084         self.failUnless(getattr(self.folder.foo, 'baz', None) is not None)
00085         self.failUnless(getattr(self.folder.bar, 'blah', None) is not None)
00086         self.assertEqual(self.folder.foo.baz.Title(),title)
00087         self.assertEqual(self.folder.bar.blah.Title(),title)


Member Data Documentation

Definition at line 24 of file testFolderButtons.py.


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