Back to index

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

List of all members.

Public Member Functions

def afterSetUp
def getPermissionsOfRole
def testDiscussionReply
def testDocumentCreate
def testDocumentEdit
def testEventCreate
def testEventEdit
def testFavoriteCreate
def testFavoriteEdit
def testFileCreate
def testFileEdit
def testImageCreate
def testImageEdit
def testFolderCreate
def testFolderEdit
def testLinkCreate
def testLinkEdit
def testNewsItemCreate
def testNewsItemEdit
def testClearImageTitle
def testAddToFavorites
def test_listMetaTypes
def testObjectDeleteFailsOnGET
def testObjectDelete
def setRequestMethod
def getAuthenticator
def setupAuthenticator

Public Attributes

 discussion
 request

Detailed Description

Definition at line 19 of file testContentTypeScripts.py.


Member Function Documentation

Definition at line 21 of file testContentTypeScripts.py.

00021 
00022     def afterSetUp(self):
00023         perms = self.getPermissionsOfRole('Member')
00024         self.setPermissions(perms + [AddPortalTopics], 'Member')
00025         self.discussion = self.portal.portal_discussion
00026         self.request = self.app.REQUEST

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 27 of file testContentTypeScripts.py.

00027 
00028     def getPermissionsOfRole(self, role):
00029         perms = self.portal.permissionsOfRole(role)
00030         return [p['name'] for p in perms if p['selected']]

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 175 of file testContentTypeScripts.py.

00175 
00176     def test_listMetaTypes(self):
00177         self.folder.invokeFactory('Document', id='doc')
00178         tool = self.portal.plone_utils
00179         doc = self.folder.doc
00180         doc.setTitle('title')
00181         metatypes = tool.listMetaTags(doc)
00182         # TODO: atm it checks only of the script can be called w/o an error

Definition at line 156 of file testContentTypeScripts.py.

00156 
00157     def testAddToFavorites(self):
00158         # Ugh, addFavorite traverses to remote_url, so make sure it can.
00159         self.setRoles(['Manager'])
00160         self.portal.invokeFactory('Folder', id='bar')
00161         self.portal.bar.invokeFactory('Document', id='baz.html')
00162         self.setRoles(['Member'])
00163         # back to normal
00164         self.failIf('Favorites' in self.folder.objectIds())
00165         self.portal.bar['baz.html'].addtoFavorites()
00166         self.failUnless('Favorites' in self.folder.objectIds())
00167         favorite = self.folder.Favorites.objectValues()[0]
00168         self.assertEqual(favorite.getRemoteUrl(),
00169                          '%s/bar/baz.html' % self.portal.portal_url())
00170         # Make sure the script created AT types
00171         self.assertEqual(self.folder.Favorites.meta_type, 'ATFolder')
00172         self.assertEqual(favorite.meta_type, 'ATFavorite')
00173         # Make sure that the script gave a Title to the folder
00174         self.assertEqual(self.folder.Favorites.Title(), 'Favorites')

Here is the call graph for this function:

Definition at line 148 of file testContentTypeScripts.py.

00148 
00149     def testClearImageTitle(self):
00150         # Test for http://dev.plone.org/plone/ticket/3303
00151         # Should be able to clear Image title
00152         self.folder.invokeFactory('Image', id='image', title='Foo', file=dummy.Image())
00153         self.assertEqual(self.folder.image.Title(), 'Foo')
00154         self.folder.image.image_edit(title='')
00155         self.assertEqual(self.folder.image.Title(), '')

Definition at line 31 of file testContentTypeScripts.py.

00031 
00032     def testDiscussionReply(self):
00033         self.folder.invokeFactory('Document', id='doc')
00034         # Create the talkback object
00035         self.discussion.overrideDiscussionFor(self.folder.doc, 1)
00036         self.discussion.getDiscussionFor(self.folder.doc)
00037         # Now test it
00038         self.folder.doc.discussion_reply('Foo', 'blah')
00039         talkback = self.discussion.getDiscussionFor(self.folder.doc)
00040         reply = talkback.objectValues()[0]
00041         self.assertEqual(reply.Title(), 'Foo')
00042         self.assertEqual(reply.EditableBody(), 'blah')

