Ejemplo n.º 1
0
 def testOutput(self):
     listNode = self.d.getElementById("first")
     assert listNode, "Test %s failed" % outputNum
     liNodes = filter(lambda x: hasattr(x, 'tagName') and x.tagName == 'li', listNode.childNodes)
     assert len(liNodes) == len(self.m.data), "Test %s failed" % outputNum
     for i in range(len(liNodes)):
         sublistNode = domhelpers.getElementsByTagName(liNodes[i], 'ol')[0]
         subLiNodes = domhelpers.getElementsByTagName(sublistNode, 'li')
         assert len(self.m.data[i]) == len(subLiNodes)
Ejemplo n.º 2
0
    def testOutput(self):
        listNode = self.d.getElementById("first")
        assert listNode, "Test %s failed" % outputNum
        liNodes = filter(lambda x: hasattr(x, 'tagName') and x.tagName == 'li', listNode.childNodes)
#        print len(liNodes), len(self.m.data), liNodes, self.m.data
        assert len(liNodes) == len(self.m.data), "Test %s failed" % outputNum
        for i in range(len(liNodes)):
            sublistNode = domhelpers.getElementsByTagName(liNodes[i], 'ol')[0]
            subLiNodes = domhelpers.getElementsByTagName(sublistNode, 'li')
            assert len(self.m.data[i]) == len(subLiNodes)
Ejemplo n.º 3
0
 def testOutput(self):
     listNode = self.d.getElementById("first")
     assert listNode, "Test %s failed" % outputNum
     liNodes = filter(lambda x: hasattr(x, "tagName") and x.tagName == "li", listNode.childNodes)
     #        print len(liNodes), len(self.m.data), liNodes, self.m.data
     assert len(liNodes) == len(self.m.data), "Test %s failed" % outputNum
     for i in range(len(liNodes)):
         sublistNode = domhelpers.getElementsByTagName(liNodes[i], "ol")[0]
         subLiNodes = domhelpers.getElementsByTagName(sublistNode, "li")
         assert len(self.m.data[i]) == len(subLiNodes)
Ejemplo n.º 4
0
 def testOutput(self):
     listNode = self.d.getElementById("list")
     assert listNode, "Test %s failed; there was no element with the id 'list' in the output" % outputNum
     liNodes = domhelpers.getElementsByTagName(listNode, 'li')
     assert len(liNodes) == len(
         identityList
     ), "Test %s failed; the number of 'li' nodes did not match the list size" % outputNum
Ejemplo n.º 5
0
 def testComplexNotification(self):
     listNode = self.d.getElementById("theList")
     self.assert_(listNode, "Test %s failed" % outputNum)
     liNodes = domhelpers.getElementsByTagName(listNode, "li")
     self.assert_(liNodes, "DOM was not updated by notifying Widgets. Test %s" % outputNum)
     text = domhelpers.gatherTextNodes(liNodes[0])
     self.assert_(text.strip() == "test", "Wrong output: %s. Test %s" % (text, outputNum))
Ejemplo n.º 6
0
 def testOutput(self):
     listNode = self.d.getElementById("list")
     assert listNode, "Test %s failed; there was no element with the id 'list' in the output" % outputNum
     liNodes = domhelpers.getElementsByTagName(listNode, "li")
     assert len(liNodes) == len(identityList), (
         "Test %s failed; the number of 'li' nodes did not match the list size" % outputNum
     )
