From 37ff17b0cbefd8a0056b131621728123b292e211 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Thu, 26 Aug 2010 18:27:18 -0400 Subject: Added unit test for _fix_ns for handling namespaces with forward slashes. --- tests/test_elementbase.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests') diff --git a/tests/test_elementbase.py b/tests/test_elementbase.py index 6b0c076b..8de7a169 100644 --- a/tests/test_elementbase.py +++ b/tests/test_elementbase.py @@ -3,6 +3,21 @@ from sleekxmpp.xmlstream.stanzabase import ElementBase class TestElementBase(SleekTest): + def testFixNs(self): + """Test fixing namespaces in an XPath expression.""" + + e = ElementBase() + ns = "http://jabber.org/protocol/disco#items" + result = e._fix_ns("{%s}foo/bar/{abc}baz/{%s}more" % (ns, ns)) + + expected = "/".join(["{%s}foo" % ns, + "{%s}bar" % ns, + "{abc}baz", + "{%s}more" % ns]) + self.failUnless(expected == result, + "Incorrect namespace fixing result: %s" % str(result)) + + def testExtendedName(self): """Test element names of the form tag1/tag2/tag3.""" -- cgit v1.2.3