From 3f9f68eb138b3b6790cb8067ed5a2a8a1d4961a2 Mon Sep 17 00:00:00 2001
From: Nicolas Delaby <nicolas@nexedi.com>
Date: Thu, 28 Jan 2010 15:31:49 +0000
Subject: [PATCH] Add skip decorator for test_09 and validate ODF against
 RelaxNG only for this test. OOo does not produce compliant xml, and RelaxNG
 istself is still draft. So, validation fails even with unmodified xml.
 reviewed by Seb

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32065 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../ERP5OOo/tests/testFormPrintoutAsODT.py    | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/product/ERP5OOo/tests/testFormPrintoutAsODT.py b/product/ERP5OOo/tests/testFormPrintoutAsODT.py
index 36bf38067f..0ad74e7eec 100644
--- a/product/ERP5OOo/tests/testFormPrintoutAsODT.py
+++ b/product/ERP5OOo/tests/testFormPrintoutAsODT.py
@@ -32,6 +32,7 @@
 import unittest
 import transaction
 from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
+from Products.ERP5Type.tests.backportUnittest import skip
 from Products.ERP5OOo.tests.testFormPrintout import TestFormPrintoutMixin
 from Products.ERP5Type.tests.utils import createZODBPythonScript
 from Products.MimetypesRegistry.mime_types.magic import guessMime
@@ -1156,10 +1157,11 @@ return []
     #test_output.write(printout.data)
     self.assertEqual('application/msword', guessMime(printout.data))
 
-  def test_09_FieldReplacement(self):
+  def test_09_FieldReplacement(self, validate=False):
     """test field in ODF Documents"""
     foo_printout = self.portal.foo_module.test1.Foo5_viewAsPrintout
-    self._validate(self.getODFDocumentFromPrintout(foo_printout))
+    if validate:
+      self._validate(self.getODFDocumentFromPrintout(foo_printout))
     foo_form = self.portal.foo_module.test1.Foo_view
     field_name = 'your_checkbox'
     if foo_form._getOb(field_name, None) is None:
@@ -1168,7 +1170,8 @@ return []
 
     checkbox.values['default'] = 1
     odf_document = foo_printout(self.portal.REQUEST)
-    self._validate(odf_document)
+    if validate:
+      self._validate(odf_document)
     builder = OOoBuilder(odf_document)
     content_xml = builder.extract("content.xml")
     document_tree = etree.XML(content_xml)
@@ -1177,13 +1180,21 @@ return []
 
     checkbox.values['default'] = 0
     odf_document = foo_printout(self.portal.REQUEST)
-    self._validate(odf_document)
+    if validate:
+      self._validate(odf_document)
     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.assertFalse(node.get('{%s}current-state' % document_tree.nsmap['form']))
 
+  @skip('Disable validation because OOo does not produce compliant'\
+        ' xml, and RelaxNG status is still draft')
+  def test_09_FieldReplacementWithValidation(self):
+    """
+    """
+    return self.test_09_FieldReplacement(validate=True)
+
 def test_suite():
   suite = unittest.TestSuite()
   suite.addTest(unittest.makeSuite(TestFormPrintoutAsODT))
-- 
2.30.9