Commit 7c8f3fac authored by Fabien Morin's avatar Fabien Morin

- spread testFormPrintout.py in two parts : testFormPrintoutMixin and

testFormPrintout. This make possible to reuse some methods in
testFormPrintoutAsODG Class.
- fix a small issue in testFormPrintoutAsODG.py 


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@31253 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 17d830b3
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2009 Nexedi KK and Contributors. All Rights Reserved. # Copyright (c) 2009 Nexedi KK and Contributors. All Rights Reserved.
# Tatuya Kamada <tatuya@nexedi.com> # Tatuya Kamada <tatuya@nexedi.com>
# Fabien Morin <fabien@nexedi.com>
# #
# WARNING: This program as such is intended to be used by professional # WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential # programmers who take the whole responsibility of assessing all potential
...@@ -41,12 +42,41 @@ from StringIO import StringIO ...@@ -41,12 +42,41 @@ from StringIO import StringIO
from lxml import etree from lxml import etree
import os import os
# TODO : move code specific to ODT document to another file like class TestFormPrintoutMixin(ERP5TypeTestCase):
# testFormPrintoutAsODT which inherite from this class. run_all_test = 1
# This class should contain only common parts to all ODF type tests (odg, odt,
# ods, ...). def getBusinessTemplateList(self):
return ('erp5_base', 'erp5_ui_test', 'erp5_odt_style')
def login(self):
uf = self.getPortal().acl_users
uf._doAddUser('zope', '', ['Manager'], [])
user = uf.getUserById('zope').__of__(uf)
newSecurityManager(None, user)
def setSystemPreference(self):
default_pref = self.portal.portal_preferences.default_site_preference
default_pref.setPreferredOoodocServerAddress('127.0.0.1')
default_pref.setPreferredOoodocServerPortNumber('8008')
#default_pref.setPreferredConversionCacheFactory('document_cache_factory')
if default_pref.getPreferenceState() != 'global':
default_pref.enable()
def _validate(self, odf_file_data):
error_list = self.validator.validate(odf_file_data)
if error_list:
self.fail(''.join(error_list))
def getODFDocumentFromPrintout(self, printout_form):
'''return odf document from the printout
'''
document_file = getattr(self.portal, printout_form.template, None)
document_file = StringIO(document_file).read()
if document_file is not None:
return document_file
raise ValueError ('%s template not found' % printout_form.template)
class TestFormPrintout(ERP5TypeTestCase): class TestFormPrintout(TestFormPrintoutMixin):
run_all_test = 1 run_all_test = 1
def getTitle(self): def getTitle(self):
...@@ -55,9 +85,6 @@ class TestFormPrintout(ERP5TypeTestCase): ...@@ -55,9 +85,6 @@ class TestFormPrintout(ERP5TypeTestCase):
""" """
return "FormPrintout" return "FormPrintout"
def getBusinessTemplateList(self):
return ('erp5_base', 'erp5_ui_test', 'erp5_odt_style')
def afterSetUp(self): def afterSetUp(self):
self.login() self.login()
self.setSystemPreference() self.setSystemPreference()
...@@ -138,34 +165,6 @@ class TestFormPrintout(ERP5TypeTestCase): ...@@ -138,34 +165,6 @@ class TestFormPrintout(ERP5TypeTestCase):
transaction.commit() transaction.commit()
self.tic() self.tic()
def login(self):
uf = self.getPortal().acl_users
uf._doAddUser('tatuya', '', ['Manager'], [])
user = uf.getUserById('tatuya').__of__(uf)
newSecurityManager(None, user)
def setSystemPreference(self):
default_pref = self.portal.portal_preferences.default_site_preference
default_pref.setPreferredOoodocServerAddress('127.0.0.1')
default_pref.setPreferredOoodocServerPortNumber('8008')
#default_pref.setPreferredConversionCacheFactory('document_cache_factory')
if default_pref.getPreferenceState() != 'global':
default_pref.enable()
def _validate(self, odf_file_data):
error_list = self.validator.validate(odf_file_data)
if error_list:
self.fail(''.join(error_list))
def getODFDocumentFromPrintout(self, printout_form):
'''return odf document from the printout
'''
document_file = getattr(self.portal, printout_form.template, None)
document_file = StringIO(document_file).read()
if document_file is not None:
return document_file
raise ValueError ('%s template not found' % printout_form.template)
def test_01_Paragraph(self, run=run_all_test): def test_01_Paragraph(self, run=run_all_test):
""" """
mapping a field to a paragraph mapping a field to a paragraph
......
...@@ -30,13 +30,13 @@ ...@@ -30,13 +30,13 @@
import unittest import unittest
import transaction import transaction
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5OOo.tests.testFormPrintout import TestFormPrintout from Products.ERP5OOo.tests.testFormPrintout import TestFormPrintoutMixin
from Products.ERP5OOo.OOoUtils import OOoBuilder from Products.ERP5OOo.OOoUtils import OOoBuilder
from Products.ERP5OOo.tests.utils import Validator from Products.ERP5OOo.tests.utils import Validator
from lxml import etree from lxml import etree
import os import os
class TestFormPrintoutAsODG(TestFormPrintout): class TestFormPrintoutAsODG(TestFormPrintoutMixin):
run_all_test = 1 run_all_test = 1
def getTitle(self): def getTitle(self):
...@@ -123,8 +123,7 @@ class TestFormPrintoutAsODG(TestFormPrintout): ...@@ -123,8 +123,7 @@ class TestFormPrintoutAsODG(TestFormPrintout):
style_dict = {'{urn:oasis:names:tc:opendocument:xmlns:text:1.0}span': style_dict = {'{urn:oasis:names:tc:opendocument:xmlns:text:1.0}span':
{'{urn:oasis:names:tc:opendocument:xmlns:text:1.0}style-name': 'T2'}, {'{urn:oasis:names:tc:opendocument:xmlns:text:1.0}style-name': 'T2'},
'{urn:oasis:names:tc:opendocument:xmlns:text:1.0}p': '{urn:oasis:names:tc:opendocument:xmlns:text:1.0}p': {}
{'{urn:oasis:names:tc:opendocument:xmlns:text:1.0}style-name': 'P2'}
} }
# test target # test target
......
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