Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes
ATContentTypes.tests.test_atdocument.TestSiteATDocument Class Reference
Inheritance diagram for ATContentTypes.tests.test_atdocument.TestSiteATDocument:
Inheritance graph
[legend]
Collaboration diagram for ATContentTypes.tests.test_atdocument.TestSiteATDocument:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_doesImplementHistoryAware
def test_doesImplementZ3HistoryAware
def test_implementsTextContent
def test_implementsZ3TextContent
def test_implementsATDocument
def test_implementsZ3ATDocument
def test_edit
def test_cmf_edit_failure
def test_rename_keeps_contenttype
def test_x_safe_html
def test_get_size
def test_tidy_validator_with_upload_wrong_encoding
def afterSetUp
def test_000testsetup
def test_dcEdit
def test_typeInfo
def test_doesImplementDC
def test_doesImplementATCT
def test_doesImplementZ3ATCT
def test_doesImplementAT
def test_implementsTranslateable
def test_not_implements_ITemplateMixin
def test_implements_ISelectableBrowserDefault
def compareDC
def test_idValidation
def test_getobjpositioninparent
def test_schema_marshall
def beforeTearDown

Static Public Attributes

 klass = ATDocument
string portal_type = 'Document'
string title = 'Page'
string meta_type = 'ATDocument'
string icon = 'document_icon.gif'
 cmf_klass = None
string cmf_portal_type = ''

Detailed Description

Definition at line 79 of file test_atdocument.py.


Member Function Documentation

Reimplemented in ATContentTypes.tests.test_attopic.TestSiteATTopic.

Definition at line 89 of file atcttestcase.py.

00089 
00090     def afterSetUp(self):
00091         #self.setRoles(['Manager', 'Member'])
00092         self._ATCT = self._createType(self.folder, self.portal_type, 'ATCT')
00093         if self.cmf_klass:
00094             self._cmf = self._createType(self.folder, self.cmf_portal_type, 'cmf')

Definition at line 231 of file atcttestcase.py.

00231 
00232     def beforeTearDown(self):
00233         self.logout()

Here is the call graph for this function:

def ATContentTypes.tests.atcttestcase.ATCTTypeTestCase.compareDC (   self,
  first,
  second = None,
  kwargs 
) [inherited]

Definition at line 181 of file atcttestcase.py.

00181 
00182     def compareDC(self, first, second=None, **kwargs):
00183         """
00184         """
00185         if second != None:
00186             title = second.Title()
00187             description = second.Description()
00188         else:
00189             title = kwargs.get('title')
00190             description = kwargs.get('description')
00191 
00192         self.failUnlessEqual(first.Title(), title)
00193         self.failUnlessEqual(first.Description(), description)

Here is the caller graph for this function:

Definition at line 107 of file atcttestcase.py.

00107 
00108     def test_000testsetup(self):
00109         # test if we really have the right test setup
00110         # vars
00111         self.failUnless(self.klass)
00112         self.failUnless(self.portal_type)
00113         self.failUnless(self.title)
00114         self.failUnless(self.meta_type)
00115         self.failUnless(self.icon)
00116         if self.cmf_klass:
00117             self.failUnless(self.cmf_klass)
00118             self.failUnless(self.cmf_portal_type)
00119 
00120         # portal types
00121         self.failUnlessEqual(self._ATCT.portal_type, self.portal_type)
00122         if self.cmf_klass:
00123             self.failUnlessEqual(self._cmf.portal_type, self.cmf_portal_type)
00124 
00125         # classes
00126         atct_class = self._ATCT.__class__
00127         self.failUnlessEqual(self.klass, atct_class)
00128         if self.cmf_klass:
00129             cmf_class = self._cmf.__class__
00130             self.failUnlessEqual(self.cmf_klass, cmf_class)

Definition at line 118 of file test_atdocument.py.

00118 
00119     def test_cmf_edit_failure(self):
00120         self._ATCT.edit(thisisnotcmfandshouldbeignored=1)

