Commit 2387b8db authored by Nicolas Delaby's avatar Nicolas Delaby

test CheckBox replacement

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@31073 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent fca8c79d
...@@ -67,11 +67,15 @@ class TestFormPrintout(ERP5TypeTestCase): ...@@ -67,11 +67,15 @@ class TestFormPrintout(ERP5TypeTestCase):
'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(__file__),
'test_document', 'test_document',
'Foo_004.odt') 'Foo_004.odt')
foo5_file_path = os.path.join(os.path.dirname(__file__),
'test_document',
'Foo_005.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')
foo3_file = open(foo3_file_path, 'rb') foo3_file = open(foo3_file_path, 'rb')
foo4_file = open(foo4_file_path, 'rb') foo4_file = open(foo4_file_path, 'rb')
foo5_file = open(foo5_file_path, 'rb')
custom = self.portal.portal_skins.custom custom = self.portal.portal_skins.custom
addStyleSheet = custom.manage_addProduct['OFSP'].manage_addFile addStyleSheet = custom.manage_addProduct['OFSP'].manage_addFile
if custom._getOb('Foo_getODTStyleSheet', None) is None: if custom._getOb('Foo_getODTStyleSheet', None) is None:
...@@ -86,6 +90,9 @@ class TestFormPrintout(ERP5TypeTestCase): ...@@ -86,6 +90,9 @@ class TestFormPrintout(ERP5TypeTestCase):
if custom._getOb('Foo4_getODTStyleSheet', None) is None: if custom._getOb('Foo4_getODTStyleSheet', None) is None:
addStyleSheet(id='Foo4_getODTStyleSheet', file=foo4_file, title='', addStyleSheet(id='Foo4_getODTStyleSheet', file=foo4_file, title='',
precondition='', content_type = 'application/vnd.oasis.opendocument.text') precondition='', content_type = 'application/vnd.oasis.opendocument.text')
if custom._getOb('Foo5_getODTStyleSheet', None) is None:
addStyleSheet(id='Foo5_getODTStyleSheet', file=foo5_file, title='',
precondition='', content_type = 'application/vnd.oasis.opendocument.text')
erp5OOo = custom.manage_addProduct['ERP5OOo'] erp5OOo = custom.manage_addProduct['ERP5OOo']
addOOoTemplate = erp5OOo.addOOoTemplate addOOoTemplate = erp5OOo.addOOoTemplate
if custom._getOb('Foo_viewAsOdt', None) is None: if custom._getOb('Foo_viewAsOdt', None) is None:
...@@ -105,6 +112,9 @@ class TestFormPrintout(ERP5TypeTestCase): ...@@ -105,6 +112,9 @@ class TestFormPrintout(ERP5TypeTestCase):
if custom._getOb('FooReport_viewAsPrintout', None) is None: if custom._getOb('FooReport_viewAsPrintout', None) is None:
erp5OOo.addFormPrintout(id='FooReport_viewAsPrintout', erp5OOo.addFormPrintout(id='FooReport_viewAsPrintout',
title='') title='')
if custom._getOb('Foo5_viewAsPrintout', None) is None:
erp5OOo.addFormPrintout(id='Foo5_viewAsPrintout', title='',
form_name='Foo_view', template='Foo5_getODTStyleSheet')
## append 'test1' data to a listbox ## append 'test1' data to a listbox
foo_module = self.portal.foo_module foo_module = self.portal.foo_module
...@@ -1184,6 +1194,23 @@ return [] ...@@ -1184,6 +1194,23 @@ return []
#test_output.write(printout.data) #test_output.write(printout.data)
self.assertEqual('application/msword', guessMime(printout.data)) self.assertEqual('application/msword', guessMime(printout.data))
def test_09_FieldReplacement(self, run=run_all_test):
"""test field in ODF Documents"""
foo_printout = self.portal.foo_module.test1.Foo5_viewAsPrintout
foo_form = self.portal.foo_module.test1.Foo_view
field_name = 'your_checkbox'
if foo_form._getOb(field_name, None) is None:
foo_form.manage_addField(field_name, 'CheckBox', 'CheckBoxField')
checkbox = getattr(foo_form, field_name)
checkbox.values['default'] = 1
odf_document = foo_printout()
builder = OOoBuilder(odf_document)
content_xml = builder.extract("content.xml")
document_tree = etree.XML(content_xml)
node = document_tree.xpath('//form:checkbox[@form:name = "%s"]' % field_name, namespaces=document_tree.nsmap)[0]
self.assertTrue(node.get('{%s}current-state' % document_tree.nsmap['form']))
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
......
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