Commit 2e04cc61 authored by Nicolas Delaby's avatar Nicolas Delaby

Add test for import object from OOo

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13900 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 653ed585
...@@ -44,6 +44,7 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase ...@@ -44,6 +44,7 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5Type.Cache import clearCache from Products.ERP5Type.Cache import clearCache
from Products.ERP5OOo.Document.OOoDocument import ConversionError from Products.ERP5OOo.Document.OOoDocument import ConversionError
from ZPublisher.HTTPRequest import FileUpload
if __name__ == '__main__': if __name__ == '__main__':
...@@ -129,7 +130,7 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -129,7 +130,7 @@ class TestIngestion(ERP5TypeTestCase):
self.createPreferences() self.createPreferences()
self.createTools() self.createTools()
self.unpackData() self.unpackData()
def unpackData(self): def unpackData(self):
""" """
Unpack the content of testIngestion_docs.zip Unpack the content of testIngestion_docs.zip
...@@ -404,6 +405,9 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -404,6 +405,9 @@ class TestIngestion(ERP5TypeTestCase):
################################## ##################################
## Basic steps ## Basic steps
################################## ##################################
def stepTic(self, sequence=None, sequence_list=None, **kw):
self.tic()
def stepCheckPreferences(self, sequence=None, sequence_list=None, **kw): def stepCheckPreferences(self, sequence=None, sequence_list=None, **kw):
""" """
...@@ -858,6 +862,39 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -858,6 +862,39 @@ class TestIngestion(ERP5TypeTestCase):
break break
self.failUnless(john_is_owner) self.failUnless(john_is_owner)
def stepImportRawDataFile(self, sequence=None, sequence_list=None, **kw):
f = makeFileUpload('TEST-en-003.ods')
#environ = {'REQUEST_METHOD': 'POST', 'CONTENT_TYPE': 'plain/text'}
#file = FileUpload(FieldStorage(fp=f, environ=environ))
person_module = self.getPortal().person_module
#purge existing persons
person_module.manage_delObjects([id for id in person_module.getObjectIds()])
get_transaction().commit(); self.tic()
listbox=(
{ 'listbox_key': '001',
'portal_type_property_list':'Person.title'},
{ 'listbox_key': '002',
'portal_type_property_list':'Person.first_name'},
{ 'listbox_key': '003',
'portal_type_property_list':'Person.last_name'},
{ 'listbox_key': '004',
'portal_type_property_list':'Person.default_email_text'}
)
person_module.ERP5Site_importObjectFromOOo(import_file=f, listbox=listbox)
def stepCheckActivitiesCount(self, sequence=None, sequence_list=None, **kw):
message_list = self.getPortal().portal_activities.getMessageList()
#101 objects x 3 (default_email, recursiveImmediateReindexObject, immediateReindexObject) = 303 activities
self.assertEqual(303,len(message_list))
def stepCheckImportedPersonList(self, sequence=None, sequence_list=None, **kw):
person_module = self.getPortal().person_module
for i in range(101):
object = person_module['%s' % (i+1)]
self.assertEqual('John Doe %s' % (i), object.getTitle())
self.assertEqual('John', object.getFirstName())
self.assertEqual('Doe %s' % (i), object.getLastName())
self.assertEqual('john.doe%s@foo.com' % (i), object.getDefaultEmailText())
################################## ##################################
## Tests ## Tests
...@@ -1117,6 +1154,23 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -1117,6 +1154,23 @@ class TestIngestion(ERP5TypeTestCase):
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet) sequence_list.play(self, quiet=quiet)
def test_12_ImportObjectFromOOoInActivities(self, quiet=QUIET, run=RUN_ALL_TEST):
"""
Simulate import of OOo file true ERP5Site_importObjectFromOOoFastInput
For Person Module.
"""
if testrun and 12 not in testrun:return
if not run: return
if not quiet: shout('test_12_ImportObjectOOoInActivities')
sequence_list = SequenceList()
step_list = [ 'stepImportRawDataFile'
,'stepCheckActivitiesCount'
,'Tic'
,'stepCheckImportedPersonList'
]
sequence_string = ' '.join(step_list)
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet)
if __name__ == '__main__': if __name__ == '__main__':
framework() framework()
......
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