Commit 2755a7be authored by Fabien Morin's avatar Fabien Morin

validate each original test document before to modify it


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@31221 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d8be00ad
...@@ -56,6 +56,11 @@ class TestFormPrintout(ERP5TypeTestCase): ...@@ -56,6 +56,11 @@ class TestFormPrintout(ERP5TypeTestCase):
def afterSetUp(self): def afterSetUp(self):
self.login() self.login()
self.setSystemPreference() self.setSystemPreference()
# XML validator
v12schema_url = os.path.join(os.path.dirname(__file__),
'OpenDocument-schema-v1.2-draft9.rng')
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(__file__),
'test_document', 'test_document',
'Foo_001.odt') 'Foo_001.odt')
...@@ -128,11 +133,6 @@ class TestFormPrintout(ERP5TypeTestCase): ...@@ -128,11 +133,6 @@ class TestFormPrintout(ERP5TypeTestCase):
transaction.commit() transaction.commit()
self.tic() self.tic()
# XML validator
v12schema_url = os.path.join(os.path.dirname(__file__),
'OpenDocument-schema-v1.2-draft9.rng')
self.validator = Validator(schema_url=v12schema_url)
def login(self): def login(self):
uf = self.getPortal().acl_users uf = self.getPortal().acl_users
uf._doAddUser('tatuya', '', ['Manager'], []) uf._doAddUser('tatuya', '', ['Manager'], [])
...@@ -153,6 +153,15 @@ class TestFormPrintout(ERP5TypeTestCase): ...@@ -153,6 +153,15 @@ class TestFormPrintout(ERP5TypeTestCase):
if error_list: if error_list:
self.fail(''.join(error_list)) self.fail(''.join(error_list))
def _validateFromPrintout(self, document, printout_form):
'''validate test document before to modify it
'''
document_file = getattr(document, printout_form.template, None)
if document_file is not None:
return self._validate(document_file.data)
raise ValueError ('%s template not found for %s' % (printout_form.template,
document))
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
...@@ -170,6 +179,7 @@ class TestFormPrintout(ERP5TypeTestCase): ...@@ -170,6 +179,7 @@ class TestFormPrintout(ERP5TypeTestCase):
# test target # test target
foo_printout = portal.foo_module.test1.Foo_viewAsPrintout foo_printout = portal.foo_module.test1.Foo_viewAsPrintout
self._validateFromPrintout(portal.foo_module.test1, foo_printout)
request = self.app.REQUEST request = self.app.REQUEST
# 1. Normal case: "my_title" field to the "my_title" reference in the ODF document # 1. Normal case: "my_title" field to the "my_title" reference in the ODF document
...@@ -860,6 +870,7 @@ return report_section_list ...@@ -860,6 +870,7 @@ return report_section_list
title='', title='',
form_name='FooReport_view', form_name='FooReport_view',
template='Foo2_getODTStyleSheet') template='Foo2_getODTStyleSheet')
self._validateFromPrintout(test1, foo_report_printout)
odf_document = foo_report_printout() odf_document = foo_report_printout()
#test_output = open("/tmp/test_04_Iteratoin.odf", "w") #test_output = open("/tmp/test_04_Iteratoin.odf", "w")
...@@ -964,6 +975,7 @@ return report_section_list ...@@ -964,6 +975,7 @@ return report_section_list
title='', title='',
form_name='FooReport_view', form_name='FooReport_view',
template='Foo3_getODTStyleSheet') template='Foo3_getODTStyleSheet')
self._validateFromPrintout(test1, foo_report_printout)
odf_document = foo_report_printout() odf_document = foo_report_printout()
#test_output = open("/tmp/test_04_Iteratoin_02_Section_01.odf", "w") #test_output = open("/tmp/test_04_Iteratoin_02_Section_01.odf", "w")
...@@ -1076,6 +1088,7 @@ return report_section_list ...@@ -1076,6 +1088,7 @@ return report_section_list
title='', title='',
form_name='Foo2_view', form_name='Foo2_view',
template='Foo4_getODTStyleSheet') template='Foo4_getODTStyleSheet')
self._validateFromPrintout(test1, foo_report_printout)
odf_document = foo_report_printout() odf_document = foo_report_printout()
# test_output = open("/tmp/test_04_Iteratoin_03_Section_01.odf", "w") # test_output = open("/tmp/test_04_Iteratoin_03_Section_01.odf", "w")
...@@ -1207,6 +1220,7 @@ return [] ...@@ -1207,6 +1220,7 @@ return []
def test_09_FieldReplacement(self, run=run_all_test): def test_09_FieldReplacement(self, run=run_all_test):
"""test field in ODF Documents""" """test field in ODF Documents"""
foo_printout = self.portal.foo_module.test1.Foo5_viewAsPrintout foo_printout = self.portal.foo_module.test1.Foo5_viewAsPrintout
self._validateFromPrintout(self.portal.foo_module.test1, foo_printout)
foo_form = self.portal.foo_module.test1.Foo_view foo_form = self.portal.foo_module.test1.Foo_view
field_name = 'your_checkbox' field_name = 'your_checkbox'
if foo_form._getOb(field_name, None) is None: if foo_form._getOb(field_name, None) is None:
......
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