Ejemplo n.º 7
0
    def test_getElementsByTagName(self):
        doc1=microdom.parseString('<foo/>')
        actual=domhelpers.getElementsByTagName(doc1, 'foo')[0].nodeName
        expected='foo'
        self.assertEquals(actual, expected)
        el1=doc1.documentElement
        actual=domhelpers.getElementsByTagName(el1, 'foo')[0].nodeName
        self.assertEqual(actual, expected)

        doc2_xml='<a><foo in="a"/><b><foo in="b"/></b><c><foo in="c"/></c><foo in="d"/><foo in="ef"/><g><foo in="g"/><h><foo in="h"/></h></g></a>'
        doc2=microdom.parseString(doc2_xml)
        tag_list=domhelpers.getElementsByTagName(doc2, 'foo')
        actual=''.join([node.getAttribute('in') for node in tag_list])
        expected='abcdefgh'
        self.assertEquals(actual, expected)
        el2=doc2.documentElement
        tag_list=domhelpers.getElementsByTagName(el2, 'foo')
        actual=''.join([node.getAttribute('in') for node in tag_list])
        self.assertEqual(actual, expected)

        doc3_xml='''
<a><foo in="a"/>
    <b><foo in="b"/>
        <d><foo in="d"/>
            <g><foo in="g"/></g>
            <h><foo in="h"/></h>
        </d>
        <e><foo in="e"/>
            <i><foo in="i"/></i>
        </e>
    </b>
    <c><foo in="c"/>
        <f><foo in="f"/>
            <j><foo in="j"/></j>
        </f>
    </c>
</a>'''
        doc3=microdom.parseString(doc3_xml)
        tag_list=domhelpers.getElementsByTagName(doc3, 'foo')
        actual=''.join([node.getAttribute('in') for node in tag_list])
        expected='abdgheicfj'
        self.assertEquals(actual, expected)
        el3=doc3.documentElement
        tag_list=domhelpers.getElementsByTagName(el3, 'foo')
        actual=''.join([node.getAttribute('in') for node in tag_list])
        self.assertEqual(actual, expected)

        doc4_xml='<foo><bar></bar><baz><foo/></baz></foo>'
        doc4=microdom.parseString(doc4_xml)
        actual=domhelpers.getElementsByTagName(doc4, 'foo')
        root=doc4.documentElement
        expected=[root, root.lastChild().firstChild()]
        self.assertEquals(actual, expected)
        actual=domhelpers.getElementsByTagName(root, 'foo')
        self.assertEqual(actual, expected)
Ejemplo n.º 8
0
    def test_getElementsByTagName(self):
        doc1 = self.dom.parseString('<foo/>')
        actual = domhelpers.getElementsByTagName(doc1, 'foo')[0].nodeName
        expected = 'foo'
        self.assertEqual(actual, expected)
        el1 = doc1.documentElement
        actual = domhelpers.getElementsByTagName(el1, 'foo')[0].nodeName
        self.assertEqual(actual, expected)

        doc2_xml = '<a><foo in="a"/><b><foo in="b"/></b><c><foo in="c"/></c><foo in="d"/><foo in="ef"/><g><foo in="g"/><h><foo in="h"/></h></g></a>'
        doc2 = self.dom.parseString(doc2_xml)
        tag_list = domhelpers.getElementsByTagName(doc2, 'foo')
        actual = ''.join([node.getAttribute('in') for node in tag_list])
        expected = 'abcdefgh'
        self.assertEqual(actual, expected)
        el2 = doc2.documentElement
        tag_list = domhelpers.getElementsByTagName(el2, 'foo')
        actual = ''.join([node.getAttribute('in') for node in tag_list])
        self.assertEqual(actual, expected)

        doc3_xml = '''
<a><foo in="a"/>
    <b><foo in="b"/>
        <d><foo in="d"/>
            <g><foo in="g"/></g>
            <h><foo in="h"/></h>
        </d>
        <e><foo in="e"/>
            <i><foo in="i"/></i>
        </e>
    </b>
    <c><foo in="c"/>
        <f><foo in="f"/>
            <j><foo in="j"/></j>
        </f>
    </c>
</a>'''
        doc3 = self.dom.parseString(doc3_xml)
        tag_list = domhelpers.getElementsByTagName(doc3, 'foo')
        actual = ''.join([node.getAttribute('in') for node in tag_list])
        expected = 'abdgheicfj'
        self.assertEqual(actual, expected)
        el3 = doc3.documentElement
        tag_list = domhelpers.getElementsByTagName(el3, 'foo')
        actual = ''.join([node.getAttribute('in') for node in tag_list])
        self.assertEqual(actual, expected)

        doc4_xml = '<foo><bar></bar><baz><foo/></baz></foo>'
        doc4 = self.dom.parseString(doc4_xml)
        actual = domhelpers.getElementsByTagName(doc4, 'foo')
        root = doc4.documentElement
        expected = [root, root.childNodes[-1].childNodes[0]]
        self.assertEqual(actual, expected)
        actual = domhelpers.getElementsByTagName(root, 'foo')
        self.assertEqual(actual, expected)
Ejemplo n.º 9
0
 def testComplexNotification(self):
     listNode = self.d.getElementById("theList")
     self.assert_(listNode, "Test %s failed" % outputNum)
     liNodes = domhelpers.getElementsByTagName(listNode, 'li')
     self.assert_(liNodes,
      "DOM was not updated by notifying Widgets. Test %s" % outputNum)
     text = domhelpers.gatherTextNodes(liNodes[0])
     self.assert_(text.strip() == "test",
            "Wrong output: %s. Test %s" % (text, outputNum))