Definition at line 43 of file testContentTypeScripts.py.

00043 
00044     def testDocumentCreate(self):
00045         self.folder.invokeFactory('Document', id='doc', text='data')
00046         self.assertEqual(self.folder.doc.EditableBody(), 'data')
00047         self.assertEqual(self.folder.doc.Format(), 'text/plain')

Definition at line 48 of file testContentTypeScripts.py.

00048 
00049     def testDocumentEdit(self):
00050         self.folder.invokeFactory('Document', id='doc')
00051         self.folder.doc.document_edit('html', 'data', title='Foo')
00052         self.assertEqual(self.folder.doc.EditableBody(), 'data')
00053         self.assertEqual(self.folder.doc.Format(), 'text/html')
00054         self.assertEqual(self.folder.doc.Title(), 'Foo')

Definition at line 55 of file testContentTypeScripts.py.

00055 
00056     def testEventCreate(self):
00057         self.folder.invokeFactory('Event', id='event',
00058                                   title = 'Foo',
00059                                   start_date='2003-09-18',
00060                                   end_date='2003-09-19')
00061         self.assertEqual(self.folder.event.Title(), 'Foo')
00062         self.assertEqual(self.folder.event.start().ISO(), '2003-09-18 00:00:00')
00063         self.assertEqual(self.folder.event.end().ISO(), '2003-09-19 00:00:00')

Definition at line 64 of file testContentTypeScripts.py.

00064 
00065     def testEventEdit(self):
00066         self.folder.invokeFactory('Event', id='event')
00067         self.folder.event.event_edit(title='Foo',
00068                                      start_date='2003-09-18',
00069                                      end_date='2003-09-19')
00070         self.assertEqual(self.folder.event.Title(), 'Foo')
00071         self.assertEqual(self.folder.event.start().ISO(), '2003-09-18 00:00:00')
00072         self.assertEqual(self.folder.event.end().ISO(), '2003-09-19 00:00:00')

Definition at line 73 of file testContentTypeScripts.py.

00073 
00074     def testFavoriteCreate(self):
00075         # Ugh, addFavorite traverses to remote_url, so make sure it can.
00076         self.setRoles(['Manager'])
00077         self.portal.invokeFactory('Folder', id='bar')
00078         self.portal.bar.invokeFactory('Document', id='baz.html')
00079         self.setRoles(['Member'])
00080         # back to normal
00081         self.folder.invokeFactory('Favorite', id='favorite',
00082                                   remote_url='bar/baz.html',
00083                                   title='Foo')
00084         self.assertEqual(self.folder.favorite.getRemoteUrl(),
00085                          '%s/bar/baz.html' % self.portal.portal_url())
00086         self.assertEqual(self.folder.favorite.Title(), 'Foo')

Here is the call graph for this function:

Definition at line 87 of file testContentTypeScripts.py.

00087 
00088     def testFavoriteEdit(self):
00089         # Note: link_edit does not traverse to remote_url
00090         self.folder.invokeFactory('Favorite', id='favorite')
00091         self.folder.favorite.link_edit('bar/baz.html', title='Foo')
00092         self.assertEqual(self.folder.favorite.getRemoteUrl(),
00093                          '%s/bar/baz.html' % self.portal.portal_url())
00094         self.assertEqual(self.folder.favorite.Title(), 'Foo')

Definition at line 95 of file testContentTypeScripts.py.

00095 
00096     def testFileCreate(self):
00097         self.folder.invokeFactory('File', id='file', file=dummy.File())
00098         self.assertEqual(str(self.folder.file), dummy.TEXT)

