예제 #1
0
 def test_find_first_nested(self):
     XML = u'''<?xml version="1.0" ?>
     <topelement>
       <subelement id="1">
           <subelement id="2"/>
       </subelement>
     </topelement>
     '''
     dom = vmxml.parse_xml(XML)
     sub1 = vmxml.find_first(dom, 'subelement')  # outermost
     sub2 = vmxml.find_first(sub1, 'subelement')  # innermost
     last = vmxml.find_first(sub2, 'subelement')
     self.assertIsNot(sub2, last)
예제 #2
0
파일: vmXmlTests.py 프로젝트: bronhaim/vdsm
 def test_remove_child(self):
     top = vmxml.find_first(self._dom, 'topelement')
     hello = list(vmxml.find_all(top, 'hello'))
     old = hello[1]
     vmxml.remove_child(top, old)
     updated_hello = list(vmxml.find_all(top, 'hello'))
     hello = hello[:1] + hello[2:]
     self.assertEqual(updated_hello, hello)
예제 #3
0
파일: vmXmlTests.py 프로젝트: bronhaim/vdsm
 def test_find_all(self, start_tag, tag, number):
     dom = self._dom
     if start_tag is not None:
         dom = vmxml.find_first(self._dom, 'topelement')
     elements = vmxml.find_all(dom, tag)
     matches = [vmxml.tag(e) == tag for e in elements]
     self.assertTrue(all(matches))
     self.assertEqual(len(matches), number)
예제 #4
0
 def test_remove_child(self):
     top = vmxml.find_first(self._dom, 'topelement')
     hello = list(vmxml.find_all(top, 'hello'))
     old = hello[1]
     vmxml.remove_child(top, old)
     updated_hello = list(vmxml.find_all(top, 'hello'))
     hello = hello[:1] + hello[2:]
     self.assertEqual(updated_hello, hello)
예제 #5
0
 def test_find_all(self, start_tag, tag, number):
     dom = self._dom
     if start_tag is not None:
         dom = vmxml.find_first(self._dom, 'topelement')
     elements = vmxml.find_all(dom, tag)
     matches = [vmxml.tag(e) == tag for e in elements]
     self.assertTrue(all(matches))
     self.assertEqual(len(matches), number)
예제 #6
0
파일: vmXmlTests.py 프로젝트: bronhaim/vdsm
 def test_append_child(self):
     empty = vmxml.find_first(self._dom, 'empty')
     vmxml.append_child(empty, vmxml.Element('new'))
     self.assertIsNotNone(vmxml.find_first(self._dom, 'new', None))
     empty = vmxml.find_first(self._dom, 'empty')
     self.assertIsNotNone(vmxml.find_first(empty, 'new', None))
예제 #7
0
파일: vmXmlTests.py 프로젝트: bronhaim/vdsm
 def test_children(self, start_tag, tag, number):
     element = vmxml.find_first(self._dom, start_tag)
     self.assertEqual(len(list(vmxml.children(element, tag))), number)
예제 #8
0
파일: vmXmlTests.py 프로젝트: bronhaim/vdsm
 def test_text(self, tag, result):
     element = vmxml.find_first(self._dom, tag)
     text = vmxml.text(element)
     self.assertEqual(text, result)
예제 #9
0
 def test_append_child(self):
     empty = vmxml.find_first(self._dom, 'empty')
     vmxml.append_child(empty, vmxml.Element('new'))
     self.assertIsNotNone(vmxml.find_first(self._dom, 'new', None))
     empty = vmxml.find_first(self._dom, 'empty')
     self.assertIsNotNone(vmxml.find_first(empty, 'new', None))
예제 #10
0
 def test_children(self, start_tag, tag, number):
     element = vmxml.find_first(self._dom, start_tag)
     self.assertEqual(len(list(vmxml.children(element, tag))), number)
예제 #11
0
 def test_text(self, tag, result):
     element = vmxml.find_first(self._dom, tag)
     text = vmxml.text(element)
     self.assertEqual(text, result)