Back to index

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

List of all members.

Public Member Functions

def afterSetUp
def set_metadata
def metadata_test
def getPermissionsOfRole
def setFAQ
def verifyFAQ
def testFAQ
def setQuestion
def verifyQuestion
def testFAQWithContent
def createImage
def testContentWithReferences

Public Attributes

 membership
 catalog
 workflow
 portal_repository
 portal_archivist

Detailed Description

Definition at line 16 of file test_FAQ.py.


Member Function Documentation

Definition at line 18 of file test_FAQ.py.

00018 
00019     def afterSetUp(self):
00020         self.membership = self.portal.portal_membership
00021         self.catalog = self.portal.portal_catalog
00022         self.workflow = self.portal.portal_workflow
00023         self.portal_repository = self.portal.portal_repository
00024         self.portal_archivist = self.portal.portal_archivist
00025         self.folder.manage_permission('Add FAQ content', ['Member', 'Manager'])

def CMFEditions.tests.test_FAQ.TestATContents.createImage (   self,
  id = 'image' 
)

Definition at line 125 of file test_FAQ.py.

00125 
00126     def createImage(self, id='image'):
00127         self.folder.invokeFactory('Image', id=id)
00128         img1 = open(os.path.join(PACKAGE_HOME, 'tests/images/img1.png'), 'rb').read()
00129         portal_repository = self.portal_repository
00130         portal_archivist = self.portal_archivist
00131         content = getattr(self.folder, id)
00132         content.edit(file=img1)
00133         return content

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 42 of file test_FAQ.py.

00042 
00043     def getPermissionsOfRole(self, role):
00044         perms = self.portal.permissionsOfRole(role)
00045         return [p['name'] for p in perms if p['selected']]

Here is the caller graph for this function:

def CMFEditions.tests.test_FAQ.TestATContents.metadata_test (   self,
  obj,
  text 
)

Definition at line 34 of file test_FAQ.py.

00034 
00035     def metadata_test(self, obj, text):
00036         self.assertEqual(obj.Title(), text + ' title')
00037         self.assertEqual(obj.Subject(), (text + ' subject',))
00038         self.assertEqual(obj.Description(), text + ' description')
00039         self.assertEqual(obj.Contributors(), (text + ' contributors',))
00040         self.assertEqual(obj.Language(), text + ' language')
00041         self.assertEqual(obj.Rights(), text + ' rights')

Here is the caller graph for this function:

def CMFEditions.tests.test_FAQ.TestATContents.set_metadata (   self,
  obj,
  text 
)

Definition at line 26 of file test_FAQ.py.

00026 
00027     def set_metadata(self, obj, text):
00028         obj.setTitle(text + ' title')
00029         obj.setSubject(text + ' subject')
00030         obj.setDescription(text + ' description')
00031         obj.setContributors(text + ' contributors')
00032         obj.setLanguage(text + ' language')
00033         obj.setRights(text + ' rights')

Here is the caller graph for this function:

def CMFEditions.tests.test_FAQ.TestATContents.setFAQ (   self,
  content,
  tag 
)

Definition at line 46 of file test_FAQ.py.

00046 
00047     def setFAQ(self, content, tag):
00048         content.setSummary('summary '+tag)
00049         content.setIntroduction('intro '+tag)
00050         content.setSections(('sections '+tag+' 1', 'sections '+tag+' 2'))
00051         self.set_metadata(content, 'content '+tag)

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFEditions.tests.test_FAQ.TestATContents.setQuestion (   self,
  question,
  tag 
)

Definition at line 75 of file test_FAQ.py.

00075 
00076     def setQuestion(self, question, tag):
00077         question.setSection('section '+tag)
00078         question.setTitle('title '+tag)
00079         question.setAnswer('answer '+tag)

Here is the caller graph for this function:

Definition at line 134 of file test_FAQ.py.

00134 
00135     def testContentWithReferences(self):
00136         self.folder.invokeFactory('FAQ', id='test_faq')
00137         image = self.createImage()
00138         image2 = self.createImage(id='image2')
00139         portal_repository = self.portal_repository
00140         faq = self.folder.test_faq
00141         self.setFAQ(faq, 'v1')
00142         portal_repository.save(faq, comment='save no links')
00143         faq.setLinks([image.UID()])
00144         portal_repository.save(faq, comment='save with link')
00145         faq.setLinks([image2.UID()])
00146         portal_repository.save(faq, comment='save with other link')
00147         bothLinks = [image2.UID(), image.UID()]
00148         bothLinks.sort()
00149         faq.setLinks(bothLinks)
00150         portal_repository.save(faq, comment='save with other link')
00151         self.assertEquals(2, len(faq.getRawLinks()))
00152 #         print "Link stuff", faq.getLinks()
00153 #         print "Raw Link stuff", faq.getRawLinks()
00154 
00155         expected = [ (0, []),
00156             (1, [image.UID()]),
00157             (2, [image2.UID()]),
00158             (3, bothLinks)
00159             ]
00160 
00161         for version, explinks in expected:
00162             portal_repository.revert(faq, version)
00163 
00164             # Reverting reverts back the references
00165             links = faq.getRawLinks()
00166             links.sort()
00167 
00168             folderLinks = [ ref.targetUID for ref in faq.at_references.objectValues()]
00169             folderLinks.sort()
00170 
00171 #             print "folderlinks", folderLinks
00172 #             print "Link stuff", faq.getLinks()
00173 #             print "Raw Link stuff", faq.getRawLinks()
00174 
00175             # XXX This assertion checks that the reference engine has
00176             # not been corrupted, but currently it fails.
00177             # XXX
00178             self.assertEquals(folderLinks, links,
00179                  "Version %d: links on object do not match reference catalog\nfolder %r, links %r" % (version, explinks, links))
00180             
00181             explinks.sort()
00182             self.assertEquals(explinks, folderLinks,
00183                 "Version %d, expected %r, actual %r" % (version, explinks, folderLinks))

