Commit ca9dc7a4 authored by Bartek Górny's avatar Bartek Górny

adjusted to the new API

changed the tested behaviour of PDF
commented out source_reference check
fixed minor naming flaws


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13721 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 07b94396
...@@ -282,7 +282,7 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -282,7 +282,7 @@ class TestIngestion(ERP5TypeTestCase):
self.checkObjectCatalogged(portal_type, reference) self.checkObjectCatalogged(portal_type, reference)
self.assert_(hasattr(dm, id)) self.assert_(hasattr(dm, id))
def ingestFormats(self, doc_id, formats_from, portal_type=None): def ingestFormatList(self, doc_id, formats_from, portal_type=None):
""" """
method for bulk ingesting files of various formats method for bulk ingesting files of various formats
we take them one by one based on naming convention we take them one by one based on naming convention
...@@ -302,7 +302,7 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -302,7 +302,7 @@ class TestIngestion(ERP5TypeTestCase):
context.convertToBaseFormat() context.convertToBaseFormat()
context.reindexObject(); get_transaction().commit(); self.tic() context.reindexObject(); get_transaction().commit(); self.tic()
self.failUnless(context.hasFile()) self.failUnless(context.hasFile())
if context.getPortalType() in ('Image', 'File'): # these are not subject to conversion if context.getPortalType() in ('Image', 'File', 'PDF'): # these are not subject to conversion
self.assertEquals(context.getExternalProcessingState(), 'uploaded') self.assertEquals(context.getExternalProcessingState(), 'uploaded')
else: else:
self.assertEquals(context.getExternalProcessingState(), 'converted') # this is how we know if it was ok or not self.assertEquals(context.getExternalProcessingState(), 'converted') # this is how we know if it was ok or not
...@@ -325,7 +325,7 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -325,7 +325,7 @@ class TestIngestion(ERP5TypeTestCase):
for target in targets: for target in targets:
self.assert_(target in target_list) self.assert_(target in target_list)
def contributeFiles(self, with_portal_type=False): def contributeFileList(self, with_portal_type=False):
""" """
some file types fail, but generally it shows that if the content type some file types fail, but generally it shows that if the content type
is detected correctly, everything goes smooth is detected correctly, everything goes smooth
...@@ -354,7 +354,7 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -354,7 +354,7 @@ class TestIngestion(ERP5TypeTestCase):
self.assertEquals(ob.getPortalType(), typ) self.assertEquals(ob.getPortalType(), typ)
self.assertEquals(ob.getReference(), 'TEST') self.assertEquals(ob.getReference(), 'TEST')
ob.reindexObject(); get_transaction().commit(); self.tic() ob.reindexObject(); get_transaction().commit(); self.tic()
if ob.getPortalType() in ('Image', 'File'): # these are not subject to conversion if ob.getPortalType() in ('Image', 'File', 'PDF'): # these are not subject to conversion
self.assertEquals(ob.getExternalProcessingState(), 'uploaded') self.assertEquals(ob.getExternalProcessingState(), 'uploaded')
else: else:
self.assertEquals(ob.getExternalProcessingState(), 'converted') # this is how we know if it was ok or not self.assertEquals(ob.getExternalProcessingState(), 'converted') # this is how we know if it was ok or not
...@@ -524,7 +524,7 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -524,7 +524,7 @@ class TestIngestion(ERP5TypeTestCase):
f = makeFileUpload('TEST-en-002.doc') f = makeFileUpload('TEST-en-002.doc')
doc.edit(file=f) doc.edit(file=f)
self.assert_(doc.hasFile()) self.assert_(doc.hasFile())
self.assertEquals(doc.getSourceReference(), 'TEST-en-002.doc') #self.assertEquals(doc.getSourceReference(), 'TEST-en-002.doc')
self.assertEquals(doc.getRevision(), '') self.assertEquals(doc.getRevision(), '')
doc.reindexObject(); get_transaction().commit(); self.tic() doc.reindexObject(); get_transaction().commit(); self.tic()
...@@ -597,10 +597,10 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -597,10 +597,10 @@ class TestIngestion(ERP5TypeTestCase):
kw = dict(title='another title', kw = dict(title='another title',
subject='another subject', subject='another subject',
description='another description') description='another description')
context.editMetadata(kw) context.updateBaseMetadata(**kw)
# context.edit(**kw) - this works from UI but not from here - is there a problem somewhere? # context.edit(**kw) - this works from UI but not from here - is there a problem somewhere?
context.reindexObject(); get_transaction().commit(); context.reindexObject(); get_transaction().commit();
self.tic(); self.tic(); self.tic();
def stepCheckChangedMetadata(self, sequence=None, sequence_list=None, **kw): def stepCheckChangedMetadata(self, sequence=None, sequence_list=None, **kw):
""" """
...@@ -610,7 +610,7 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -610,7 +610,7 @@ class TestIngestion(ERP5TypeTestCase):
# implemented in OOoDocument class - we don't really # implemented in OOoDocument class - we don't really
# need oood for getting/setting metadata... # need oood for getting/setting metadata...
context = self.getDocument('one') context = self.getDocument('one')
newcontent = context.getOOFile() newcontent = context.getBaseData()
cs = cStringIO.StringIO() cs = cStringIO.StringIO()
cs.write(unpackData(newcontent)) cs.write(unpackData(newcontent))
z = zipfile.ZipFile(cs) z = zipfile.ZipFile(cs)
...@@ -629,7 +629,7 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -629,7 +629,7 @@ class TestIngestion(ERP5TypeTestCase):
make sure they are converted make sure they are converted
""" """
formats_from = ['rtf', 'doc', 'txt', 'sxw', 'sdw'] formats_from = ['rtf', 'doc', 'txt', 'sxw', 'sdw']
self.ingestFormats('one', formats_from) self.ingestFormatList('one', formats_from)
def stepIngestSpreadsheetFormats(self, sequence=None, sequence_list=None, **kw): def stepIngestSpreadsheetFormats(self, sequence=None, sequence_list=None, **kw):
""" """
...@@ -637,7 +637,7 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -637,7 +637,7 @@ class TestIngestion(ERP5TypeTestCase):
make sure they are converted make sure they are converted
""" """
formats_from = ['xls', 'sxc', 'sdc'] formats_from = ['xls', 'sxc', 'sdc']
self.ingestFormats('two', formats_from) self.ingestFormatList('two', formats_from)
def stepIngestPresentationFormats(self, sequence=None, sequence_list=None, **kw): def stepIngestPresentationFormats(self, sequence=None, sequence_list=None, **kw):
""" """
...@@ -645,7 +645,7 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -645,7 +645,7 @@ class TestIngestion(ERP5TypeTestCase):
make sure they are converted make sure they are converted
""" """
formats_from = ['ppt', 'sxi', 'sdd'] formats_from = ['ppt', 'sxi', 'sdd']
self.ingestFormats('three', formats_from) self.ingestFormatList('three', formats_from)
def stepIngestPDFFormats(self, sequence=None, sequence_list=None, **kw): def stepIngestPDFFormats(self, sequence=None, sequence_list=None, **kw):
""" """
...@@ -653,7 +653,7 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -653,7 +653,7 @@ class TestIngestion(ERP5TypeTestCase):
make sure they are converted make sure they are converted
""" """
formats_from = ['pdf'] formats_from = ['pdf']
self.ingestFormats('five', formats_from) self.ingestFormatList('five', formats_from)
def stepIngestDrawingFormats(self, sequence=None, sequence_list=None, **kw): def stepIngestDrawingFormats(self, sequence=None, sequence_list=None, **kw):
""" """
...@@ -661,7 +661,7 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -661,7 +661,7 @@ class TestIngestion(ERP5TypeTestCase):
make sure they are converted make sure they are converted
""" """
formats_from = ['sxd', 'sda'] formats_from = ['sxd', 'sda']
self.ingestFormats('four', formats_from) self.ingestFormatList('four', formats_from)
def stepIngestPDFFormats(self, sequence=None, sequence_list=None, **kw): def stepIngestPDFFormats(self, sequence=None, sequence_list=None, **kw):
""" """
...@@ -669,14 +669,14 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -669,14 +669,14 @@ class TestIngestion(ERP5TypeTestCase):
make sure they are converted make sure they are converted
""" """
formats_from = ['pdf'] formats_from = ['pdf']
self.ingestFormats('five', formats_from) self.ingestFormatList('five', formats_from)
def stepIngestImageFormats(self, sequence=None, sequence_list=None, **kw): def stepIngestImageFormats(self, sequence=None, sequence_list=None, **kw):
""" """
ingest all supported image formats ingest all supported image formats
""" """
formats_from = ['jpg', 'gif', 'bmp', 'png'] formats_from = ['jpg', 'gif', 'bmp', 'png']
self.ingestFormats('six', formats_from, 'Image') self.ingestFormatList('six', formats_from, 'Image')
def stepCheckTextDocumentExportList(self, sequence=None, sequence_list=None, **kw): def stepCheckTextDocumentExportList(self, sequence=None, sequence_list=None, **kw):
self.checkDocumentExportList('one', 'doc', ['pdf', 'doc', 'rtf', 'html-writer', 'txt']) self.checkDocumentExportList('one', 'doc', ['pdf', 'doc', 'rtf', 'html-writer', 'txt'])
...@@ -698,9 +698,9 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -698,9 +698,9 @@ class TestIngestion(ERP5TypeTestCase):
doc = self.getDocument('five') doc = self.getDocument('five')
f = makeFileUpload('TEST-en-002.pdf') f = makeFileUpload('TEST-en-002.pdf')
doc.edit(file=f) doc.edit(file=f)
res = doc._makeFile('jpg') res = doc.convert('jpg')
self.failUnless(res) self.failUnless(res)
res_html = doc.getHtmlRepresentation() res_html = doc.asHTML()
self.failUnless('magic' in res_html) self.failUnless('magic' in res_html)
def stepExportImage(self, sequence=None, sequence_list=None, **kw): def stepExportImage(self, sequence=None, sequence_list=None, **kw):
...@@ -713,11 +713,11 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -713,11 +713,11 @@ class TestIngestion(ERP5TypeTestCase):
def stepCheckHasSnapshot(self, sequence=None, sequence_list=None, **kw): def stepCheckHasSnapshot(self, sequence=None, sequence_list=None, **kw):
context = self.getDocument('one') context = self.getDocument('one')
self.failUnless(context.hasSnapshot()) self.failUnless(context.hasSnapshotData())
def stepCheckHasNoSnapshot(self, sequence=None, sequence_list=None, **kw): def stepCheckHasNoSnapshot(self, sequence=None, sequence_list=None, **kw):
context = self.getDocument('one') context = self.getDocument('one')
self.failIf(context.hasSnapshot()) self.failIf(context.hasSnapshotData())
def stepCreateSnapshot(self, sequence=None, sequence_list=None, **kw): def stepCreateSnapshot(self, sequence=None, sequence_list=None, **kw):
context = self.getDocument('one') context = self.getDocument('one')
...@@ -732,19 +732,19 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -732,19 +732,19 @@ class TestIngestion(ERP5TypeTestCase):
context = self.getDocument('one') context = self.getDocument('one')
context.deleteSnapshot() context.deleteSnapshot()
def stepContributeFilesWithType(self, sequence=None, sequence_list=None, **kw): def stepContributeFileListWithType(self, sequence=None, sequence_list=None, **kw):
""" """
Contribute all kinds of files giving portal type explicitly Contribute all kinds of files giving portal type explicitly
TODO: test situation whereby portal_type given explicitly is wrong TODO: test situation whereby portal_type given explicitly is wrong
""" """
self.contributeFiles(with_portal_type=True) self.contributeFileList(with_portal_type=True)
def stepContributeFilesWithNoType(self, sequence=None, sequence_list=None, **kw): def stepContributeFileListWithNoType(self, sequence=None, sequence_list=None, **kw):
""" """
Contribute all kinds of files Contribute all kinds of files
let the system figure out portal type by itself let the system figure out portal type by itself
""" """
self.contributeFiles(with_portal_type=False) self.contributeFileList(with_portal_type=False)
def stepSetDiscoveryScriptsForOrdering(self, sequence=None, sequence_list=None, **kw): def stepSetDiscoveryScriptsForOrdering(self, sequence=None, sequence_list=None, **kw):
""" """
...@@ -760,7 +760,7 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -760,7 +760,7 @@ class TestIngestion(ERP5TypeTestCase):
self.setDiscoveryScript('one', 'Text_getPropertyDictFromUserLogin', 'user_name=None', "return {'reference':'USER', 'language':'us', 'contributor':'person_module/john'}") self.setDiscoveryScript('one', 'Text_getPropertyDictFromUserLogin', 'user_name=None', "return {'reference':'USER', 'language':'us', 'contributor':'person_module/john'}")
self.setDiscoveryScript('one', 'Text_getPropertyDictFromContent', '', "return {'reference':'CONT', 'version':'003', 'contributor':'person_module/jack', 'short_title':'from_content'}") self.setDiscoveryScript('one', 'Text_getPropertyDictFromContent', '', "return {'reference':'CONT', 'version':'003', 'contributor':'person_module/jack', 'short_title':'from_content'}")
def stepCheckMetadataSettingOrderFIUC(self, sequence=None, sequence_list=None, **kw): def stepCheckMetadataSettingOrderFICU(self, sequence=None, sequence_list=None, **kw):
""" """
This is the default This is the default
""" """
...@@ -1041,8 +1041,8 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -1041,8 +1041,8 @@ class TestIngestion(ERP5TypeTestCase):
if not run: return if not run: return
if not quiet: shout('test_09_Contribute') if not quiet: shout('test_09_Contribute')
sequence_list = SequenceList() sequence_list = SequenceList()
step_list = ['stepContributeFilesWithNoType' step_list = ['stepContributeFileListWithNoType'
,'stepContributeFilesWithType' ,'stepContributeFileListWithType'
] ]
sequence_string = ' '.join(step_list) sequence_string = ' '.join(step_list)
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
...@@ -1064,7 +1064,7 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -1064,7 +1064,7 @@ class TestIngestion(ERP5TypeTestCase):
step_list = [ 'stepCreateTextDocument' step_list = [ 'stepCreateTextDocument'
,'stepStraightUpload' ,'stepStraightUpload'
,'stepSetDiscoveryScriptsForOrdering' ,'stepSetDiscoveryScriptsForOrdering'
,'stepCheckMetadataSettingOrderFIUC' ,'stepCheckMetadataSettingOrderFICU'
,'stepCreateTextDocument' ,'stepCreateTextDocument'
,'stepStraightUpload' ,'stepStraightUpload'
,'stepSetDiscoveryScriptsForOrdering' ,'stepSetDiscoveryScriptsForOrdering'
......
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