Commit ac8d33af authored by Arnaud Fontaine's avatar Arnaud Fontaine

Add test to check whether insert-{before,after} with same ids is working fine.

parent bf3d3747
......@@ -1112,5 +1112,79 @@ class TestERP5Diff(unittest.TestCase):
"""
self._assertERP5DiffWorks(old_xml, new_xml, expected_result_string)
def test_insert_element_with_same_id(self):
"""31. Insert elements with the same ids with the proper
indexes
"""
old_xml = """<erp5>
<object portal_type="Person" id="313730">
<workflow_action id="edit_workflow">
<time type="date">2011/11/22 18:12:58.767616 GMT+9</time>
</workflow_action>
<workflow_action id="edit_workflow">
<time type="date">2011/11/22 18:13:0.092858 GMT+9</time>
</workflow_action>
<workflow_action id="edit_workflow">
<time type="date">2011/11/22 18:13:4.909007 GMT+9</time>
</workflow_action>
</object>
</erp5>
"""
new_xml = """<erp5>
<object portal_type="Person" id="313730">
<workflow_action id="edit_workflow">
<time type="date">2011/11/22 18:06:58.767616 GMT+9</time>
</workflow_action>
<workflow_action id="edit_workflow">
<time type="date">2011/11/22 18:12:58.767616 GMT+9</time>
</workflow_action>
<workflow_action id="edit_workflow">
<time type="date">2011/11/22 18:13:0.092858 GMT+9</time>
</workflow_action>
<workflow_action id="edit_workflow">
<time type="date">2011/11/22 18:13:3.767616 GMT+9</time>
</workflow_action>
<workflow_action id="edit_workflow">
<time type="date">2011/11/22 18:13:4.909007 GMT+9</time>
</workflow_action>
<workflow_action id="edit_workflow">
<time type="date">2011/11/22 18:13:4.999999 GMT+9</time>
</workflow_action>
<workflow_action id="edit_workflow">
<time type="date">2011/11/22 18:13:14.767616 GMT+9</time>
</workflow_action>
</object>
</erp5>
"""
expected_result_string = """<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:insert-before select="/erp5/object[@id='313730']/workflow_action[@id='edit_workflow'][1]">
<xupdate:element name="workflow_action">
<xupdate:attribute name="id">edit_workflow</xupdate:attribute>
<time type="date">2011/11/22 18:06:58.767616 GMT+9</time>
</xupdate:element>
</xupdate:insert-before>
<xupdate:insert-before select="/erp5/object[@id='313730']/workflow_action[@id='edit_workflow'][4]">
<xupdate:element name="workflow_action">
<xupdate:attribute name="id">edit_workflow</xupdate:attribute>
<time type="date">2011/11/22 18:13:3.767616 GMT+9</time>
</xupdate:element>
</xupdate:insert-before>
<xupdate:insert-after select="/erp5/object[@id='313730']/workflow_action[@id='edit_workflow'][5]">
<xupdate:element name="workflow_action">
<xupdate:attribute name="id">edit_workflow</xupdate:attribute>
<time type="date">2011/11/22 18:13:4.999999 GMT+9</time>
</xupdate:element>
<xupdate:element name="workflow_action">
<xupdate:attribute name="id">edit_workflow</xupdate:attribute>
<time type="date">2011/11/22 18:13:14.767616 GMT+9</time>
</xupdate:element>
</xupdate:insert-after>
</xupdate:modifications>
"""
self._assertERP5DiffWorks(old_xml, new_xml, expected_result_string)
if __name__ == '__main__':
unittest.main()
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