[Erp5-report] r42471 nicolas - in /erp5/trunk/utils/xupdate_processor/src/xupdate_processor...

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Jan 19 17:24:31 CET 2011


Author: nicolas
Date: Wed Jan 19 17:24:31 2011
New Revision: 42471

URL: http://svn.erp5.org?rev=42471&view=rev
Log:
Fix bug where append sub-elements where misordered

Modified:
    erp5/trunk/utils/xupdate_processor/src/xupdate_processor/content_handler.py
    erp5/trunk/utils/xupdate_processor/src/xupdate_processor/tests/xupdate_processor_test_suite.py

Modified: erp5/trunk/utils/xupdate_processor/src/xupdate_processor/content_handler.py
URL: http://svn.erp5.org/erp5/trunk/utils/xupdate_processor/src/xupdate_processor/content_handler.py?rev=42471&r1=42470&r2=42471&view=diff
==============================================================================
--- erp5/trunk/utils/xupdate_processor/src/xupdate_processor/content_handler.py [utf8] (original)
+++ erp5/trunk/utils/xupdate_processor/src/xupdate_processor/content_handler.py [utf8] Wed Jan 19 17:24:31 2011
@@ -213,6 +213,7 @@ class XUpdateHandler(ContentHandler):
       elif localname == 'element':
         node_stack_position = self._current_position_to_append_stack.pop()
         node_to_append_list = [self._node_stack.pop() for node in self._node_stack[node_stack_position:]]
+        node_to_append_list.reverse()
         node = self._node_stack[-1]
         node.extend(node_to_append_list)
         if len(node):

Modified: erp5/trunk/utils/xupdate_processor/src/xupdate_processor/tests/xupdate_processor_test_suite.py
URL: http://svn.erp5.org/erp5/trunk/utils/xupdate_processor/src/xupdate_processor/tests/xupdate_processor_test_suite.py?rev=42471&r1=42470&r2=42471&view=diff
==============================================================================
--- erp5/trunk/utils/xupdate_processor/src/xupdate_processor/tests/xupdate_processor_test_suite.py [utf8] (original)
+++ erp5/trunk/utils/xupdate_processor/src/xupdate_processor/tests/xupdate_processor_test_suite.py [utf8] Wed Jan 19 17:24:31 2011
@@ -453,6 +453,67 @@ class TestXUpdateProcessor(unittest.Test
     self._assertXUprocWorks(xml_xu_string, xml_doc_string,
                             expected_result_string)
 
+  def test_NodeCreationWithMultipleSubElements(self):
+    """check that creation of new node with multiple sub elements,
+    will not append them in reverse order
+    """
+    xml_doc_string = """
+<erp5>
+  <object portal_type="Test"/>
+  <object1/>
+  <object2/>
+  <object3/>
+</erp5>
+"""
+    xml_xu_string = """
+<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
+   <xupdate:insert-after select="/erp5/object[1]">
+    <xupdate:element name="workflow_action">
+      <xupdate:attribute name="id">edit_workflow</xupdate:attribute>
+      <action type="string">edit</action>
+      <comment type="None"/>
+      <error_message type="string"/>
+      <state type="string">current</state>
+    </xupdate:element>
+  </xupdate:insert-after>
+  <xupdate:insert-after select="/erp5/object1">
+    <action type="string">edit</action>
+    <comment type="None"/>
+    <error_message type="string"/>
+    <state type="string">current</state>
+  </xupdate:insert-after>
+  <xupdate:insert-before select="/erp5/object3">
+    <action type="string">edit</action>
+    <comment type="None"/>
+    <error_message type="string"/>
+    <state type="string">current</state>
+  </xupdate:insert-before>
+</xupdate:modifications>
+"""
+    expected_result_string =  """<erp5>
+  <object portal_type="Test"/>
+  <workflow_action id="edit_workflow">
+    <action type="string">edit</action>
+    <comment type="None"/>
+    <error_message type="string"/>
+    <state type="string">current</state>
+  </workflow_action>
+  <object1/>
+  <action type="string">edit</action>
+  <comment type="None"/>
+  <error_message type="string"/>
+  <state type="string">current</state>
+  <object2/>
+  <action type="string">edit</action>
+  <comment type="None"/>
+  <error_message type="string"/>
+  <state type="string">current</state>
+  <object3/>
+</erp5>
+"""
+    self._assertXUprocWorks(xml_xu_string, xml_doc_string,
+                            expected_result_string)
+
   def test_PI_and_Comments(self):
     """processing-instruction and comments
     """



More information about the Erp5-report mailing list