Back to index

plone3  3.1.7
Public Member Functions
CMFPlone.tests.testNextPrevious.TestNextPrevious Class Reference
Inheritance diagram for CMFPlone.tests.testNextPrevious.TestNextPrevious:
Inheritance graph
[legend]
Collaboration diagram for CMFPlone.tests.testNextPrevious.TestNextPrevious:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def afterSetUp
def populateSite
def testIfFolderImplementsPreviousNext
def testNextPreviousEnablingOnCreation
def testNextPreviousViewDisabled
def testNextPreviousViewEnabled
def testAdapterOnPortal
def testNextPreviousItems
def setRequestMethod
def getAuthenticator
def setupAuthenticator

Detailed Description

Basic use cases and tests for next/previous navigation

Definition at line 8 of file testNextPrevious.py.


Member Function Documentation

Definition at line 12 of file testNextPrevious.py.

00012 
00013     def afterSetUp(self):
00014         self.populateSite()

Here is the call 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:

Definition at line 16 of file testNextPrevious.py.

00016 
00017     def populateSite(self):
00018         self.setRoles(['Manager'])
00019         self.portal.invokeFactory('Document', 'doc1')
00020         self.portal.invokeFactory('Document', 'doc2')
00021         self.portal.invokeFactory('Document', 'doc3')
00022         self.portal.invokeFactory('Folder', 'folder1')
00023         self.portal.invokeFactory('Link', 'link1')
00024         self.portal.link1.setRemoteUrl('http://plone.org')
00025         self.portal.link1.reindexObject()
00026         folder1 = getattr(self.portal, 'folder1')
00027         folder1.invokeFactory('Document', 'doc11')
00028         folder1.invokeFactory('Document', 'doc12')
00029         folder1.invokeFactory('Document', 'doc13')
00030         self.portal.invokeFactory('Folder', 'folder2')
00031         folder2 = getattr(self.portal, 'folder2')
00032         folder2.invokeFactory('Document', 'doc21')
00033         folder2.invokeFactory('Document', 'doc22')
00034         folder2.invokeFactory('Document', 'doc23')
00035         folder2.invokeFactory('File', 'file21')
00036         self.setRoles(['Member'])

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 75 of file testNextPrevious.py.

00075 
00076     def testAdapterOnPortal(self):
00077         view = self.portal.doc1.restrictedTraverse('@@plone_nextprevious_view', None)
00078         self.failUnless(view)
00079         self.failIf(view.enabled())
00080         self.assertEquals(None, view.next())
00081         self.assertEquals(None, view.previous())

Definition at line 37 of file testNextPrevious.py.

00037 
00038     def testIfFolderImplementsPreviousNext(self):
00039         self.folder.invokeFactory('Folder', 'case')
00040         self.failUnless(INextPreviousProvider(self.folder.case, None) is not None)

Definition at line 41 of file testNextPrevious.py.

00041 
00042     def testNextPreviousEnablingOnCreation(self):
00043         self.folder.invokeFactory('Folder', 'case')
00044         
00045         #first the field on the atfolder direct, to get sure the field is there
00046         enabled = self.folder.case.getNextPreviousEnabled()
00047         self.failIf(enabled)
00048         
00049         #secoundly we test if the adapter provides the isNextPreviousEnabled()
00050         adapter = INextPreviousProvider(self.folder.case)
00051         self.failIf(adapter.enabled)

Definition at line 82 of file testNextPrevious.py.

00082 
00083     def testNextPreviousItems(self):
00084         self.folder.invokeFactory('Folder', 'case3')
00085         
00086         for documentCounter in range(1, 6):
00087             self.folder.case3.invokeFactory('Document', 'subDoc%d' % documentCounter)
00088     
00089         container  = self.folder.case3
00090         testedItem = container.subDoc2
00091         
00092         #set up the adapter for the folder
00093         adapter = INextPreviousProvider(container)
00094 
00095         #test the next item of subDoc2
00096         next = adapter.getNextItem(self.folder.case3.subDoc2)
00097         self.failUnlessEqual(next["id"], 'subDoc3')
00098 
00099         #test that the contenttype is defined correct
00100         self.failUnlessEqual(next["portal_type"], 'Document')
00101         
00102         #test the previous item of subDoc2
00103         previous = adapter.getPreviousItem(self.folder.case3.subDoc2)
00104         self.failUnlessEqual(previous["id"], 'subDoc1')
00105         
00106         #first item should not have a previous item
00107         previous = adapter.getPreviousItem(self.folder.case3.subDoc1)
00108         self.failUnlessEqual(previous, None)
00109 
00110         #last item should not have a next item
00111         next = adapter.getNextItem(self.folder.case3.subDoc5)
00112         self.failUnlessEqual(next, None)

Definition at line 52 of file testNextPrevious.py.

00052 
00053     def testNextPreviousViewDisabled(self):
00054         view = self.portal.folder1.doc11.restrictedTraverse('@@plone_nextprevious_view', None)
00055         self.failIf(view is None)
00056         
00057         #is it enabled (default is false)
00058         self.failIf(view.enabled())

Definition at line 59 of file testNextPrevious.py.

00059 
00060     def testNextPreviousViewEnabled(self):
00061         #set the parent folder "getNextPreviousEnabled" to true
00062         self.portal.folder1.setNextPreviousEnabled(True)
00063         
00064         # clear request memos
00065         view = self.portal.folder1.doc12.restrictedTraverse('@@plone_nextprevious_view', None)
00066         self.failUnless(view.enabled())
00067 
00068         # test the next method
00069         next = view.next()
00070         self.assertEquals(next['url'], self.portal.folder1.doc13.absolute_url())
00071         
00072         # test the previous method
00073         previous = view.previous()
00074         self.assertEquals(previous['url'], self.portal.folder1.doc11.absolute_url())


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