Back to index

plone3  3.1.7
Public Member Functions
plone.app.redirector.tests.test_view.TestRedirectorView Class Reference
Inheritance diagram for plone.app.redirector.tests.test_view.TestRedirectorView:
Inheritance graph
[legend]
Collaboration diagram for plone.app.redirector.tests.test_view.TestRedirectorView:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def storage
def view
def test_attempt_redirect_with_known_url
def test_attempt_redirect_with_known_url_and_template
def test_attempt_redirect_with_unknown_url
def test_find_first_parent_found_leaf
def test_find_first_parent_found_node
def test_find_first_parent_not_found
def test_search_leaf
def test_search_ignore_ids
def test_search_node
def test_search_blacklisted

Detailed Description

Ensure that the redirector view behaves as expected.

Definition at line 7 of file test_view.py.


Member Function Documentation

Definition at line 12 of file test_view.py.

00012 
00013     def storage(self):
00014         return getUtility(IRedirectionStorage)

Definition at line 20 of file test_view.py.

00020 
00021     def test_attempt_redirect_with_known_url(self):
00022         fp = '/'.join(self.folder.getPhysicalPath())
00023         fu = self.folder.absolute_url()
00024         self.storage.add(fp + '/foo', fp + '/bar')
00025         view = self.view(self.portal, fu + '/foo')
00026         self.assertEquals(True, view.attempt_redirect())
00027         self.assertEquals(301, self.app.REQUEST.response.getStatus())
00028         self.assertEquals(fu + '/bar', self.app.REQUEST.response.getHeader('location'))

Here is the call graph for this function:

Definition at line 29 of file test_view.py.

00029 
00030     def test_attempt_redirect_with_known_url_and_template(self):
00031         fp = '/'.join(self.folder.getPhysicalPath())
00032         fu = self.folder.absolute_url()
00033         self.storage.add(fp + '/foo', fp + '/bar')
00034         view = self.view(self.portal, fu + '/foo/view')
00035         self.assertEquals(True, view.attempt_redirect())
00036         self.assertEquals(301, self.app.REQUEST.response.getStatus())
00037         self.assertEquals(fu + '/bar/view', self.app.REQUEST.response.getHeader('location'))

Here is the call graph for this function:

Definition at line 38 of file test_view.py.

00038 
00039     def test_attempt_redirect_with_unknown_url(self):
00040         fp = '/'.join(self.folder.getPhysicalPath())
00041         fu = self.folder.absolute_url()
00042         view = self.view(self.portal, fu + '/foo')
00043         self.assertEquals(False, view.attempt_redirect())
00044         self.assertNotEquals(301, self.app.REQUEST.response.getStatus())

Here is the call graph for this function:

Definition at line 45 of file test_view.py.

00045 
00046     def test_find_first_parent_found_leaf(self):
00047         self.folder.invokeFactory('Folder', 'f1')
00048         fu = self.folder.absolute_url()
00049         view = self.view(self.portal, fu + '/f1/p1')
00050         obj = view.find_first_parent()
00051         self.assertEquals(fu + '/f1', obj.absolute_url())

Here is the call graph for this function:

Definition at line 52 of file test_view.py.

00052 
00053     def test_find_first_parent_found_node(self):
00054         self.folder.invokeFactory('Folder', 'f1')
00055         fu = self.folder.absolute_url()
00056         view = self.view(self.portal, fu + '/f1/p1/p2')
00057         obj = view.find_first_parent()
00058         self.assertEquals(fu + '/f1', obj.absolute_url())

Here is the call graph for this function:

Definition at line 59 of file test_view.py.

00059 
00060     def test_find_first_parent_not_found(self):
00061         view = self.view(self.portal, '/foo/f1/p1/p2')
00062         self.assertEquals(None, view.find_first_parent())

Here is the call graph for this function:

Definition at line 97 of file test_view.py.

00097 
00098     def test_search_blacklisted(self):
00099         self.folder.invokeFactory('Folder', 'f1')
00100         self.folder.invokeFactory('Folder', 'f2')
00101         self.folder.f1.invokeFactory('Document', 'p1')
00102         self.folder.f1.invokeFactory('Document', 'p2')
00103         fu = self.folder.absolute_url()
00104         self.portal.portal_properties.site_properties.types_not_searched = ['Document']
00105         view = self.view(self.portal, fu + '/f2/p1')
00106         urls = sorted([b.getURL() for b in view.search_for_similar()])
00107         self.assertEquals(1, len(urls))
00108         self.assertEquals(fu + '/f2', urls[0])

Here is the call graph for this function:

Definition at line 74 of file test_view.py.

00074 
00075     def test_search_ignore_ids(self):
00076         self.folder.invokeFactory('Folder', 'f1')
00077         self.folder.invokeFactory('Folder', 'f2')
00078         self.folder.f1.invokeFactory('Document', 'p1')
00079         self.folder.f1.invokeFactory('Document', 'p2')
00080         self.folder.f1.invokeFactory('Document', 'p3', title='view')
00081         fu = self.folder.absolute_url()
00082         view = self.view(self.portal, fu + '/f2/p1/view')
00083         urls = sorted([b.getURL() for b in view.search_for_similar()])
00084         self.assertEquals(1, len(urls))
00085         self.assertEquals(fu + '/f1/p1', urls[0])

Here is the call graph for this function:

Definition at line 63 of file test_view.py.

00063 
00064     def test_search_leaf(self):
00065         self.folder.invokeFactory('Folder', 'f1')
00066         self.folder.invokeFactory('Folder', 'f2')
00067         self.folder.f1.invokeFactory('Document', 'p1')
00068         self.folder.f1.invokeFactory('Document', 'p2')
00069         fu = self.folder.absolute_url()
00070         view = self.view(self.portal, fu + '/f2/p1')
00071         urls = sorted([b.getURL() for b in view.search_for_similar()])
00072         self.assertEquals(1, len(urls))
00073         self.assertEquals(fu + '/f1/p1', urls[0])

Here is the call graph for this function:

Definition at line 86 of file test_view.py.

00086 
00087     def test_search_node(self):
00088         self.folder.invokeFactory('Folder', 'f1')
00089         self.folder.invokeFactory('Folder', 'f2')
00090         self.folder.f1.invokeFactory('Document', 'p1')
00091         self.folder.f1.invokeFactory('Document', 'p2')
00092         fu = self.folder.absolute_url()
00093         view = self.view(self.portal, fu + '/f2/p1/f3')
00094         urls = sorted([b.getURL() for b in view.search_for_similar()])
00095         self.assertEquals(1, len(urls))
00096         self.assertEquals(fu + '/f1/p1', urls[0])

Here is the call graph for this function:

def plone.app.redirector.tests.test_view.TestRedirectorView.view (   self,
  context,
  actual_url 
)

Definition at line 15 of file test_view.py.

00015 
00016     def view(self, context, actual_url):
00017         request = self.app.REQUEST
00018         request['ACTUAL_URL'] = actual_url
00019         return getMultiAdapter((context, request), name='plone_redirector_view')

Here is the caller graph for this function:


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