Back to index

plone3  3.1.7
Public Member Functions | Public Attributes
kupu.plone.tests.test_links.TestLinkCode Class Reference
Inheritance diagram for kupu.plone.tests.test_links.TestLinkCode:
Inheritance graph
[legend]
Collaboration diagram for kupu.plone.tests.test_links.TestLinkCode:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_relative
def test_external
def test_localexternal
def test_abspath
def test_anchor
def test_redundant
def test_bad_portal_factory
def test_dot
def test_resolveuid
def test_resolveuidEmbedded
def test_badlink
def test_image
def test_image2
def afterSetUp
def loginPortalOwner
def create
def setup_content

Public Attributes

 kupu

Detailed Description

Test the link checking code

Definition at line 19 of file test_links.py.


Member Function Documentation

Definition at line 55 of file kuputestcase.py.

00055 
00056     def afterSetUp(self):
00057         portal = self.portal
00058         self.setRoles(['Manager',])
00059         self.kupu = portal.kupu_library_tool
00060         self.kupu.configure_kupu(captioning=True, linkbyuid=True)
00061         typestool = self.portal.portal_types
00062         if not hasattr(typestool, 'ATDocument'):
00063             # Use the type names without the AT prefix
00064             for k in TypeMapping:
00065                 TypeMapping[k] = k

Here is the call graph for this function:

def kupu.plone.tests.kuputestcase.KupuTestCase.create (   self,
  id,
  metatype = 'ATDocument',
  folder = None,
  kwds 
) [inherited]
Create an object in the cms portal

Definition at line 72 of file kuputestcase.py.

00072 
00073     def create(self, id, metatype='ATDocument', folder=None, **kwds):
00074         '''Create an object in the cms portal'''
00075         if folder is None:
00076             folder = self.portal
00077 
00078         folder.invokeFactory(MapType(metatype), id)
00079         obj = getattr(folder, id)
00080 
00081         if metatype=='Folder' and constraintypes:
00082             obj.setConstrainTypesMode(constraintypes.DISABLED)
00083 
00084         if metatype=='Document':
00085             obj.setTitle('Simple document')
00086             obj.setText('Sample document text')
00087             for k, v in kwds.items():
00088                 field = obj.getField(k)
00089                 mutator = field.getMutator(obj)(v)
00090 
00091             obj.reindexObject()
00092 
00093         assert obj is not None
00094         return obj

Here is the call graph for this function:

Here is the caller graph for this function:

Use if you need to manipulate the portal itself.

Definition at line 66 of file kuputestcase.py.

00066 
00067     def loginPortalOwner(self):
00068         '''Use if you need to manipulate the portal itself.'''
00069         uf = self.app.acl_users
00070         user = uf.getUserById(portal_owner).__of__(uf)
00071         newSecurityManager(None, user)

Here is the caller graph for this function:

Definition at line 95 of file kuputestcase.py.

00095 
00096     def setup_content(self):
00097         self.setRoles(['Manager',])
00098         self.loginPortalOwner()
00099         f = self.create('folder', 'Folder')
00100 
00101         for id in ('alpha', 'beta'):
00102             self.create(id, 'Document', f, subject=['aspidistra'])
00103         self.create('gamma', 'Image', f)
00104         gamma = f.gamma
00105         gamma.setImage(open(join(PREFIX,'image.jpg'),'rb').read())
00106         gamma.setTitle('Kupu Test Image')
00107         gamma.setDescription('Test image caption')
00108         # The image needs a fixed uid for the transform tests.
00109         f.gamma._setUID('104ede98d4c7c8eaeaa3b984f7395979')
00110 
00111         self.create('umlauts', 'Image', f)
00112         umlauts = f.umlauts
00113         umlauts.setImage(open(join(PREFIX,'image.jpg'),'rb').read())
00114         title, description = open(join(PREFIX, 'umlauts-testdata.txt')).read().strip().split(';')
00115         umlauts.setTitle(title)
00116         umlauts.setDescription(description)
00117         # The image needs a fixed uid for the transform tests.
00118         f.umlauts._setUID('215fef98e5d7c9ebebb4c984f7395979')
00119 
00120         f.reindexObject()
00121 
00122         sub1 = self.create('sub1', 'Folder', f)
00123         sub1.setSubject(['aspidistra'])
00124         sub1.reindexObject()
00125         sub2 = self.create('sub2', 'Folder', f)
00126         self.create('delta', 'Folder', sub2)
00127 
00128         portal = self.portal
00129         tool = self.portal.kupu_library_tool
00130         types = tool.zmi_get_resourcetypes()
00131         #tool.deleteResource([ t.name for t in types])
00132         for k,v in RESOURCES.items():
00133             tool.addResourceType(k, [MapType(t) for t in v])

Here is the caller graph for this function:

Definition at line 49 of file test_links.py.

00049 
00050     def test_abspath(self):
00051         self.setup_content()
00052         migrator = Migration(self.kupu)
00053         portal = self.portal
00054         base = portal.folder.alpha.absolute_url()
00055         path = '/plone/folder/beta'
00056         expected = ('internal', portal.folder.beta.UID(), 'beta', '')
00057         self.assertEquals(expected, migrator.classifyLink(path, base))

Here is the call graph for this function:

Definition at line 58 of file test_links.py.

00058 
00059     def test_anchor(self):
00060         self.setup_content()
00061         migrator = Migration(self.kupu)
00062         portal = self.portal
00063         base = portal.folder.alpha.absolute_url()
00064         path = '#fred'
00065         expected = ('internal', None, '', path)
00066         self.assertEquals(expected, migrator.classifyLink(path, base))

