示例#1
0
    def test_xml_diff01(self):
        xml01 = '<?xml version="1.0" encoding="UTF-8"?><commands></commands>'
        xml02 = '<?xml version="1.0" encoding="UTF-8"?><commands />'
        self.assertIsNone(xml_diff(xml01, xml02))

        xml01 = u'<?xml version="1.0" encoding="utf-8"?><créer></créer>'
        xml02 = u'<?xml version="1.0" encoding="UTF-8"?><créer />'
        self.assertIsNone(xml_diff(xml01, xml02))
示例#2
0
 def test_xml_diff06(self):
     xml01 = ('<commands attr1="foo" attr2="bar">'
              '<create attr3="xxx" >'
              '</create>'
              '</commands>')
     xml02 = ('<commands attr2="bar" attr1="foo" >'
              '   <create attr3="xxx" />'
              '</commands>')
     self.assertIsNone(xml_diff(xml01, xml02))
示例#3
0
 def test_xml_diff12(self):
     "Missing tag"
     xml01 = ('<commands attr2="bar" attr1="foo" >'
              '   <create attr3="xxx" />'
              '   <update />'
              '</commands>')
     diff = xml_diff(xml01, '<commands attr2="bar" attr1="foo" />')
     self.assertIsNotNone(diff)
     self.assertEqual('<create> ===> Does not exist in second document',
                      diff.short_msg)
示例#4
0
 def test_xml_diff03(self):
     "Attributes value difference"
     diff = xml_diff('<commands attr1="foo" attr2="bar"></commands>',
                     '<commands attr2="bar" attr1="stuff" />')
     self.assertIsNotNone(diff)
     self.assertEqual('<commands> ===> Attribute "attr1": "foo" != "stuff"',
                      diff.short_msg)
     self.assertEqual(
         '<commands attr1="foo" attr2="bar">'
         ' -================= HERE : Attribute "attr1": "foo" != "stuff" ==========</commands>',
         diff.long_msg)
示例#5
0
 def test_xml_diff13(self):
     "Additional tags"
     xml02 = ('<commands attr2="bar" attr1="foo" >'
              '   <create attr3="xxx" />'
              '   <update />'
              '</commands>')
     diff = xml_diff('<commands attr2="bar" attr1="foo" />', xml02)
     self.assertIsNotNone(diff)
     self.assertEqual(
         '<commands> ===> Additional sibling or child element in the second document',
         diff.short_msg)
示例#6
0
 def test_xml_diff05(self):
     "Missing attribute"
     diff = xml_diff('<commands attr1="bar" attr2="stuff" />',
                     '<commands attr2="stuff" />')
     self.assertIsNotNone(diff)
     self.assertEqual(
         '<commands> ===> Attribute "attr1" is missing in the second document',
         diff.short_msg)
     self.assertEqual(
         '<commands attr1="bar" attr2="stuff"> -================= HERE : '
         'Attribute "attr1" is missing in the second document ==========</commands>',
         diff.long_msg)
示例#7
0
 def test_xml_diff14(self):
     "Tail difference"
     xml01 = ('<commands attr2="bar" attr1="foo" >'
              '   <create attr3="xxx" />My Tail'
              '   <update />'
              '</commands>')
     xml02 = ('<commands attr2="bar" attr1="foo" >'
              '   <create attr3="xxx" />'
              '   <update />'
              '</commands>')
     diff = xml_diff(xml01, xml02)
     self.assertIsNotNone(diff)
     self.assertEqual('<create> ===> Tail "My Tail" != ""', diff.short_msg)
示例#8
0
 def test_xml_diff11(self):
     "Text difference"
     xml01 = ('<commands attr2="bar" attr1="foo" >'
              '   <create attr3="xxx" />'
              '   <update />'
              '</commands>')
     xml02 = ('<commands attr2="bar" attr1="foo" >'
              '   <create attr3="xxx" />'
              '   <update>Text element</update>'
              '</commands>')
     diff = xml_diff(xml01, xml02)
     self.assertIsNotNone(diff)
     self.assertEqual('<update> ===> Text "" != "Text element"',
                      diff.short_msg)
示例#9
0
 def test_xml_diff08(self):
     "Missing child"
     xml01 = ('<commands attr1="foo" attr2="bar">\n'
              '   <create attr3="xxx" >\n'
              '      <update />'
              '   </create>\n'
              '</commands>')
     xml02 = ('<commands attr2="bar" attr1="foo" >'
              '   <create attr3="xxx" />'
              '   <update />'
              '</commands>')
     diff = xml_diff(xml01, xml02)
     self.assertIsNotNone(diff)
     self.assertEqual('<update> ===> Does not exist', diff.short_msg)
示例#10
0
 def test_xml_diff04(self):
     "Additional attribute"
     xml01 = ('<commands attr1="foo">\n' '    <create />\n' '</commands>')
     xml02 = ('<commands attr2="bar" attr1="foo" >'
              ' <create />'
              '</commands>')
     diff = xml_diff(xml01, xml02)
     self.assertIsNotNone(diff)
     self.assertEqual(
         '<commands> ===> Attribute "attr2" is missing in the first document',
         diff.short_msg)
     self.assertEqual(
         '<commands attr1="foo"> -================= HERE : '
         'Attribute "attr2" is missing in the first document ==========\n'
         '    <create />\n'
         '</commands>', diff.long_msg)
示例#11
0
 def test_xml_diff09(self):
     "Child becomes sibling"
     xml01 = ('<commands attr1="foo" attr2="bar">\n'
              '   <create attr3="xxx" >\n'
              '      <field name="uuid" />\n'
              '      <update />'
              '   </create>\n'
              '</commands>')
     xml02 = ('<commands attr2="bar" attr1="foo" >'
              '   <create attr3="xxx" >\n'
              '      <field name="uuid" />\n'
              '   </create>\n'
              '   <update />'
              '</commands>')
     diff = xml_diff(xml01, xml02)
     self.assertIsNotNone(diff)
     self.assertEqual('<update> ===> Does not exist', diff.short_msg)
示例#12
0
 def test_xml_diff07(self):
     "Tag difference"
     xml01 = ('<commands attr1="foo" attr2="bar">\n'
              '   <create attr3="xxx" >\n'
              '   </create>\n'
              '</commands>')
     xml02 = ('<commands attr2="bar" attr1="foo" >'
              '   <update />'
              '</commands>')
     diff = xml_diff(xml01, xml02)
     self.assertIsNotNone(diff)
     self.assertEqual('<create> ===> Tag "create" != "update"',
                      diff.short_msg)
     self.assertEqual(
         '<commands attr1="foo" attr2="bar">\n'
         '   <create attr3="xxx"> -================= HERE : Tag "create" != "update" ==========\n'
         '   </create>\n'
         '</commands>', diff.long_msg)
示例#13
0
 def test_xml_diff02(self):
     "Attributes order can vary"
     xml01 = ('<?xml version="1.0" encoding="UTF-8"?>'
              '<commands attr1="foo" attr2="bar"></commands>')
     self.assertIsNone(
         xml_diff(xml01, '<commands attr2="bar" attr1="foo" />'))