Reimplemented in ATContentTypes.tests.test_atimage.TestSiteATImage.

Definition at line 131 of file atcttestcase.py.

00131 
00132     def test_dcEdit(self):
00133         new = self._ATCT
00134         dcEdit(new)
00135         if self.cmf_klass:
00136             old = self._cmf
00137             dcEdit(old)
00138             self.compareDC(old, new)

Here is the call graph for this function:

Definition at line 160 of file atcttestcase.py.

00160 
00161     def test_doesImplementAT(self):
00162         self.failUnless(IBaseContent.isImplementedBy(self._ATCT))
00163         self.failUnless(IReferenceable.isImplementedBy(self._ATCT))
00164         self.failUnless(verifyObject(IBaseContent, self._ATCT))
00165         self.failUnless(verifyObject(IReferenceable, self._ATCT))

Definition at line 152 of file atcttestcase.py.

00152 
00153     def test_doesImplementATCT(self):
00154         self.failUnless(IATContentType.isImplementedBy(self._ATCT))
00155         self.failUnless(verifyObject(IATContentType, self._ATCT))

Definition at line 146 of file atcttestcase.py.

00146 
00147     def test_doesImplementDC(self):
00148         self.failUnless(IDublinCore.isImplementedBy(self._ATCT))
00149         self.failUnless(IMutableDublinCore.isImplementedBy(self._ATCT))
00150         self.failUnless(verifyObject(IDublinCore, self._ATCT))
00151         self.failUnless(verifyObject(IMutableDublinCore, self._ATCT))

Definition at line 87 of file test_atdocument.py.

00087 
00088     def test_doesImplementHistoryAware(self):
00089         iface = IHistoryAware
00090         self.failUnless(iface.isImplementedBy(self._ATCT))
00091         self.failUnless(verifyObject(iface, self._ATCT))

Definition at line 156 of file atcttestcase.py.

00156 
00157     def test_doesImplementZ3ATCT(self):
00158         iface = Z3IATContentType
00159         self.failUnless(Z3verifyObject(iface, self._ATCT))

Definition at line 92 of file test_atdocument.py.

00092 
00093     def test_doesImplementZ3HistoryAware(self):
00094         iface = Z3IHistoryAware
00095         self.failUnless(Z3verifyObject(iface, self._ATCT))

Definition at line 114 of file test_atdocument.py.

00114 
00115     def test_edit(self):
00116         new = self._ATCT
00117         editATCT(new)

Here is the call graph for this function:

Definition at line 159 of file test_atdocument.py.

00159 
00160     def test_get_size(self):
00161         atct = self._ATCT
00162         editATCT(atct)
00163         self.failUnlessEqual(atct.get_size(), len(example_stx))

Here is the call graph for this function:

Definition at line 215 of file atcttestcase.py.

00215 
00216     def test_getobjpositioninparent(self):
00217         # TODO: not a real test
00218         self._ATCT.getObjPositionInParent()

Definition at line 194 of file atcttestcase.py.

00194 
00195     def test_idValidation(self):
00196         self.setRoles(['Manager', 'Member']) # for ATTopic
00197         asdf = self._createType(self.folder, self.portal_type, 'asdf')
00198         asdf2 = self._createType(self.folder, self.portal_type, 'asdf2')
00199         self.setRoles(['Member'])
00200 
00201         request = FakeRequestSession()
00202 
00203         # invalid ids
00204         ids = ['asdf2', '???', '/asdf2', ' asdf2', 'portal_workflow',
00205             'portal_url']
00206         for id in ids:
00207             request.form = {'id':id, 'fieldset':'default'}
00208             self.assertNotEquals(asdf.validate(REQUEST=request), {}, "Not catched id: %s" % id)
00209 
00210         # valid ids
00211         ids = ['', 'abcd', 'blafasel']
00212         for id in ids:
00213             request.form = {'id':id}
00214             self.assertEquals(asdf.validate(REQUEST=request), {})

