def test_setIndexLink(self): """ Tests to make sure that index links are processed when an index page exists and removed when there is not. """ templ = dom.parse(open(d["template"])) indexFilename = "theIndexFile" numLinks = len(domhelpers.findElementsWithAttribute(templ, "class", "index-link")) # if our testing template has no index-link nodes, complain about it self.assertNotEquals([], domhelpers.findElementsWithAttribute(templ, "class", "index-link")) tree.setIndexLink(templ, indexFilename) self.assertEquals([], domhelpers.findElementsWithAttribute(templ, "class", "index-link")) indexLinks = domhelpers.findElementsWithAttribute(templ, "href", indexFilename) self.assertTrue(len(indexLinks) >= numLinks) templ = dom.parse(open(d["template"])) self.assertNotEquals([], domhelpers.findElementsWithAttribute(templ, "class", "index-link")) indexFilename = None tree.setIndexLink(templ, indexFilename) self.assertEquals([], domhelpers.findElementsWithAttribute(templ, "class", "index-link"))
def test_setIndexLink(self): """ Tests to make sure that index links are processed when an index page exists and removed when there is not. """ templ = dom.parse(open(d['template'])) indexFilename = 'theIndexFile' numLinks = len(domhelpers.findElementsWithAttribute(templ, "class", "index-link")) # if our testing template has no index-link nodes, complain about it self.assertNotEquals( [], domhelpers.findElementsWithAttribute(templ, "class", "index-link")) tree.setIndexLink(templ, indexFilename) self.assertEqual( [], domhelpers.findElementsWithAttribute(templ, "class", "index-link")) indexLinks = domhelpers.findElementsWithAttribute(templ, "href", indexFilename) self.assertTrue(len(indexLinks) >= numLinks) templ = dom.parse(open(d['template'])) self.assertNotEquals( [], domhelpers.findElementsWithAttribute(templ, "class", "index-link")) indexFilename = None tree.setIndexLink(templ, indexFilename) self.assertEqual( [], domhelpers.findElementsWithAttribute(templ, "class", "index-link"))