Back to index

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

List of all members.

Public Member Functions

def afterSetUp
def testAutoGeneratedId
def testValidPortalTypeNameButNotAutoGeneratedId
def test_pretty_title_or_id_returns_title
def test_pretty_title_or_id_returns_id
def test_pretty_title_or_id_when_autogenerated
def test_pretty_title_or_id_works_with_method_that_needs_context
def test_pretty_title_or_id_on_catalog_brain
def test_pretty_title_or_id_on_catalog_brain_returns_id
def test_pretty_title_or_id_on_catalog_brain_autogenerated
def test_pretty_title_or_id_on_catalog_brain_no_title
def testGetMethodAliases
def setRequestMethod
def getAuthenticator
def setupAuthenticator

Public Attributes

 utils

Detailed Description

Tests the isIDAutoGenerated method and pretty_title_or_id

Definition at line 561 of file testPloneTool.py.


Member Function Documentation

Definition at line 565 of file testPloneTool.py.

00565 
00566     def afterSetUp(self):
00567         self.utils = self.portal.plone_utils

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 613 of file testPloneTool.py.

00613 
00614     def test_pretty_title_or_id_on_catalog_brain(self):
00615         cat = self.portal.portal_catalog
00616         self.setRoles(['Manager','Member'])
00617         self.folder.edit(title='My pretty title', subject='foobar')
00618         results = cat(Subject='foobar')
00619         self.assertEqual(len(results), 1)
00620         self.assertEqual(self.utils.pretty_title_or_id(results[0]),
00621                                                         'My pretty title')

Here is the call graph for this function:

Definition at line 631 of file testPloneTool.py.

00631 
00632     def test_pretty_title_or_id_on_catalog_brain_autogenerated(self):
00633         cat = self.portal.portal_catalog
00634         self.setRoles(['Manager','Member'])
00635         self.folder.edit(id='folder.2004-11-09.0123456789',
00636                          title='', subject='foobar')
00637         results = cat(Subject='foobar')
00638         self.assertEqual(len(results), 1)
00639         self.assertEqual(self.utils.pretty_title_or_id(results[0], 'Marker'),
00640                                                         'Marker')

Here is the call graph for this function:

Definition at line 641 of file testPloneTool.py.

00641 
00642     def test_pretty_title_or_id_on_catalog_brain_no_title(self):
00643         cat = self.portal.portal_catalog
00644         self.setRoles(['Manager','Member'])
00645         # Remove Title from catalog metadata to simulate a catalog with no
00646         # Title metadata and similar pathological cases.
00647         cat.delColumn('Title')
00648         self.folder.edit(title='',subject='foobar')
00649         results = cat(Subject='foobar')
00650         self.assertEqual(len(results), 1)
00651         # Give the portal a title because this is what will show up on
00652         # failure
00653         self.portal.title = 'This is not the title you are looking for'
00654         self.assertEqual(self.utils.pretty_title_or_id(results[0]),
00655                                                         self.folder.getId())

Here is the call graph for this function:

Definition at line 622 of file testPloneTool.py.

00622 
00623     def test_pretty_title_or_id_on_catalog_brain_returns_id(self):
00624         cat = self.portal.portal_catalog
00625         self.setRoles(['Manager','Member'])
00626         self.folder.edit(title='', subject='foobar')
00627         results = cat(Subject='foobar')
00628         self.assertEqual(len(results), 1)
00629         self.assertEqual(self.utils.pretty_title_or_id(results[0]),
00630                                                         self.folder.getId())

Here is the call graph for this function:

Definition at line 588 of file testPloneTool.py.

00588 
00589     def test_pretty_title_or_id_returns_id(self):
00590         self.folder.setTitle('')
00591         self.assertEqual(self.utils.pretty_title_or_id(self.folder),
00592                          self.folder.getId())

Here is the call graph for this function:

Definition at line 583 of file testPloneTool.py.

00583 
00584     def test_pretty_title_or_id_returns_title(self):
00585         self.folder.setTitle('My pretty title')
00586         self.assertEqual(self.utils.pretty_title_or_id(self.folder),
00587                          'My pretty title')

Here is the call graph for this function:

Definition at line 593 of file testPloneTool.py.

00593 
00594     def test_pretty_title_or_id_when_autogenerated(self):
00595         self.setRoles(['Manager','Member'])
00596         self.folder.setTitle('')
00597         self.folder.setId('folder.2004-11-09.0123456789')
00598         self.assertEqual(self.utils.pretty_title_or_id(self.folder),
00599                          self.utils.getEmptyTitle())
00600         self.assertEqual(self.utils.pretty_title_or_id(self.folder, 'Marker'),
00601                                 'Marker')

Here is the call graph for this function:

Definition at line 602 of file testPloneTool.py.

00602 
00603     def test_pretty_title_or_id_works_with_method_that_needs_context(self):
00604         self.setRoles(['Manager','Member'])
00605         # Create a dummy class that looks at it's context to find the title
00606         new_obj = DummyTitle()
00607         new_obj = new_obj.__of__(self.folder)
00608         try:
00609             title = self.utils.pretty_title_or_id(new_obj)
00610         except AttributeError, e:
00611             self.fail('pretty_title_or_id failed to include context %s'%e)
00612         self.assertEqual(title, 'portal_catalog')

Here is the call graph for this function:

Definition at line 568 of file testPloneTool.py.

00568 
00569     def testAutoGeneratedId(self):
00570         r = self.utils.isIDAutoGenerated('document.2004-11-09.0123456789')
00571         self.assertEqual(r, True)

Definition at line 656 of file testPloneTool.py.

00656 
00657     def testGetMethodAliases(self):
00658         fti = self.folder.getTypeInfo()
00659         expectedAliases = fti.getMethodAliases()
00660         aliases = self.utils.getMethodAliases(fti)
00661         self.assertEqual(len(expectedAliases), len(aliases))
00662         for k, v in aliases.items():
00663             self.assertEqual(expectedAliases[k], v)

Definition at line 572 of file testPloneTool.py.

00572 
00573     def testValidPortalTypeNameButNotAutoGeneratedId(self):
00574         # This was raising an IndexError exception for
00575         # Zope < 2.7.3 (DateTime.py < 1.85.12.11) and a
00576         # SyntaxError for Zope >= 2.7.3 (DateTime.py >= 1.85.12.11)
00577         r = self.utils.isIDAutoGenerated('document.tar.gz')
00578         self.assertEqual(r, False)
00579         r = self.utils.isIDAutoGenerated('document.tar.12/32/2004')
00580         self.assertEqual(r, False)
00581         r = self.utils.isIDAutoGenerated('document.tar.12/31/2004 12:62')
00582         self.assertEqual(r, False)


Member Data Documentation

Definition at line 566 of file testPloneTool.py.


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