Commit 5b454b0e authored by Ivan Tyagov's avatar Ivan Tyagov

Test calculation of PDF content information

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@38518 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3ac3d77e
......@@ -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'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment