def test_adding(self): # we can add OfficeDoc instances self.folder.invokeFactory( 'psj.content.officedoc', 'doc1', psj_office_doc=self.src_file, title=u'My Doc', description=u'My description.' ) d1 = self.folder['doc1'] self.assertTrue(IOfficeDoc.providedBy(d1)) self.assertEqual(d1.title, u'My Doc') self.assertEqual(d1.description, u'My description.') # additional attributes were set self.assertEqual(d1.psj_md5, '396199333edbf40ad43e62a1c1397793') assert d1.psj_html_repr.data is not None assert d1.psj_pdf_repr.data is not None
def test_factory(self): # our fti provides a factory for OfficeDoc instances fti = queryUtility(IDexterityFTI, name='psj.content.officedoc') factory = fti.factory new_obj = createObject(factory) self.assertTrue(IOfficeDoc.providedBy(new_obj))