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

WIP

parent 4645e7b4
......@@ -29,11 +29,12 @@
import unittest
import os
from Products.ERP5OOo.OOoUtils import OOoParser
from erp5.component.module.OOoUtils import OOoParser
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):
""" OOoParser tests
......@@ -45,7 +46,7 @@ class TestOOoParser(unittest.TestCase):
self.assertEqual(['Person'], mapping.keys())
person_mapping = mapping['Person']
self.assertTrue(isinstance(person_mapping, list))
self.assertTrue(102, len(person_mapping))
self.assertEqual(len(person_mapping), 102)
self.assertEqual(person_mapping[0],
['Title', 'First Name', 'Last Name', 'Default Email Text'])
self.assertEqual(person_mapping[1],
......@@ -99,7 +100,7 @@ class TestOOoParser(unittest.TestCase):
parser.openFile(open(makeFilePath('import_big_spreadsheet.ods'), 'rb'))
mapping = parser.getSpreadsheetsMapping()
not_ok = 1
for spread, values in mapping.iteritems():
for _, values in mapping.iteritems():
self.assertEqual(len(values), 41001)
not_ok = 0
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
test.erp5.testNotificationMessageModule
test.erp5.testNotificationTool
test.erp5.testOOoBatchMode
test.erp5.testOOoParser
test.erp5.testPerson
test.erp5.testQueryModule
test.erp5.testRestrictedPythonSecurity
......
......@@ -118,13 +118,13 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
def test_report_view(self):
self.loginAsUser('bob')
self.portal.changeSkin('Deferred')
response = self.publish(
self.publish(
'/%s/person_module/pers/Base_viewHistory?deferred_portal_skin=%s'
% (self.portal.getId(), self.skin), '%s:%s' % (self.username, self.password))
self.tic()
last_message = self.portal.MailHost._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])
mail_message = email.message_from_string(message_text)
for part in mail_message.walk():
......@@ -181,7 +181,7 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
self._defineSystemPreference()
self.loginAsUser('bob')
self.portal.changeSkin('Deferred')
response = self.publish(
self.publish(
'/%s/person_module/pers/Base_viewHistory?deferred_portal_skin=%s'
% (self.portal.getId(), self.skin), '%s:%s' % (self.username, self.password))
self.tic()
......@@ -189,7 +189,7 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
last_message = self.portal.MailHost._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])
mail_message = email.message_from_string(message_text)
for part in mail_message.walk():
......@@ -219,7 +219,7 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
self._defineSystemPreference("notification-deferred.report")
self.loginAsUser('bob')
self.portal.changeSkin('Deferred')
response = self.publish(
self.publish(
'/%s/person_module/pers/Base_viewHistory?deferred_portal_skin=%s'
% (self.portal.getId(), self.skin), '%s:%s' % (self.username, self.password))
self.tic()
......@@ -227,7 +227,7 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
last_message = self.portal.MailHost._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])
mail_message = email.message_from_string(message_text)
for part in mail_message.walk():
......@@ -242,7 +242,7 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
self._defineSystemPreference()
self.loginAsUser('bob')
self.portal.changeSkin('Deferred')
response = self.publish(
self.publish(
'/%s/person_module/pers/Base_viewHistory?deferred_portal_skin=%s&format=pdf'
% (self.portal.getId(), self.skin), '%s:%s' % (self.username, self.password))
self.tic()
......@@ -251,7 +251,7 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
last_message = self.portal.MailHost._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])
mail_message = email.message_from_string(message_text)
for part in mail_message.walk():
......@@ -266,7 +266,7 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
self.loginAsUser('bob')
# simulate a big request, for which Base_callDialogMethod will not issue a
# redirect
response = self.publish(
self.publish(
'/%s/person_module/pers/Base_callDialogMethod?deferred_portal_skin=%s&'
'dialog_method=Person_view&dialog_id=Person_view&'
'deferred_style:int=1&junk=%s' % (self.portal.getId(),
......@@ -276,7 +276,7 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
self.tic()
last_message = self.portal.MailHost._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])
mail_message = email.message_from_string(message_text)
for part in mail_message.walk():
......@@ -300,7 +300,7 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
# User's Accept-Language header is honored in reports.
self.loginAsUser('bob')
self.portal.changeSkin('Deferred')
response = self.publish(
self.publish(
'/%s/person_module/pers/Base_viewHistory?deferred_portal_skin=%s'
% (self.portal.getId(), self.skin),
'%s:%s' % (self.username, self.password),
......@@ -325,7 +325,7 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
# User's LOCALIZER_LANGUAGE cookie is honored in reports and have priority over Accept-Language
self.loginAsUser('bob')
self.portal.changeSkin('Deferred')
response = self.publish(
self.publish(
'/%s/person_module/pers/Base_viewHistory?deferred_portal_skin=%s'
% (self.portal.getId(), self.skin),
'%s:%s' % (self.username, self.password),
......@@ -366,13 +366,13 @@ class TestODSDeferredStyle(TestDeferredStyle):
"""
self.loginAsUser('bob')
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'
% (self.portal.getId(), self.skin), '%s:%s' % (self.username, self.password))
self.tic()
last_message = self.portal.MailHost._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])
mail_message = email.message_from_string(message_text)
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
<?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 @@
##############################################################################
import unittest
from testIngestion import TestIngestion
from erp5.component.test.testIngestion import TestIngestion
from Products.ERP5Type.tests.ERP5TypeTestCase import _getPersistentMemcachedServerDict
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.testDmsWithFlare
test.erp5.testERP5WebWithDms
test.erp5.testIngestion
test.erp5.testIngestionWithFlare
test.erp5.testOOoConversionCache
test.erp5.testOOoConversionServerRetry
\ No newline at end of file
erp5_full_text_mroonga_catalog
erp5_ingestion_mysql_innodb_catalog
\ No newline at end of file
erp5_ingestion_mysql_innodb_catalog
erp5_core_proxy_field_legacy
\ No newline at end of file
......@@ -40,7 +40,7 @@ class TestFormPrintoutMixin(ERP5TypeTestCase):
def getBusinessTemplateList(self):
return ('erp5_base', 'erp5_ui_test', 'erp5_odt_style')
def login(self):
def login(self, *args, **kw):
uf = self.getPortal().acl_users
uf._doAddUser('zope', '', ['Manager'], [])
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 @@
##############################################################################
import unittest
from Products.ERP5OOo.tests.TestFormPrintoutMixin import TestFormPrintoutMixin
from Products.ERP5OOo.OOoUtils import OOoBuilder
import Products.ERP5
from erp5.component.module.TestFormPrintoutMixin import TestFormPrintoutMixin
from erp5.component.module.OOoUtils import OOoBuilder
from Products.ERP5OOo.tests.utils import Validator
from Products.ERP5Type.tests.utils import FileUpload
from lxml import etree
......@@ -56,12 +57,13 @@ class TestFormPrintoutAsODG(TestFormPrintoutMixin):
def afterSetUp(self):
self.login()
# 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')
self.validator = Validator(schema_url=v12schema_url)
foo_file_path = os.path.join(os.path.dirname(__file__),
'test_document',
foo_file_path = os.path.join(os.path.dirname(Products.ERP5.__file__),
'test_data',
'Foo_001.odg')
foo_file = open(foo_file_path, 'rb')
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 @@
##############################################################################
import unittest
import Products.ERP5
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.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.ERP5Type.tests.utils import FileUpload
from DateTime import DateTime
......@@ -52,27 +53,28 @@ class TestFormPrintoutAsODT(TestFormPrintoutMixin):
def afterSetUp(self):
self.login()
# 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')
self.validator = Validator(schema_url=v12schema_url)
foo_file_path = os.path.join(os.path.dirname(__file__),
'test_document',
foo_file_path = os.path.join(os.path.dirname(Products.ERP5.__file__),
'test_data',
'Foo_001.odt')
foo2_file_path = os.path.join(os.path.dirname(__file__),
'test_document',
foo2_file_path = os.path.join(os.path.dirname(Products.ERP5.__file__),
'test_data',
'Foo_002.odt')
foo3_file_path = os.path.join(os.path.dirname(__file__),
'test_document',
foo3_file_path = os.path.join(os.path.dirname(Products.ERP5.__file__),
'test_data',
'Foo_003.odt')
foo4_file_path = os.path.join(os.path.dirname(__file__),
'test_document',
foo4_file_path = os.path.join(os.path.dirname(Products.ERP5.__file__),
'test_data',
'Foo_004.odt')
foo5_file_path = os.path.join(os.path.dirname(__file__),
'test_document',
foo5_file_path = os.path.join(os.path.dirname(Products.ERP5.__file__),
'test_data',
'Foo_005.odt')
variable_file_path = os.path.join(os.path.dirname(__file__),
'test_document',
variable_file_path = os.path.join(os.path.dirname(Products.ERP5.__file__),
'test_data',
'Foo_001_with_variable.odt')
foo_file = open(foo_file_path, 'rb')
foo2_file = open(foo2_file_path, 'rb')
......@@ -154,7 +156,7 @@ class TestFormPrintoutAsODT(TestFormPrintoutMixin):
self.assertEqual(request.RESPONSE.getHeader('content-disposition'),
'inline;filename="Foo_viewAsPrintout.odt"')
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'),
'application/pdf')
self.assertEqual(request.RESPONSE.getHeader('content-disposition'),
......@@ -505,7 +507,6 @@ class TestFormPrintoutAsODT(TestFormPrintoutMixin):
test1 = self.portal.foo_module.test1
foo_printout = test1.Foo_viewAsPrintout
foo_form = test1.Foo_view
listbox = foo_form.listbox
request = self.app.REQUEST
request['here'] = test1
......@@ -564,7 +565,6 @@ class TestFormPrintoutAsODT(TestFormPrintoutMixin):
test1 = self.portal.foo_module.test1
foo_printout = test1.Foo_viewAsPrintout
foo_form = test1.Foo_view
listbox = foo_form.listbox
request = self.app.REQUEST
request['here'] = test1
......@@ -685,7 +685,6 @@ class TestFormPrintoutAsODT(TestFormPrintoutMixin):
test1 = self.portal.foo_module.test1
foo_printout = test1.Foo_viewAsPrintout
foo_form = test1.Foo_view
listbox = foo_form.listbox
request = self.app.REQUEST
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
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import FileUpload
from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5OOo.OOoUtils import OOoParser
from erp5.component.module.OOoUtils import OOoParser
from DateTime import DateTime
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):
path = makeFilePath(name)
......@@ -887,7 +888,7 @@ class TestOOoImport(TestOOoImportMixin):
parser.openFile(open(makeFilePath('import_big_spreadsheet.ods'), 'rb'))
mapping = parser.getSpreadsheetsMapping()
not_ok = 1
for spread, values in mapping.iteritems():
for _, values in mapping.iteritems():
self.assertEqual(len(values), 41001)
not_ok = 0
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
from Products.ERP5Type import PropertySheet
from urllib import quote
from Products.ERP5Type.Globals import InitializeClass, DTMLFile
from Products.ERP5 import _dtmldir
from Acquisition import aq_base
from AccessControl import ClassSecurityInfo
from erp5.component.module.OOoUtils import OOoBuilder
......@@ -45,6 +46,8 @@ from zipfile import ZipFile, ZIP_DEFLATED
from cStringIO import StringIO
import re
import itertools
import os.path
import Products.ERP5
try:
# pylint: disable=no-name-in-module,unused-import
......@@ -58,7 +61,7 @@ from lxml import etree
from lxml.etree import Element
# 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
"""Add OOo template to folder.
......@@ -145,7 +148,7 @@ class OOoTemplate(Base, ZopePageTemplate):
"""
meta_type = "ERP5 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
# it won't influence the code at all
......@@ -176,8 +179,9 @@ class OOoTemplate(Base, ZopePageTemplate):
)
security.declareProtected('View management screens', 'formSettings')
formSettings = PageTemplateFile('www/formSettings', globals(),
__name__='formSettings')
formSettings = PageTemplateFile(
os.path.join(os.path.dirname(Products.ERP5.__file__), 'www', 'formSettings'),
__name__='formSettings')
formSettings._owner = None
def __init__(self, id, title='', *args, **kw): # pylint: disable=redefined-builtin
......
......@@ -558,3 +558,6 @@ allow_class(CorruptedOOoFile)
def newOOoParser(container):
return OOoParser().__of__(container)
from AccessControl import ModuleSecurityInfo
ModuleSecurityInfo(__name__).declarePublic('OOoParser',)
ModuleSecurityInfo(__name__).declarePublic('newOOoParser',)
\ No newline at end of file
This diff is collapsed.
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