From 82870993a17cd225a689688eb5f93402195b2caf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20=C3=96zkural?= Date: Wed, 2 Nov 2005 16:34:53 +0000 Subject: [PATCH] * expose bug in add routine! uhuhuhuuh :'( --- tests/xmlexttests.py | 52 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 tests/xmlexttests.py diff --git a/tests/xmlexttests.py b/tests/xmlexttests.py new file mode 100644 index 00000000..fe4eec6b --- /dev/null +++ b/tests/xmlexttests.py @@ -0,0 +1,52 @@ +# Copyright (C) 2005, TUBITAK/UEKAE +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation; either version 2 of the License, or (at your option) +# any later version. +# +# Please read the COPYING file. +# + +import unittest +import os +import xml.dom.minidom as mdom +from xml.parsers.expat import ExpatError +import types + +import pisi +import pisi.api +from pisi import xmlfile +import pisi.context as ctx +import pisi.util as util +from pisi.xmlext import * + +import testcase + +class XmlExtTestCase(testcase.TestCase): + + def setUp(self): + testcase.TestCase.setUp(self, database=False) + + def testGet(self): + self.a = mdom.parse('tests/a.xml') + self.doc = self.a.documentElement + self.assertEqual(getNodeText(self.doc, 'Number'), '868') + self.assertEqual(getNodeText(self.doc, 'OtherInfo/BirthDate'), '18071976') + codeswith = getAllNodes(self.doc, 'OtherInfo/CodesWith/Person') + self.assertEqual(len(codeswith), 4) + self.assertEqual(getNodeText(codeswith[2]), 'Caglar') + + def testAdd(self): + impl = mdom.getDOMImplementation() + a = impl.createDocument(None, 'team', None) + node = a.documentElement + addText(node, 'team/coder', 'zibidi1') + addText(node, 'team/coder', 'zibidi2') + addText(node, 'team/coder', 'zibidi3') + reada = getAllNodes(node, 'team/coder') + self.assertEqual(len(reada), 3) + + pass + +suite = unittest.makeSuite(XmlExtTestCase)