Here is the call graph for this function:

Definition at line 58 of file test_FAQ.py.

00058 
00059     def testFAQ(self):
00060         self.folder.invokeFactory('FAQ', id='test_faq')
00061         portal_repository = self.portal_repository
00062         content = self.folder.test_faq
00063         self.setFAQ(content, 'v1')
00064         portal_repository.applyVersionControl(content, comment='save no 1')
00065         self.setFAQ(content, 'v2')
00066         portal_repository.save(content, comment='save no 2')
00067         vdata = portal_repository.retrieve(content, 0)
00068         obj = vdata.object
00069         self.verifyFAQ(obj, 'v1')
00070         vdata = portal_repository.retrieve(content, 1)
00071         obj = vdata.object
00072         self.verifyFAQ(obj, 'v2')
00073         portal_repository.revert(content, 0)
00074         self.verifyFAQ(content, 'v1')

Here is the call graph for this function:

Definition at line 85 of file test_FAQ.py.

00085 
00086     def testFAQWithContent(self):
00087         self.folder.invokeFactory('FAQ', id='test_faq')
00088         portal_repository = self.portal_repository
00089         faq = self.folder.test_faq
00090         self.setFAQ(faq, 'v1')
00091         for id in ('q1', 'q2'):
00092             faq.invokeFactory('FAQQuestion', id=id)
00093             question = getattr(faq, id)
00094             self.setQuestion(question, id+' v1')
00095 
00096         portal_repository.applyVersionControl(faq, comment='save no 1')
00097         self.setFAQ(faq, 'v2')
00098         for id in ('q1', 'q2'):
00099             question = getattr(faq, id)
00100             self.setQuestion(question, id+' v2')
00101         portal_repository.save(faq, comment='save no 2')
00102 
00103         vdata = portal_repository.retrieve(faq, 0)
00104         obj = vdata.object
00105         self.verifyFAQ(obj, 'v1')
00106         for id in ('q1', 'q2'):
00107             question = getattr(obj, id)
00108             self.verifyQuestion(question, id+' v1')
00109 
00110         vdata = portal_repository.retrieve(faq, 1)
00111         obj = vdata.object
00112         self.verifyFAQ(obj, 'v2')
00113         for id in ('q1', 'q2'):
00114             question = getattr(obj, id)
00115             self.verifyQuestion(question, id+' v2')
00116 
00117         for id in ('q1', 'q2'):
00118             question = getattr(faq, id)
00119             self.verifyQuestion(question, id+' v2')
00120         portal_repository.revert(faq, 0)
00121         self.verifyFAQ(faq, 'v1')
00122         for id in ('q1', 'q2'):
00123             question = getattr(faq, id)
00124             self.verifyQuestion(question, id+' v1')

Here is the call graph for this function:

def CMFEditions.tests.test_FAQ.TestATContents.verifyFAQ (   self,
  content,
  tag 
)

Definition at line 52 of file test_FAQ.py.

00052 
00053     def verifyFAQ(self, content, tag):
00054         self.assertEqual(content.getSummary(), 'summary '+tag)
00055         self.assertEqual(content.getIntroduction(), 'intro '+tag)
00056         self.assertEqual(content.getSections(), ('sections '+tag+' 1', 'sections '+tag+' 2'))
00057         self.metadata_test(content, 'content '+tag)
        

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFEditions.tests.test_FAQ.TestATContents.verifyQuestion (   self,
  question,
  tag 
)

Definition at line 80 of file test_FAQ.py.

00080 
00081     def verifyQuestion(self, question, tag):
00082         self.assertEqual(question.getSection(), 'section '+tag)
00083         self.assertEqual(question.getTitle(), 'title '+tag)
00084         self.assertEqual(question.getAnswer(), 'answer '+tag)

Here is the caller graph for this function:


Member Data Documentation

Definition at line 20 of file test_FAQ.py.

Definition at line 19 of file test_FAQ.py.

Definition at line 23 of file test_FAQ.py.

Definition at line 22 of file test_FAQ.py.

Definition at line 21 of file test_FAQ.py.


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