Back to index

plone3  3.1.7
Public Member Functions | Public Attributes
CMFEditions.tests.test_ATContentTypes.TestATContents Class Reference

List of all members.

Public Member Functions

def afterSetUp
def set_metadata
def metadata_test
def getPermissionsOfRole
def testATDocument
def testNewsItem
def testImage
def testFile
def testFolder

Public Attributes

 membership
 catalog
 workflow
 portal_repository

Detailed Description

Definition at line 31 of file test_ATContentTypes.py.


Member Function Documentation

Definition at line 33 of file test_ATContentTypes.py.

00033 
00034     def afterSetUp(self):
00035         self.membership = self.portal.portal_membership
00036         self.catalog = self.portal.portal_catalog
00037         self.workflow = self.portal.portal_workflow
00038         self.portal_repository = self.portal.portal_repository

Definition at line 55 of file test_ATContentTypes.py.

00055 
00056     def getPermissionsOfRole(self, role):
00057         perms = self.portal.permissionsOfRole(role)
00058         return [p['name'] for p in perms if p['selected']]

Here is the caller graph for this function:

Definition at line 47 of file test_ATContentTypes.py.

00047 
00048     def metadata_test(self, obj, text):
00049         self.assertEqual(obj.Title(), text)
00050         self.assertEqual(obj.Subject(), (text,))
00051         self.assertEqual(obj.Description(), text)
00052         self.assertEqual(obj.Contributors(), (text,))
00053         self.assertEqual(obj.Language(), text)
00054         self.assertEqual(obj.Rights(), text)

Here is the caller graph for this function:

Definition at line 39 of file test_ATContentTypes.py.

00039 
00040     def set_metadata(self, obj, text):
00041         obj.setTitle(text)
00042         obj.setSubject(text)
00043         obj.setDescription(text)
00044         obj.setContributors(text)
00045         obj.setLanguage(text)
00046         obj.setRights(text)

Here is the caller graph for this function:

Definition at line 59 of file test_ATContentTypes.py.

00059 
00060     def testATDocument(self):
00061         self.folder.invokeFactory('Document', id='doc')
00062         portal_repository = self.portal_repository
00063         content = self.folder.doc
00064         content.setText('text v1')
00065         self.set_metadata(content, 'content')
00066         portal_repository.applyVersionControl(content, comment='save no 1')
00067         content.setText('text v2')
00068         self.set_metadata(content, 'contentOK')
00069         portal_repository.save(content, comment='save no 2')
00070         vdata = portal_repository.retrieve(content, 0)
00071         obj = vdata.object
00072         self.assertEqual(obj.getRawText(), 'text v1')
00073         self.metadata_test(obj, 'content')
00074         vdata = portal_repository.retrieve(content, 1)
00075         obj = vdata.object
00076         self.assertEqual(obj.getRawText(), 'text v2')
00077         self.metadata_test(obj, 'contentOK')
00078         portal_repository.revert(content, 0)
00079         self.assertEqual(content.getRawText(), 'text v1')
00080         self.metadata_test(content, 'content')

Here is the call graph for this function:

Definition at line 117 of file test_ATContentTypes.py.

00117 
00118     def testFile(self):
00119         self.folder.invokeFactory('File', id='file')
00120         file1 = open(os.path.join(PACKAGE_HOME, 'tests/images/img1.png'), 'rb').read()
00121         file2 = open(os.path.join(PACKAGE_HOME, 'tests/images/img2.png'), 'rb').read()
00122         portal_repository = self.portal_repository
00123         content = self.folder.file
00124         content.edit(file=file1)
00125         portal_repository.applyVersionControl(content, comment='save no 1')
00126         content.edit(file=file2)
00127         portal_repository.save(content, comment='save no 2')
00128         vdata = portal_repository.retrieve(content, 0)
00129         obj = vdata.object
00130         self.assertEqual(obj.data, file1)
00131         vdata = portal_repository.retrieve(content, 1)
00132         obj = vdata.object
00133         self.assertEqual(obj.data, file2)
00134         portal_repository.revert(content, 0)
00135         self.assertEqual(content.data, file1)

Definition at line 136 of file test_ATContentTypes.py.

00136 
00137     def testFolder(self):
00138         titleOne = 'folderOne'
00139         titleTwo = 'folderTwo'
00140         self.folder.invokeFactory('Folder', id='myfolder')
00141         portal_repository = self.portal_repository
00142         content = self.folder.myfolder
00143         content.setTitle(titleOne)
00144         portal_repository.applyVersionControl(content, comment='save no 0')
00145         content.setTitle(titleTwo)
00146         portal_repository.save(content, comment='save no 1')
00147         vdata = portal_repository.retrieve(content, 0)
00148         obj = vdata.object
00149         self.assertEqual(obj.Title(), titleOne)
00150         vdata = portal_repository.retrieve(content, 1)
00151         obj = vdata.object
00152         self.assertEqual(obj.Title(), titleTwo)
00153         portal_repository.revert(content, 0)
00154         self.assertEqual(content.Title(), titleOne)
00155 

Definition at line 98 of file test_ATContentTypes.py.

00098 
00099     def testImage(self):
00100         self.folder.invokeFactory('Image', id='image')
00101         img1 = open(os.path.join(PACKAGE_HOME, 'tests/images/img1.png'), 'rb').read()
00102         img2 = open(os.path.join(PACKAGE_HOME, 'tests/images/img2.png'), 'rb').read()
00103         portal_repository = self.portal_repository
00104         content = self.folder.image
00105         content.edit(file=img1)
00106         portal_repository.applyVersionControl(content, comment='save no 1')
00107         content.edit(file=img2)
00108         portal_repository.save(content, comment='save no 2')
00109         vdata = portal_repository.retrieve(content, 0)
00110         obj = vdata.object
00111         self.assertEqual(obj.data, img1)
00112         vdata = portal_repository.retrieve(content, 1)
00113         obj = vdata.object
00114         self.assertEqual(obj.data, img2)
00115         portal_repository.revert(content, 0)
00116         self.assertEqual(content.data, img1)

Definition at line 81 of file test_ATContentTypes.py.

00081 
00082     def testNewsItem(self):
00083         self.folder.invokeFactory('News Item', id='news_one')
00084         portal_repository = self.portal_repository
00085         content = self.folder.news_one
00086         content.text = 'text v1'
00087         portal_repository.applyVersionControl(content, comment='save no 1')
00088         content.text = 'text v2'
00089         portal_repository.save(content, comment='save no 2')
00090         vdata = portal_repository.retrieve(content, 0)
00091         obj = vdata.object
00092         self.assertEqual(obj.text, 'text v1')
00093         vdata = portal_repository.retrieve(content, 1)
00094         obj = vdata.object
00095         self.assertEqual(obj.text, 'text v2')
00096         portal_repository.revert(content, 0)
00097         self.assertEqual(content.text, 'text v1')


Member Data Documentation

Definition at line 35 of file test_ATContentTypes.py.

Definition at line 34 of file test_ATContentTypes.py.

Definition at line 37 of file test_ATContentTypes.py.

Definition at line 36 of file test_ATContentTypes.py.


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