Commit 59571d6d authored by Arnaud Fontaine's avatar Arnaud Fontaine

WIP

parent 4645e7b4
...@@ -29,11 +29,12 @@ ...@@ -29,11 +29,12 @@
import unittest import unittest
import os import os
from Products.ERP5OOo.OOoUtils import OOoParser from erp5.component.module.OOoUtils import OOoParser
def makeFilePath(name): def makeFilePath(name):
return os.path.join(os.path.dirname(__file__), 'test_document', name) import Products.ERP5
return os.path.join(os.path.dirname(Products.ERP5.__file__), 'test_data', name)
class TestOOoParser(unittest.TestCase): class TestOOoParser(unittest.TestCase):
""" OOoParser tests """ OOoParser tests
...@@ -45,7 +46,7 @@ class TestOOoParser(unittest.TestCase): ...@@ -45,7 +46,7 @@ class TestOOoParser(unittest.TestCase):
self.assertEqual(['Person'], mapping.keys()) self.assertEqual(['Person'], mapping.keys())
person_mapping = mapping['Person'] person_mapping = mapping['Person']
self.assertTrue(isinstance(person_mapping, list)) self.assertTrue(isinstance(person_mapping, list))
self.assertTrue(102, len(person_mapping)) self.assertEqual(len(person_mapping), 102)
self.assertEqual(person_mapping[0], self.assertEqual(person_mapping[0],
['Title', 'First Name', 'Last Name', 'Default Email Text']) ['Title', 'First Name', 'Last Name', 'Default Email Text'])
self.assertEqual(person_mapping[1], self.assertEqual(person_mapping[1],
...@@ -99,7 +100,7 @@ class TestOOoParser(unittest.TestCase): ...@@ -99,7 +100,7 @@ class TestOOoParser(unittest.TestCase):
parser.openFile(open(makeFilePath('import_big_spreadsheet.ods'), 'rb')) parser.openFile(open(makeFilePath('import_big_spreadsheet.ods'), 'rb'))
mapping = parser.getSpreadsheetsMapping() mapping = parser.getSpreadsheetsMapping()
not_ok = 1 not_ok = 1
for spread, values in mapping.iteritems(): for _, values in mapping.iteritems():
self.assertEqual(len(values), 41001) self.assertEqual(len(values), 41001)
not_ok = 0 not_ok = 0
if not_ok: if not_ok:
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testOOoParser</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5OOo.tests.testOOoParser</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testOOoParser</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -30,6 +30,7 @@ test.erp5.testMemcachedTool ...@@ -30,6 +30,7 @@ test.erp5.testMemcachedTool
test.erp5.testNotificationMessageModule test.erp5.testNotificationMessageModule
test.erp5.testNotificationTool test.erp5.testNotificationTool
test.erp5.testOOoBatchMode test.erp5.testOOoBatchMode
test.erp5.testOOoParser
test.erp5.testPerson test.erp5.testPerson
test.erp5.testQueryModule test.erp5.testQueryModule
test.erp5.testRestrictedPythonSecurity test.erp5.testRestrictedPythonSecurity
......
...@@ -118,13 +118,13 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -118,13 +118,13 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
def test_report_view(self): def test_report_view(self):
self.loginAsUser('bob') self.loginAsUser('bob')
self.portal.changeSkin('Deferred') self.portal.changeSkin('Deferred')
response = self.publish( self.publish(
'/%s/person_module/pers/Base_viewHistory?deferred_portal_skin=%s' '/%s/person_module/pers/Base_viewHistory?deferred_portal_skin=%s'
% (self.portal.getId(), self.skin), '%s:%s' % (self.username, self.password)) % (self.portal.getId(), self.skin), '%s:%s' % (self.username, self.password))
self.tic() self.tic()
last_message = self.portal.MailHost._last_message last_message = self.portal.MailHost._last_message
self.assertNotEquals((), last_message) self.assertNotEquals((), last_message)
mfrom, mto, message_text = last_message _, mto, message_text = last_message
self.assertEqual('"%s" <%s>' % (self.first_name, self.recipient_email_address), mto[0]) self.assertEqual('"%s" <%s>' % (self.first_name, self.recipient_email_address), mto[0])
mail_message = email.message_from_string(message_text) mail_message = email.message_from_string(message_text)
for part in mail_message.walk(): for part in mail_message.walk():
...@@ -181,7 +181,7 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -181,7 +181,7 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
self._defineSystemPreference() self._defineSystemPreference()
self.loginAsUser('bob') self.loginAsUser('bob')
self.portal.changeSkin('Deferred') self.portal.changeSkin('Deferred')
response = self.publish( self.publish(
'/%s/person_module/pers/Base_viewHistory?deferred_portal_skin=%s' '/%s/person_module/pers/Base_viewHistory?deferred_portal_skin=%s'
% (self.portal.getId(), self.skin), '%s:%s' % (self.username, self.password)) % (self.portal.getId(), self.skin), '%s:%s' % (self.username, self.password))
self.tic() self.tic()
...@@ -189,7 +189,7 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -189,7 +189,7 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
last_message = self.portal.MailHost._last_message last_message = self.portal.MailHost._last_message
self.assertNotEquals((), last_message) self.assertNotEquals((), last_message)
mfrom, mto, message_text = last_message _, mto, message_text = last_message
self.assertEqual('"%s" <%s>' % (self.first_name, self.recipient_email_address), mto[0]) self.assertEqual('"%s" <%s>' % (self.first_name, self.recipient_email_address), mto[0])
mail_message = email.message_from_string(message_text) mail_message = email.message_from_string(message_text)
for part in mail_message.walk(): for part in mail_message.walk():
...@@ -219,7 +219,7 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -219,7 +219,7 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
self._defineSystemPreference("notification-deferred.report") self._defineSystemPreference("notification-deferred.report")
self.loginAsUser('bob') self.loginAsUser('bob')
self.portal.changeSkin('Deferred') self.portal.changeSkin('Deferred')
response = self.publish( self.publish(
'/%s/person_module/pers/Base_viewHistory?deferred_portal_skin=%s' '/%s/person_module/pers/Base_viewHistory?deferred_portal_skin=%s'
% (self.portal.getId(), self.skin), '%s:%s' % (self.username, self.password)) % (self.portal.getId(), self.skin), '%s:%s' % (self.username, self.password))
self.tic() self.tic()
...@@ -227,7 +227,7 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -227,7 +227,7 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
last_message = self.portal.MailHost._last_message last_message = self.portal.MailHost._last_message
self.assertNotEquals((), last_message) self.assertNotEquals((), last_message)
mfrom, mto, message_text = last_message _, mto, message_text = last_message
self.assertEqual('"%s" <%s>' % (self.first_name, self.recipient_email_address), mto[0]) self.assertEqual('"%s" <%s>' % (self.first_name, self.recipient_email_address), mto[0])
mail_message = email.message_from_string(message_text) mail_message = email.message_from_string(message_text)
for part in mail_message.walk(): for part in mail_message.walk():
...@@ -242,7 +242,7 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -242,7 +242,7 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
self._defineSystemPreference() self._defineSystemPreference()
self.loginAsUser('bob') self.loginAsUser('bob')
self.portal.changeSkin('Deferred') self.portal.changeSkin('Deferred')
response = self.publish( self.publish(
'/%s/person_module/pers/Base_viewHistory?deferred_portal_skin=%s&format=pdf' '/%s/person_module/pers/Base_viewHistory?deferred_portal_skin=%s&format=pdf'
% (self.portal.getId(), self.skin), '%s:%s' % (self.username, self.password)) % (self.portal.getId(), self.skin), '%s:%s' % (self.username, self.password))
self.tic() self.tic()
...@@ -251,7 +251,7 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -251,7 +251,7 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
last_message = self.portal.MailHost._last_message last_message = self.portal.MailHost._last_message
self.assertNotEquals((), last_message) self.assertNotEquals((), last_message)
mfrom, mto, message_text = last_message _, mto, message_text = last_message
self.assertEqual('"%s" <%s>' % (self.first_name, self.recipient_email_address), mto[0]) self.assertEqual('"%s" <%s>' % (self.first_name, self.recipient_email_address), mto[0])
mail_message = email.message_from_string(message_text) mail_message = email.message_from_string(message_text)
for part in mail_message.walk(): for part in mail_message.walk():
...@@ -266,7 +266,7 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -266,7 +266,7 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
self.loginAsUser('bob') self.loginAsUser('bob')
# simulate a big request, for which Base_callDialogMethod will not issue a # simulate a big request, for which Base_callDialogMethod will not issue a
# redirect # redirect
response = self.publish( self.publish(
'/%s/person_module/pers/Base_callDialogMethod?deferred_portal_skin=%s&' '/%s/person_module/pers/Base_callDialogMethod?deferred_portal_skin=%s&'
'dialog_method=Person_view&dialog_id=Person_view&' 'dialog_method=Person_view&dialog_id=Person_view&'
'deferred_style:int=1&junk=%s' % (self.portal.getId(), 'deferred_style:int=1&junk=%s' % (self.portal.getId(),
...@@ -276,7 +276,7 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -276,7 +276,7 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
self.tic() self.tic()
last_message = self.portal.MailHost._last_message last_message = self.portal.MailHost._last_message
self.assertNotEquals((), last_message) self.assertNotEquals((), last_message)
mfrom, mto, message_text = last_message _, mto, message_text = last_message
self.assertEqual('"%s" <%s>' % (self.first_name, self.recipient_email_address), mto[0]) self.assertEqual('"%s" <%s>' % (self.first_name, self.recipient_email_address), mto[0])
mail_message = email.message_from_string(message_text) mail_message = email.message_from_string(message_text)
for part in mail_message.walk(): for part in mail_message.walk():
...@@ -300,7 +300,7 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -300,7 +300,7 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
# User's Accept-Language header is honored in reports. # User's Accept-Language header is honored in reports.
self.loginAsUser('bob') self.loginAsUser('bob')
self.portal.changeSkin('Deferred') self.portal.changeSkin('Deferred')
response = self.publish( self.publish(
'/%s/person_module/pers/Base_viewHistory?deferred_portal_skin=%s' '/%s/person_module/pers/Base_viewHistory?deferred_portal_skin=%s'
% (self.portal.getId(), self.skin), % (self.portal.getId(), self.skin),
'%s:%s' % (self.username, self.password), '%s:%s' % (self.username, self.password),
...@@ -325,7 +325,7 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -325,7 +325,7 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
# User's LOCALIZER_LANGUAGE cookie is honored in reports and have priority over Accept-Language # User's LOCALIZER_LANGUAGE cookie is honored in reports and have priority over Accept-Language
self.loginAsUser('bob') self.loginAsUser('bob')
self.portal.changeSkin('Deferred') self.portal.changeSkin('Deferred')
response = self.publish( self.publish(
'/%s/person_module/pers/Base_viewHistory?deferred_portal_skin=%s' '/%s/person_module/pers/Base_viewHistory?deferred_portal_skin=%s'
% (self.portal.getId(), self.skin), % (self.portal.getId(), self.skin),
'%s:%s' % (self.username, self.password), '%s:%s' % (self.username, self.password),
...@@ -366,13 +366,13 @@ class TestODSDeferredStyle(TestDeferredStyle): ...@@ -366,13 +366,13 @@ class TestODSDeferredStyle(TestDeferredStyle):
""" """
self.loginAsUser('bob') self.loginAsUser('bob')
self.portal.changeSkin('Deferred') self.portal.changeSkin('Deferred')
response = self.publish( self.publish(
'/%s/person_module/pers/Base_viewHistory?deferred_portal_skin=%s&sheet_per_report_section:int=1' '/%s/person_module/pers/Base_viewHistory?deferred_portal_skin=%s&sheet_per_report_section:int=1'
% (self.portal.getId(), self.skin), '%s:%s' % (self.username, self.password)) % (self.portal.getId(), self.skin), '%s:%s' % (self.username, self.password))
self.tic() self.tic()
last_message = self.portal.MailHost._last_message last_message = self.portal.MailHost._last_message
self.assertNotEquals((), last_message) self.assertNotEquals((), last_message)
mfrom, mto, message_text = last_message _, mto, message_text = last_message
self.assertEqual('"%s" <%s>' % (self.first_name, self.recipient_email_address), mto[0]) self.assertEqual('"%s" <%s>' % (self.first_name, self.recipient_email_address), mto[0])
mail_message = email.message_from_string(message_text) mail_message = email.message_from_string(message_text)
for part in mail_message.walk(): for part in mail_message.walk():
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testDeferredStyle</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5OOo.tests.testDeferredStyle</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testDeferredStyle</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
test.erp5.testDeferredStyle
\ No newline at end of file
erp5_full_text_mroonga_catalog
erp5_core_proxy_field_legacy
erp5_base
erp5_ods_style
erp5_ingestion_mysql_innodb_catalog
erp5_ingestion
erp5_web
erp5_dms
erp5_l10n_fr
\ No newline at end of file
...@@ -38,7 +38,7 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ( ...@@ -38,7 +38,7 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import (
ERP5TypeTestCase, _getConversionServerUrlList) ERP5TypeTestCase, _getConversionServerUrlList)
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5Type.tests.utils import FileUpload, createZODBPythonScript from Products.ERP5Type.tests.utils import FileUpload, createZODBPythonScript
from Products.ERP5OOo.OOoUtils import OOoBuilder from erp5.component.module.OOoUtils import OOoBuilder
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
from zExceptions import BadRequest from zExceptions import BadRequest
from unittest import expectedFailure from unittest import expectedFailure
...@@ -49,7 +49,8 @@ import urlparse ...@@ -49,7 +49,8 @@ import urlparse
import base64 import base64
# test files' home # test files' home
TEST_FILES_HOME = os.path.join(os.path.dirname(__file__), 'test_document') import Products.ERP5
TEST_FILES_HOME = os.path.join(os.path.dirname(Products.ERP5.__file__), 'test_data')
FILENAME_REGULAR_EXPRESSION = "(?P<reference>[A-Z&é@{]{3,7})-(?P<language>[a-z]{2})-(?P<version>[0-9]{3})" FILENAME_REGULAR_EXPRESSION = "(?P<reference>[A-Z&é@{]{3,7})-(?P<language>[a-z]{2})-(?P<version>[0-9]{3})"
REFERENCE_REGULAR_EXPRESSION = "(?P<reference>[A-Z&é@{]{3,7})(-(?P<language>[a-z]{2}))?(-(?P<version>[0-9]{3}))?" REFERENCE_REGULAR_EXPRESSION = "(?P<reference>[A-Z&é@{]{3,7})(-(?P<language>[a-z]{2}))?(-(?P<version>[0-9]{3}))?"
...@@ -108,7 +109,7 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -108,7 +109,7 @@ class TestIngestion(ERP5TypeTestCase):
""".split() """.split()
for module_id in module_id_list: for module_id in module_id_list:
module = self.portal[module_id] module = self.portal[module_id]
module.manage_delObjects([id for id in module.objectIds()]) module.manage_delObjects([id_ for id_ in module.objectIds()])
self.tic() self.tic()
activity_tool = self.portal.portal_activities activity_tool = self.portal.portal_activities
activity_status = {m.processing_node < -1 activity_status = {m.processing_node < -1
...@@ -259,8 +260,8 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -259,8 +260,8 @@ class TestIngestion(ERP5TypeTestCase):
For every file, this checks is the word "magic" For every file, this checks is the word "magic"
is present in both SearchableText and asText. is present in both SearchableText and asText.
""" """
for revision, format in enumerate(format_list): for _, format_ in enumerate(format_list):
filename = 'TEST-en-002.%s' %format filename = 'TEST-en-002.%s' %format_
f = makeFileUpload(filename) f = makeFileUpload(filename)
document.edit(file=f) document.edit(file=f)
self.tic() self.tic()
...@@ -274,7 +275,7 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -274,7 +275,7 @@ class TestIngestion(ERP5TypeTestCase):
# check if SearchableText() does not raise any exception # check if SearchableText() does not raise any exception
document.SearchableText() document.SearchableText()
def checkDocumentExportList(self, document, format, asserted_target_list): def checkDocumentExportList(self, document, format, asserted_target_list): # pylint: disable=redefined-builtin
""" """
Upload document ID document_id with Upload document ID document_id with
a test file of given format and assert that the document a test file of given format and assert that the document
...@@ -311,17 +312,17 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -311,17 +312,17 @@ class TestIngestion(ERP5TypeTestCase):
old_portal_type = '' old_portal_type = ''
for extension, portal_type in extension_to_type: for extension, portal_type in extension_to_type:
filename = 'TEST-en-002.%s' %extension filename = 'TEST-en-002.%s' %extension
file = makeFileUpload(filename) file_ = makeFileUpload(filename)
# if we change portal type we must change version because # if we change portal type we must change version because
# mergeRevision would fail # mergeRevision would fail
if portal_type != old_portal_type: if portal_type != old_portal_type:
counter += 1 counter += 1
old_portal_type = portal_type old_portal_type = portal_type
file.filename = 'TEST-en-00%d.%s' % (counter, extension) file_.filename = 'TEST-en-00%d.%s' % (counter, extension)
if with_portal_type: if with_portal_type:
document = self.portal.portal_contributions.newContent(portal_type=portal_type, file=file) document = self.portal.portal_contributions.newContent(portal_type=portal_type, file=file_)
else: else:
document = self.portal.portal_contributions.newContent(file=file) document = self.portal.portal_contributions.newContent(file=file_)
created_documents.append(document) created_documents.append(document)
self.tic() self.tic()
# inspect created objects # inspect created objects
...@@ -396,13 +397,12 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -396,13 +397,12 @@ class TestIngestion(ERP5TypeTestCase):
""" """
Create a person with ID "john" if it does not exists already Create a person with ID "john" if it does not exists already
""" """
portal_type = 'Person'
person_id = 'john' person_id = 'john'
reference = 'john_doe' reference = 'john_doe'
person_module = self.portal.person_module person_module = self.portal.person_module
if getattr(person_module, person_id, None) is not None: if getattr(person_module, person_id, None) is not None:
return return
person = person_module.newContent(portal_type='Person', person_module.newContent(portal_type='Person',
id=person_id, id=person_id,
reference=reference, reference=reference,
first_name='John', first_name='John',
...@@ -700,15 +700,6 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -700,15 +700,6 @@ class TestIngestion(ERP5TypeTestCase):
document = self.portal.restrictedTraverse(sequence.get('document_path')) document = self.portal.restrictedTraverse(sequence.get('document_path'))
self.ingestFormatList(document, format_list) self.ingestFormatList(document, format_list)
def stepIngestPDFFormats(self, sequence=None, sequence_list=None, **kw):
"""
ingest all supported PDF formats
make sure they are converted
"""
format_list = ['pdf']
document = self.portal.restrictedTraverse(sequence.get('document_path'))
self.ingestFormatList(document, format_list)
def stepIngestDrawingFormats(self, sequence=None, sequence_list=None, **kw): def stepIngestDrawingFormats(self, sequence=None, sequence_list=None, **kw):
""" """
ingest all supported presentation formats ingest all supported presentation formats
...@@ -798,7 +789,7 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -798,7 +789,7 @@ class TestIngestion(ERP5TypeTestCase):
f = makeFileUpload('TEST-en-002.jpg') f = makeFileUpload('TEST-en-002.jpg')
image.edit(file=f) image.edit(file=f)
self.tic() self.tic()
mime, data = image.convert(None) mime, _ = image.convert(None)
self.assertEqual(mime, 'image/jpeg') self.assertEqual(mime, 'image/jpeg')
mime, small_data = image.convert(None, display='small') mime, small_data = image.convert(None, display='small')
mime, large_data = image.convert(None, display='xlarge') mime, large_data = image.convert(None, display='xlarge')
...@@ -925,7 +916,7 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -925,7 +916,7 @@ class TestIngestion(ERP5TypeTestCase):
Email was sent in by someone to ERP5. Email was sent in by someone to ERP5.
""" """
f = open(makeFilePath('email_from.txt')) f = open(makeFilePath('email_from.txt'))
document = self.receiveEmail(f.read()) self.receiveEmail(f.read())
self.tic() self.tic()
def stepReceiveMultipleAttachmentsEmail(self, sequence=None, def stepReceiveMultipleAttachmentsEmail(self, sequence=None,
...@@ -934,35 +925,35 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -934,35 +925,35 @@ class TestIngestion(ERP5TypeTestCase):
Email was sent in by someone to ERP5. Email was sent in by someone to ERP5.
""" """
f = open(makeFilePath('email_multiple_attachments.eml')) f = open(makeFilePath('email_multiple_attachments.eml'))
document = self.receiveEmail(f.read()) self.receiveEmail(f.read())
self.tic() self.tic()
def stepVerifyEmailedMultipleDocumentsInitialContribution(self, sequence=None, sequence_list=None, **kw): def stepVerifyEmailedMultipleDocumentsInitialContribution(self, sequence=None, sequence_list=None, **kw):
""" """
Verify contributed for initial time multiple document per email. Verify contributed for initial time multiple document per email.
""" """
attachment_list, ingested_document = self.verifyEmailedMultipleDocuments() _, ingested_document = self.verifyEmailedMultipleDocuments()
self.assertEqual('1', ingested_document.getRevision()) self.assertEqual('1', ingested_document.getRevision())
def stepVerifyEmailedMultipleDocumentsMultipleContribution(self, sequence=None, sequence_list=None, **kw): def stepVerifyEmailedMultipleDocumentsMultipleContribution(self, sequence=None, sequence_list=None, **kw):
""" """
Verify contributed for initial time multiple document per email. Verify contributed for initial time multiple document per email.
""" """
attachment_list, ingested_document = self.verifyEmailedMultipleDocuments() _, ingested_document = self.verifyEmailedMultipleDocuments()
self.assertTrue(ingested_document.getRevision() > '1') self.assertTrue(ingested_document.getRevision() > '1')
def stepVerifyEmailedDocumentInitialContribution(self, sequence=None, sequence_list=None, **kw): def stepVerifyEmailedDocumentInitialContribution(self, sequence=None, sequence_list=None, **kw):
""" """
Verify contributed for initial time document per email. Verify contributed for initial time document per email.
""" """
attachment_list, ingested_document = self.verifyEmailedDocument() _, ingested_document = self.verifyEmailedDocument()
self.assertEqual('1', ingested_document.getRevision()) self.assertEqual('1', ingested_document.getRevision())
def stepVerifyEmailedDocumentMultipleContribution(self, sequence=None, sequence_list=None, **kw): def stepVerifyEmailedDocumentMultipleContribution(self, sequence=None, sequence_list=None, **kw):
""" """
Verify contributed for multiple times document per email. Verify contributed for multiple times document per email.
""" """
attachment_list, ingested_document = self.verifyEmailedDocument() _, ingested_document = self.verifyEmailedDocument()
self.assertTrue(ingested_document.getRevision() > '1') self.assertTrue(ingested_document.getRevision() > '1')
def playSequence(self, step_list): def playSequence(self, step_list):
...@@ -1070,8 +1061,8 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -1070,8 +1061,8 @@ class TestIngestion(ERP5TypeTestCase):
'sxd' : 'Drawing', 'sxd' : 'Drawing',
'xxx' : 'File', 'xxx' : 'File',
} }
for type, portal_type in correct_type_mapping.items(): for type_, portal_type in correct_type_mapping.items():
filename = 'aaa.' + type filename = 'aaa.' + type_
self.assertEqual(reg.findPortalTypeName(filename=filename), self.assertEqual(reg.findPortalTypeName(filename=filename),
portal_type) portal_type)
...@@ -1450,8 +1441,7 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -1450,8 +1441,7 @@ class TestIngestion(ERP5TypeTestCase):
contribution_tool = getToolByName(portal, 'portal_contributions') contribution_tool = getToolByName(portal, 'portal_contributions')
# create an user to simulate upload from him # create an user to simulate upload from him
user = self.createUser(reference='contributor1') user = self.createUser(reference='contributor1')
assignment = self.createUserAssignment(user, \ self.createUserAssignment(user, dict(group='anybody',
dict(group='anybody',
function='musician/wind/saxophone', function='musician/wind/saxophone',
site='arctic/spitsbergen')) site='arctic/spitsbergen'))
portal.document_module.manage_setLocalRoles(user.Person_getUserId(), ['Assignor',]) portal.document_module.manage_setLocalRoles(user.Person_getUserId(), ['Assignor',])
...@@ -1901,7 +1891,7 @@ return result ...@@ -1901,7 +1891,7 @@ return result
path = makeFilePath('import_region_category.ods') path = makeFilePath('import_region_category.ods')
data = open(path, 'r').read() data = open(path, 'r').read()
document = self.portal.portal_contributions.newContent(filename='toto', self.portal.portal_contributions.newContent(filename='toto',
data=data, data=data,
reference='Custom.Reference') reference='Custom.Reference')
self.tic()# Discover metadata will delete first ingested document self.tic()# Discover metadata will delete first ingested document
...@@ -1954,7 +1944,7 @@ return result ...@@ -1954,7 +1944,7 @@ return result
path = makeFilePath('import_region_category.xls') path = makeFilePath('import_region_category.xls')
data = open(path, 'r').read() data = open(path, 'r').read()
document = self.portal.portal_contributions.newContent( self.portal.portal_contributions.newContent(
filename='import_region_category.xls', filename='import_region_category.xls',
data=data, data=data,
content_type='application/vnd.ms-excel', content_type='application/vnd.ms-excel',
...@@ -1972,7 +1962,7 @@ return result ...@@ -1972,7 +1962,7 @@ return result
path = makeFilePath('import_region_category.xls') path = makeFilePath('import_region_category.xls')
data = open(path, 'r').read() data = open(path, 'r').read()
document = self.portal.portal_contributions.newContent( self.portal.portal_contributions.newContent(
id='this_id', id='this_id',
filename='import_region_category.xls', filename='import_region_category.xls',
data=data, data=data,
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testIngestion</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5OOo.tests.testIngestion</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testIngestion</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
############################################################################## ##############################################################################
import unittest import unittest
from testIngestion import TestIngestion from erp5.component.test.testIngestion import TestIngestion
from Products.ERP5Type.tests.ERP5TypeTestCase import _getPersistentMemcachedServerDict from Products.ERP5Type.tests.ERP5TypeTestCase import _getPersistentMemcachedServerDict
class TestIngestionWithFlare(TestIngestion): class TestIngestionWithFlare(TestIngestion):
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testIngestionWithFlare</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5OOo.tests.testIngestionWithFlare</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testIngestionWithFlare</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
test.erp5.testDms test.erp5.testDms
test.erp5.testDmsWithFlare test.erp5.testDmsWithFlare
test.erp5.testERP5WebWithDms test.erp5.testERP5WebWithDms
test.erp5.testIngestion
test.erp5.testIngestionWithFlare
test.erp5.testOOoConversionCache test.erp5.testOOoConversionCache
test.erp5.testOOoConversionServerRetry test.erp5.testOOoConversionServerRetry
\ No newline at end of file
erp5_full_text_mroonga_catalog erp5_full_text_mroonga_catalog
erp5_ingestion_mysql_innodb_catalog erp5_ingestion_mysql_innodb_catalog
erp5_core_proxy_field_legacy
\ No newline at end of file
...@@ -40,7 +40,7 @@ class TestFormPrintoutMixin(ERP5TypeTestCase): ...@@ -40,7 +40,7 @@ class TestFormPrintoutMixin(ERP5TypeTestCase):
def getBusinessTemplateList(self): def getBusinessTemplateList(self):
return ('erp5_base', 'erp5_ui_test', 'erp5_odt_style') return ('erp5_base', 'erp5_ui_test', 'erp5_odt_style')
def login(self): def login(self, *args, **kw):
uf = self.getPortal().acl_users uf = self.getPortal().acl_users
uf._doAddUser('zope', '', ['Manager'], []) uf._doAddUser('zope', '', ['Manager'], [])
user = uf.getUserById('zope').__of__(uf) user = uf.getUserById('zope').__of__(uf)
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Module Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>TestFormPrintoutMixin</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5OOo.tests.TestFormPrintoutMixin</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>module.erp5.TestFormPrintoutMixin</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Module Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -28,8 +28,9 @@ ...@@ -28,8 +28,9 @@
############################################################################## ##############################################################################
import unittest import unittest
from Products.ERP5OOo.tests.TestFormPrintoutMixin import TestFormPrintoutMixin import Products.ERP5
from Products.ERP5OOo.OOoUtils import OOoBuilder from erp5.component.module.TestFormPrintoutMixin import TestFormPrintoutMixin
from erp5.component.module.OOoUtils import OOoBuilder
from Products.ERP5OOo.tests.utils import Validator from Products.ERP5OOo.tests.utils import Validator
from Products.ERP5Type.tests.utils import FileUpload from Products.ERP5Type.tests.utils import FileUpload
from lxml import etree from lxml import etree
...@@ -56,12 +57,13 @@ class TestFormPrintoutAsODG(TestFormPrintoutMixin): ...@@ -56,12 +57,13 @@ class TestFormPrintoutAsODG(TestFormPrintoutMixin):
def afterSetUp(self): def afterSetUp(self):
self.login() self.login()
# XML validator # XML validator
v12schema_url = os.path.join(os.path.dirname(__file__), v12schema_url = os.path.join(os.path.dirname(Products.ERP5.__file__),
'test_data',
'OpenDocument-v1.2-os-schema.rng') 'OpenDocument-v1.2-os-schema.rng')
self.validator = Validator(schema_url=v12schema_url) self.validator = Validator(schema_url=v12schema_url)
foo_file_path = os.path.join(os.path.dirname(__file__), foo_file_path = os.path.join(os.path.dirname(Products.ERP5.__file__),
'test_document', 'test_data',
'Foo_001.odg') 'Foo_001.odg')
foo_file = open(foo_file_path, 'rb') foo_file = open(foo_file_path, 'rb')
self._validate(foo_file.read()) self._validate(foo_file.read())
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testFormPrintoutAsODG</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5OOo.tests.testFormPrintoutAsODG</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testFormPrintoutAsODG</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -30,11 +30,12 @@ ...@@ -30,11 +30,12 @@
############################################################################## ##############################################################################
import unittest import unittest
import Products.ERP5
from unittest import skip from unittest import skip
from Products.ERP5OOo.tests.TestFormPrintoutMixin import TestFormPrintoutMixin from erp5.component.module.TestFormPrintoutMixin import TestFormPrintoutMixin
from Products.ERP5Type.tests.utils import createZODBPythonScript from Products.ERP5Type.tests.utils import createZODBPythonScript
from Products.MimetypesRegistry.mime_types.magic import guessMime from Products.MimetypesRegistry.mime_types.magic import guessMime
from Products.ERP5OOo.OOoUtils import OOoBuilder from erp5.component.module.OOoUtils import OOoBuilder
from Products.ERP5OOo.tests.utils import Validator from Products.ERP5OOo.tests.utils import Validator
from Products.ERP5Type.tests.utils import FileUpload from Products.ERP5Type.tests.utils import FileUpload
from DateTime import DateTime from DateTime import DateTime
...@@ -52,27 +53,28 @@ class TestFormPrintoutAsODT(TestFormPrintoutMixin): ...@@ -52,27 +53,28 @@ class TestFormPrintoutAsODT(TestFormPrintoutMixin):
def afterSetUp(self): def afterSetUp(self):
self.login() self.login()
# XML validator # XML validator
v12schema_url = os.path.join(os.path.dirname(__file__), v12schema_url = os.path.join(os.path.dirname(Products.ERP5.__file__),
'test_data',
'OpenDocument-v1.2-os-schema.rng') 'OpenDocument-v1.2-os-schema.rng')
self.validator = Validator(schema_url=v12schema_url) self.validator = Validator(schema_url=v12schema_url)
foo_file_path = os.path.join(os.path.dirname(__file__), foo_file_path = os.path.join(os.path.dirname(Products.ERP5.__file__),
'test_document', 'test_data',
'Foo_001.odt') 'Foo_001.odt')
foo2_file_path = os.path.join(os.path.dirname(__file__), foo2_file_path = os.path.join(os.path.dirname(Products.ERP5.__file__),
'test_document', 'test_data',
'Foo_002.odt') 'Foo_002.odt')
foo3_file_path = os.path.join(os.path.dirname(__file__), foo3_file_path = os.path.join(os.path.dirname(Products.ERP5.__file__),
'test_document', 'test_data',
'Foo_003.odt') 'Foo_003.odt')
foo4_file_path = os.path.join(os.path.dirname(__file__), foo4_file_path = os.path.join(os.path.dirname(Products.ERP5.__file__),
'test_document', 'test_data',
'Foo_004.odt') 'Foo_004.odt')
foo5_file_path = os.path.join(os.path.dirname(__file__), foo5_file_path = os.path.join(os.path.dirname(Products.ERP5.__file__),
'test_document', 'test_data',
'Foo_005.odt') 'Foo_005.odt')
variable_file_path = os.path.join(os.path.dirname(__file__), variable_file_path = os.path.join(os.path.dirname(Products.ERP5.__file__),
'test_document', 'test_data',
'Foo_001_with_variable.odt') 'Foo_001_with_variable.odt')
foo_file = open(foo_file_path, 'rb') foo_file = open(foo_file_path, 'rb')
foo2_file = open(foo2_file_path, 'rb') foo2_file = open(foo2_file_path, 'rb')
...@@ -154,7 +156,7 @@ class TestFormPrintoutAsODT(TestFormPrintoutMixin): ...@@ -154,7 +156,7 @@ class TestFormPrintoutAsODT(TestFormPrintoutMixin):
self.assertEqual(request.RESPONSE.getHeader('content-disposition'), self.assertEqual(request.RESPONSE.getHeader('content-disposition'),
'inline;filename="Foo_viewAsPrintout.odt"') 'inline;filename="Foo_viewAsPrintout.odt"')
self._validate(odf_document) self._validate(odf_document)
pdf_document = foo_printout.index_html(REQUEST=request, format='pdf') foo_printout.index_html(REQUEST=request, format='pdf')
self.assertEqual(request.RESPONSE.getHeader('content-type'), self.assertEqual(request.RESPONSE.getHeader('content-type'),
'application/pdf') 'application/pdf')
self.assertEqual(request.RESPONSE.getHeader('content-disposition'), self.assertEqual(request.RESPONSE.getHeader('content-disposition'),
...@@ -505,7 +507,6 @@ class TestFormPrintoutAsODT(TestFormPrintoutMixin): ...@@ -505,7 +507,6 @@ class TestFormPrintoutAsODT(TestFormPrintoutMixin):
test1 = self.portal.foo_module.test1 test1 = self.portal.foo_module.test1
foo_printout = test1.Foo_viewAsPrintout foo_printout = test1.Foo_viewAsPrintout
foo_form = test1.Foo_view foo_form = test1.Foo_view
listbox = foo_form.listbox
request = self.app.REQUEST request = self.app.REQUEST
request['here'] = test1 request['here'] = test1
...@@ -564,7 +565,6 @@ class TestFormPrintoutAsODT(TestFormPrintoutMixin): ...@@ -564,7 +565,6 @@ class TestFormPrintoutAsODT(TestFormPrintoutMixin):
test1 = self.portal.foo_module.test1 test1 = self.portal.foo_module.test1
foo_printout = test1.Foo_viewAsPrintout foo_printout = test1.Foo_viewAsPrintout
foo_form = test1.Foo_view foo_form = test1.Foo_view
listbox = foo_form.listbox
request = self.app.REQUEST request = self.app.REQUEST
request['here'] = test1 request['here'] = test1
...@@ -685,7 +685,6 @@ class TestFormPrintoutAsODT(TestFormPrintoutMixin): ...@@ -685,7 +685,6 @@ class TestFormPrintoutAsODT(TestFormPrintoutMixin):
test1 = self.portal.foo_module.test1 test1 = self.portal.foo_module.test1
foo_printout = test1.Foo_viewAsPrintout foo_printout = test1.Foo_viewAsPrintout
foo_form = test1.Foo_view foo_form = test1.Foo_view
listbox = foo_form.listbox
request = self.app.REQUEST request = self.app.REQUEST
request['here'] = test1 request['here'] = test1
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testFormPrintoutAsODT</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5OOo.tests.testFormPrintoutAsODT</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testFormPrintoutAsODT</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
module.erp5.TestFormPrintoutMixin
\ No newline at end of file
test.erp5.testFormPrintoutAsODG
test.erp5.testFormPrintoutAsODT
\ No newline at end of file
erp5_full_text_mroonga_catalog
erp5_base
erp5_ui_test
\ No newline at end of file
...@@ -34,11 +34,12 @@ from AccessControl.SecurityManagement import newSecurityManager ...@@ -34,11 +34,12 @@ from AccessControl.SecurityManagement import newSecurityManager
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import FileUpload from Products.ERP5Type.tests.utils import FileUpload
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5OOo.OOoUtils import OOoParser from erp5.component.module.OOoUtils import OOoParser
from DateTime import DateTime from DateTime import DateTime
def makeFilePath(name): def makeFilePath(name):
return os.path.join(os.path.dirname(__file__), 'test_document', name) import Products.ERP5
return os.path.join(os.path.dirname(Products.ERP5.__file__), 'test_data', name)
def makeFileUpload(name): def makeFileUpload(name):
path = makeFilePath(name) path = makeFilePath(name)
...@@ -887,7 +888,7 @@ class TestOOoImport(TestOOoImportMixin): ...@@ -887,7 +888,7 @@ class TestOOoImport(TestOOoImportMixin):
parser.openFile(open(makeFilePath('import_big_spreadsheet.ods'), 'rb')) parser.openFile(open(makeFilePath('import_big_spreadsheet.ods'), 'rb'))
mapping = parser.getSpreadsheetsMapping() mapping = parser.getSpreadsheetsMapping()
not_ok = 1 not_ok = 1
for spread, values in mapping.iteritems(): for _, values in mapping.iteritems():
self.assertEqual(len(values), 41001) self.assertEqual(len(values), 41001)
not_ok = 0 not_ok = 0
if not_ok: if not_ok:
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testOOoImport</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5OOo.tests.testOOoImport</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testOOoImport</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
test.erp5.testOOoImport
\ No newline at end of file
erp5_full_text_mroonga_catalog
erp5_base
erp5_web
\ No newline at end of file
...@@ -38,6 +38,7 @@ from zope.tal.talinterpreter import FasterStringIO ...@@ -38,6 +38,7 @@ from zope.tal.talinterpreter import FasterStringIO
from Products.ERP5Type import PropertySheet from Products.ERP5Type import PropertySheet
from urllib import quote from urllib import quote
from Products.ERP5Type.Globals import InitializeClass, DTMLFile from Products.ERP5Type.Globals import InitializeClass, DTMLFile
from Products.ERP5 import _dtmldir
from Acquisition import aq_base from Acquisition import aq_base
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from erp5.component.module.OOoUtils import OOoBuilder from erp5.component.module.OOoUtils import OOoBuilder
...@@ -45,6 +46,8 @@ from zipfile import ZipFile, ZIP_DEFLATED ...@@ -45,6 +46,8 @@ from zipfile import ZipFile, ZIP_DEFLATED
from cStringIO import StringIO from cStringIO import StringIO
import re import re
import itertools import itertools
import os.path
import Products.ERP5
try: try:
# pylint: disable=no-name-in-module,unused-import # pylint: disable=no-name-in-module,unused-import
...@@ -58,7 +61,7 @@ from lxml import etree ...@@ -58,7 +61,7 @@ from lxml import etree
from lxml.etree import Element from lxml.etree import Element
# Constructors # Constructors
manage_addOOoTemplate = DTMLFile("dtml/OOoTemplate_add", globals()) manage_addOOoTemplate = DTMLFile("dtml/OOoTemplate_add", _dtmldir)
def addOOoTemplate(self, id, title="", xml_file_id="content.xml", REQUEST=None): # pylint: disable=redefined-builtin def addOOoTemplate(self, id, title="", xml_file_id="content.xml", REQUEST=None): # pylint: disable=redefined-builtin
"""Add OOo template to folder. """Add OOo template to folder.
...@@ -145,7 +148,7 @@ class OOoTemplate(Base, ZopePageTemplate): ...@@ -145,7 +148,7 @@ class OOoTemplate(Base, ZopePageTemplate):
""" """
meta_type = "ERP5 OOo Template" meta_type = "ERP5 OOo Template"
portal_type = "OOo Template" portal_type = "OOo Template"
icon = "www/OOo.png" icon = os.path.join(os.path.dirname(Products.ERP5.__file__), "www", "OOo.png")
# NOTE: 100 is just pure random starting number # NOTE: 100 is just pure random starting number
# it won't influence the code at all # it won't influence the code at all
...@@ -176,7 +179,8 @@ class OOoTemplate(Base, ZopePageTemplate): ...@@ -176,7 +179,8 @@ class OOoTemplate(Base, ZopePageTemplate):
) )
security.declareProtected('View management screens', 'formSettings') security.declareProtected('View management screens', 'formSettings')
formSettings = PageTemplateFile('www/formSettings', globals(), formSettings = PageTemplateFile(
os.path.join(os.path.dirname(Products.ERP5.__file__), 'www', 'formSettings'),
__name__='formSettings') __name__='formSettings')
formSettings._owner = None formSettings._owner = None
......
...@@ -558,3 +558,6 @@ allow_class(CorruptedOOoFile) ...@@ -558,3 +558,6 @@ allow_class(CorruptedOOoFile)
def newOOoParser(container): def newOOoParser(container):
return OOoParser().__of__(container) return OOoParser().__of__(container)
from AccessControl import ModuleSecurityInfo
ModuleSecurityInfo(__name__).declarePublic('OOoParser',)
ModuleSecurityInfo(__name__).declarePublic('newOOoParser',)
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
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