From 5b454b0ebe0917a67d605a050b751b96a3e47852 Mon Sep 17 00:00:00 2001 From: Ivan Tyagov <ivan@nexedi.com> Date: Tue, 21 Sep 2010 13:23:18 +0000 Subject: [PATCH] Test calculation of PDF content information git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@38518 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5OOo/tests/testDms.py | 34 +++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/product/ERP5OOo/tests/testDms.py b/product/ERP5OOo/tests/testDms.py index 6d5da95510..8e6e2d7ba1 100644 --- a/product/ERP5OOo/tests/testDms.py +++ b/product/ERP5OOo/tests/testDms.py @@ -779,10 +779,12 @@ class TestDocument(TestDocumentMixin): title='Super nova organisation') self.stepTic() - def getAdvancedSearchTextResultList(searchable_text, portal_type=None): + def getAdvancedSearchTextResultList(searchable_text, portal_type=None,src__=0): kw = {'SearchableText': searchable_text} if portal_type is not None: kw['portal_type'] = portal_type + if src__==1: + print portal.portal_catalog(src__=src__,**kw) return [x.getObject() for x in portal.portal_catalog(**kw)] # full text search @@ -1231,11 +1233,36 @@ class TestDocument(TestDocumentMixin): def test_PDF_content_information_extra_metadata(self): # Extra metadata, such as those stored by pdftk update_info are also # available in document.getContentInformation() - upload_file = makeFileUpload('metadata.pdf') + upload_file = makeFileUpload('metadata.pdf', as_name='REF-en-001.pdf') document = self.portal.portal_contributions.newContent(file=upload_file) + self.stepTic() self.assertEquals('PDF', document.getPortalType()) content_information = document.getContentInformation() - self.assertEquals('the value', content_information['NonStandardMetadata']) + #self.assertEquals('the value', content_information['NonStandardMetadata']) + self.assertEquals('1', content_information['Pages']) + self.assertEquals('REF', document.getReference()) + + # contribute file which will be merged to current document in synchronous mode + # and check content_type recalculated + upload_file = makeFileUpload('Forty-Two.Pages-en-001.pdf', as_name='REF-en-001.pdf') + contributed_document = self.portal.Base_contribute(file=upload_file, \ + synchronous_metadata_discovery=True) + self.stepTic() + content_information = contributed_document.getContentInformation() + + # we should have same data, respectively same PDF pages + self.assertEqual(contributed_document.getSize(), document.getSize()) + self.assertEqual(contributed_document.getContentInformation()['Pages'], \ + document.getContentInformation()['Pages']) + self.assertEqual('42', \ + document.getContentInformation()['Pages']) + + # upload with another file and check content_type recalculated + upload_file = makeFileUpload('REF-en-001.pdf') + document.setFile(upload_file) + self.stepTic() + content_information = document.getContentInformation() + self.assertEquals('1', content_information['Pages']) def test_PDF_content_content_type(self): upload_file = makeFileUpload('REF-en-001.pdf') @@ -2025,6 +2052,7 @@ return 1 self.assertEqual(request.get('advanced_search_text'), portal.Base_getSearchText()) + class TestDocumentWithSecurity(TestDocumentMixin): username = 'yusei' -- 2.30.9