Here is the call graph for this function:

Definition at line 76 of file test_links.py.

00076 
00077     def test_bad_portal_factory(self):
00078         # Some version of kupu wrongly inserted jumplinks to
00079         # portal_factory. Check these get cleaned.
00080         self.setup_content()
00081         migrator = Migration(self.kupu)
00082         portal = self.portal
00083         base = portal.folder.alpha.absolute_url()
00084         path = 'portal_factory#fred'
00085         expected = ('internal', None, '', '#fred')
00086         self.assertEquals(expected, migrator.classifyLink(path, base))

Here is the call graph for this function:

Definition at line 114 of file test_links.py.

00114 
00115     def test_badlink(self):
00116         self.setup_content()
00117         migrator = Migration(self.kupu)
00118         portal = self.portal
00119         base = portal.folder.alpha.absolute_url()
00120         path = 'wibble'
00121         expected = ('bad', None, path, '')
00122         self.assertEquals(expected, migrator.classifyLink(path, base))

Here is the call graph for this function:

Definition at line 87 of file test_links.py.

00087 
00088     def test_dot(self):
00089         self.setup_content()
00090         migrator = Migration(self.kupu)
00091         portal = self.portal
00092         base = portal.folder.alpha.absolute_url()
00093         path = '.'
00094         expected = ('internal', portal.folder.UID(), path, '')
00095         self.assertEquals(expected, migrator.classifyLink(path, base))

Here is the call graph for this function:

Definition at line 31 of file test_links.py.

00031 
00032     def test_external(self):
00033         self.setup_content()
00034         migrator = Migration(self.kupu)
00035         portal = self.portal
00036         base = portal.folder.sub2.delta.absolute_url()
00037         path = 'mailto:me@nowhere'
00038         expected = ('external', None, path, '')
00039         self.assertEquals(expected, migrator.classifyLink(path, base))

Here is the call graph for this function:

Definition at line 123 of file test_links.py.

00123 
00124     def test_image(self):
00125         self.setup_content()
00126         migrator = Migration(self.kupu)
00127         migrator.initImageSizes()
00128         portal = self.portal
00129         base = portal.folder.alpha.absolute_url()
00130         path = 'gamma/image_thumb'
00131         expected = ('internal', portal.folder.gamma.UID(), 'gamma', '/image_thumb')
00132         self.assertEquals(expected, migrator.classifyLink(path, base))

Here is the call graph for this function:

Definition at line 133 of file test_links.py.

00133 
00134     def test_image2(self):
00135         self.setup_content()
00136         migrator = Migration(self.kupu)
00137         portal = self.portal
00138         base = portal.folder.alpha.absolute_url()
00139         path = 'resolveuid/'+portal.folder.gamma.UID()+'/image_icon'
00140         expected = ('internal', portal.folder.gamma.UID(), 'gamma', '/image_icon')
00141         self.assertEquals(expected, migrator.classifyLink(path, base))
00142 
        

Here is the call graph for this function:

Definition at line 40 of file test_links.py.

00040 
00041     def test_localexternal(self):
00042         self.setup_content()
00043         migrator = Migration(self.kupu)
00044         portal = self.portal
00045         base = portal.folder.sub2.delta.absolute_url()
00046         path = 'http://nohost/plone/folder/alpha'
00047         expected = ('internal', portal.folder.alpha.UID(), '../alpha', '')
00048         self.assertEquals(expected, migrator.classifyLink(path, base))

Here is the call graph for this function:

Definition at line 67 of file test_links.py.

00067 
00068     def test_redundant(self):
00069         self.setup_content()
00070         migrator = Migration(self.kupu)
00071         portal = self.portal
00072         base = portal.folder.alpha.absolute_url()
00073         path = 'alpha#fred'
00074         expected = ('internal', None, '', '#fred')
00075         self.assertEquals(expected, migrator.classifyLink(path, base))

Here is the call graph for this function:

Definition at line 22 of file test_links.py.

00022 
00023     def test_relative(self):
00024         self.setup_content()
00025         migrator = Migration(self.kupu)
00026         portal = self.portal
00027         base = portal.folder.sub2.delta.absolute_url()
00028         path = '../alpha'
00029         expected = ('internal', portal.folder.alpha.UID(), path, '')
00030         self.assertEquals(expected, migrator.classifyLink(path, base))

Here is the call graph for this function:

Definition at line 96 of file test_links.py.

00096 
00097     def test_resolveuid(self):
00098         self.setup_content()
00099         migrator = Migration(self.kupu)
00100         portal = self.portal
00101         base = portal.folder.alpha.absolute_url()
00102         path = 'resolveuid/' + portal.folder.beta.UID()
00103         expected = ('internal', portal.folder.beta.UID(), 'beta', '')
00104         self.assertEquals(expected, migrator.classifyLink(path, base))

Here is the call graph for this function:

Definition at line 105 of file test_links.py.

00105 
00106     def test_resolveuidEmbedded(self):
00107         self.setup_content()
00108         migrator = Migration(self.kupu)
00109         portal = self.portal
00110         base = portal.folder.alpha.absolute_url()
00111         path = 'wibble/resolveuid/' + portal.folder.beta.UID() + '#fragment'
00112         expected = ('internal', portal.folder.beta.UID(), 'beta', '#fragment')
00113         self.assertEquals(expected, migrator.classifyLink(path, base))

Here is the call graph for this function:


Member Data Documentation

Definition at line 58 of file kuputestcase.py.


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