Definition at line 99 of file testContentTypeScripts.py.

00099 
00100     def testFileEdit(self):
00101         self.folder.invokeFactory('File', id='file')
00102         self.folder.file.file_edit(file=dummy.File())
00103         self.assertEqual(str(self.folder.file), dummy.TEXT)

Definition at line 113 of file testContentTypeScripts.py.

00113 
00114     def testFolderCreate(self):
00115         self.folder.invokeFactory('Folder', id='folder', title='Foo', description='Bar')
00116         self.assertEqual(self.folder.folder.Title(), 'Foo')
00117         self.assertEqual(self.folder.folder.Description(), 'Bar')

Definition at line 118 of file testContentTypeScripts.py.

00118 
00119     def testFolderEdit(self):
00120         self.folder.invokeFactory('Folder', id='folder')
00121         self.folder.folder.folder_edit('Foo', 'Bar')
00122         self.assertEqual(self.folder.folder.Title(), 'Foo')
00123         self.assertEqual(self.folder.folder.Description(), 'Bar')

Definition at line 104 of file testContentTypeScripts.py.

00104 
00105     def testImageCreate(self):
00106         self.folder.invokeFactory('Image', id='image', file=dummy.Image())
00107         self.assertEqual(str(self.folder.image.data), dummy.GIF)

Definition at line 108 of file testContentTypeScripts.py.

00108 
00109     def testImageEdit(self):
00110         self.folder.invokeFactory('Image', id='image')
00111         self.folder.image.image_edit(file=dummy.Image())
00112         self.assertEqual(str(self.folder.image.data), dummy.GIF)

Definition at line 124 of file testContentTypeScripts.py.

00124 
00125     def testLinkCreate(self):
00126         self.folder.invokeFactory('Link', id='link', remote_url='http://foo.com', title='Foo')
00127         self.assertEqual(self.folder.link.Title(), 'Foo')
00128         self.assertEqual(self.folder.link.getRemoteUrl(), 'http://foo.com')

Definition at line 129 of file testContentTypeScripts.py.

00129 
00130     def testLinkEdit(self):
00131         self.folder.invokeFactory('Link', id='link')
00132         self.folder.link.link_edit('http://foo.com', title='Foo')
00133         self.assertEqual(self.folder.link.Title(), 'Foo')
00134         self.assertEqual(self.folder.link.getRemoteUrl(), 'http://foo.com')

Definition at line 135 of file testContentTypeScripts.py.

00135 
00136     def testNewsItemCreate(self):
00137         self.folder.invokeFactory('News Item', id='newsitem', text='data', title='Foo')
00138         self.assertEqual(self.folder.newsitem.EditableBody(), 'data')
00139         self.assertEqual(self.folder.newsitem.Title(), 'Foo')

Definition at line 140 of file testContentTypeScripts.py.

00140 
00141     def testNewsItemEdit(self):
00142         self.folder.invokeFactory('News Item', id='newsitem')
00143         self.folder.newsitem.newsitem_edit('data', 'plain', title='Foo')
00144         self.assertEqual(self.folder.newsitem.EditableBody(), 'data')
00145         self.assertEqual(self.folder.newsitem.Title(), 'Foo')

Definition at line 186 of file testContentTypeScripts.py.

00186 
00187     def testObjectDelete(self):
00188         self.folder.invokeFactory('Document', id='doc')
00189         self.setupAuthenticator()
00190         self.setRequestMethod('POST')
00191         self.folder.doc.object_delete()
00192         self.failIf('doc' in self.folder.objectIds())
00193 

Here is the call graph for this function:

Definition at line 183 of file testContentTypeScripts.py.

00183 
00184     def testObjectDeleteFailsOnGET(self):
00185         self.assertRaises(Unauthorized, self.folder.object_delete,)


Member Data Documentation

Definition at line 24 of file testContentTypeScripts.py.

Definition at line 25 of file testContentTypeScripts.py.


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