Here is the call graph for this function:

Definition at line 176 of file atcttestcase.py.

00176 
00177     def test_implements_ISelectableBrowserDefault(self):
00178         iface = ISelectableBrowserDefault
00179         self.failUnless(iface.providedBy(self._ATCT))
00180         self.failUnless(Z3verifyObject(iface, self._ATCT))

Definition at line 105 of file test_atdocument.py.

00105 
00106     def test_implementsATDocument(self):
00107         iface = IATDocument
00108         self.failUnless(iface.isImplementedBy(self._ATCT))
00109         self.failUnless(verifyObject(iface, self._ATCT))

Definition at line 96 of file test_atdocument.py.

00096 
00097     def test_implementsTextContent(self):
00098         iface = ITextContent
00099         self.failUnless(iface.isImplementedBy(self._ATCT))
00100         self.failUnless(verifyObject(iface, self._ATCT))

Definition at line 166 of file atcttestcase.py.

00166 
00167     def test_implementsTranslateable(self):
00168         # lingua plone is adding the ITranslatable interface to all types
00169         if not HAS_LINGUA_PLONE:
00170             return
00171         self.failUnless(ITranslatable.isImplementedBy(self._ATCT))
00172         self.failUnless(verifyObject(ITranslatable, self._ATCT))

Definition at line 110 of file test_atdocument.py.

00110 
00111     def test_implementsZ3ATDocument(self):
00112         iface = Z3IATDocument
00113         self.failUnless(Z3verifyObject(iface, self._ATCT))

Definition at line 101 of file test_atdocument.py.

00101 
00102     def test_implementsZ3TextContent(self):
00103         iface = Z3TextContent
00104         self.failUnless(Z3verifyObject(iface, self._ATCT))

Definition at line 173 of file atcttestcase.py.

00173 
00174     def test_not_implements_ITemplateMixin(self):
00175         self.failIf(ITemplateMixin.isImplementedBy(self._ATCT))

Definition at line 121 of file test_atdocument.py.

00121 
00122     def test_rename_keeps_contenttype(self):
00123         doc = self._ATCT
00124         doc.setText(example_rest, mimetype="text/x-rst")
00125         self.failUnless(str(doc.getField('text').getContentType(doc)) == "text/x-rst")
00126         #make sure we have _p_jar
00127         transaction.savepoint(optimistic=True)
00128 
00129         cur_id = 'ATCT'
00130         new_id = 'WasATCT'
00131         self.folder.manage_renameObject(cur_id, new_id)
00132         doc = getattr(self.folder, new_id)
00133         field = doc.getField('text')
00134         self.failUnless(str(field.getContentType(doc)) == "text/x-rst")

Here is the call graph for this function:

Reimplemented in ATContentTypes.tests.test_attopic.TestSiteATTopic, ATContentTypes.tests.test_atimage.TestSiteATImage, ATContentTypes.tests.test_atfolder.TestSiteATBTreeFolder, ATContentTypes.tests.test_atfolder.TestSiteATFolder, and ATContentTypes.tests.test_atfile.TestSiteATFile.

Definition at line 219 of file atcttestcase.py.

00219 
00220     def test_schema_marshall(self):
00221         atct = self._ATCT
00222         schema = atct.Schema()
00223         marshall = schema.getLayerImpl('marshall')
00224         marshallers = [RFC822Marshaller]
00225         try:
00226             from Products.Marshall import ControlledMarshaller
00227             marshallers.append(ControlledMarshaller)
00228         except ImportError:
00229             pass
00230         self.failUnless(isinstance(marshall, tuple(marshallers)), marshall)

Definition at line 167 of file test_atdocument.py.

00167 
00168         def test_tidy_validator_with_upload_wrong_encoding(self): 
00169             doc = self._ATCT
00170     
00171             field = doc.getField('text')
00172             request = self.app.REQUEST
00173             setattr(request, 'text_text_format', 'text/html')
00174             input_file_name = 'tidy1-in.html'
00175             in_file = open(input_file_path(input_file_name))
00176             env = {'REQUEST_METHOD':'PUT'}
00177             headers = {'content-type':'text/html',
00178                        'content-length': len(in_file.read()),
00179                        'content-disposition':'attachment; filename=%s' % input_file_name}
00180             in_file.seek(0)
00181             fs = FieldStorage(fp=in_file, environ=env, headers=headers)
00182             f = FileUpload(fs)
00183     
00184             tcv = TidyHtmlWithCleanupValidator('tidy_validator_with_cleanup')
00185             result = tcv.__call__(f, field=field, REQUEST=request)
00186     
00187             self.assertEquals(result, 1)
00188     
00189             expected_file = open(input_file_path('tidy1-out.html'))
00190             expected = expected_file.read()
00191             expected_file.close()
00192             self.assertEquals(request['text_tidier_data'], expected)
00193         
00194 tests.append(TestSiteATDocument)

Here is the call graph for this function:

Definition at line 139 of file atcttestcase.py.

00139 
00140     def test_typeInfo(self):
00141         ti = self._ATCT.getTypeInfo()
00142         self.failUnlessEqual(ti.getId(), self.portal_type)
00143         self.failUnlessEqual(ti.Title(), self.title)
00144         self.failUnlessEqual(ti.getIcon(), self.icon)
00145         self.failUnlessEqual(ti.Metatype(), self.meta_type)

Definition at line 135 of file test_atdocument.py.

00135 
00136     def test_x_safe_html(self):
00137         doc = self._ATCT
00138         mimetypes = (
00139             ('text/html', '<p>test</p>'),
00140             # MTR doens't know about text/stx, and transforming
00141             # doubles the tags. Yuck.
00142             ('text/structured', '<p><p>test</p></p>\n'),
00143             # XXX
00144             # ('text/x-rst', ("<p>&lt;p&gt;test&lt;/p&gt;&lt;script&gt;"
00145             #                 "I'm a nasty boy&lt;p&gt;nested&lt;/p&gt;"
00146             #                 "&lt;/script&gt;</p>\n")),
00147             # ('text/python-source', '<p>test</p>'),
00148             # XXX
00149             # ('text/plain', ("<p>&lt;p&gt;test&lt;/p&gt;&lt;script&gt;"
00150             #                 "I'm a nasty boy&lt;p&gt;nested&lt;/p&gt;"
00151             #                 "&lt;/script&gt;</p>\n")),
00152             )
00153         for mimetype, expected in mimetypes:
00154             # scrub html is removing unallowed tags
00155             text = "<p>test</p><script>I'm a nasty boy<p>nested</p></script>"
00156             doc.setText(text, mimetype=mimetype)
00157             txt = doc.getText()
00158             self.failUnlessEqual(txt, expected, (txt, expected, mimetype))


Member Data Documentation

Definition at line 82 of file atcttestcase.py.

Definition at line 84 of file atcttestcase.py.

string ATContentTypes.tests.test_atdocument.TestSiteATDocument.icon = 'document_icon.gif' [static]

Reimplemented from ATContentTypes.tests.atcttestcase.ATCTTypeTestCase.

Definition at line 85 of file test_atdocument.py.

Reimplemented from ATContentTypes.tests.atcttestcase.ATCTTypeTestCase.

Definition at line 81 of file test_atdocument.py.

Reimplemented from ATContentTypes.tests.atcttestcase.ATCTTypeTestCase.

Definition at line 84 of file test_atdocument.py.

Reimplemented from ATContentTypes.tests.atcttestcase.ATCTTypeTestCase.

Definition at line 82 of file test_atdocument.py.

Reimplemented from ATContentTypes.tests.atcttestcase.ATCTTypeTestCase.

Definition at line 83 of file test_atdocument.py.


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