Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrendan Taylor <bct@diffeq.com>2008-06-29 21:06:30 +0400
committerBrendan Taylor <bct@diffeq.com>2008-06-29 21:06:30 +0400
commit90d849f945e4899967150eeb953b8cc25455a9bb (patch)
tree1e00a7c97f4edd953a2895737e75c85f42732470 /test/test_dispatcher_nb.py
parent3a94e595e5dba4b995f2b8c9109ddaffda19d40d (diff)
added test for parsing of unbound namespace prefixes
Diffstat (limited to 'test/test_dispatcher_nb.py')
-rw-r--r--test/test_dispatcher_nb.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/test/test_dispatcher_nb.py b/test/test_dispatcher_nb.py
new file mode 100644
index 000000000..c82115fa2
--- /dev/null
+++ b/test/test_dispatcher_nb.py
@@ -0,0 +1,53 @@
+# tests for xmpppy's dispatcher_nb.py
+import unittest
+
+import testlib
+testlib.setup_env()
+
+from mock import Mock
+
+from common.xmpp import dispatcher_nb
+from common.xmpp import auth
+
+class TestDispatcherNB(unittest.TestCase):
+ def test_unbound_namespace_prefix(self):
+ '''tests our handling of a message with an unbound namespace prefix'''
+ d = dispatcher_nb.Dispatcher()
+
+ conn = Mock()
+
+ owner = Mock()
+ owner._caller = Mock()
+ owner.defaultNamespace = auth.NS_CLIENT
+ owner.debug_flags = []
+ owner.Connection = conn
+ owner._component = False
+
+ d._owner = owner
+ d.plugin(owner)
+
+ msgs = []
+
+ def _got_message(conn, msg):
+ msgs.append(msg)
+
+ d.RegisterHandler('message', _got_message)
+
+ d.StreamInit()
+
+ d.ProcessNonBlocking("<stream:stream xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client'>")
+
+ # should be able to parse a normal message
+ d.ProcessNonBlocking('<message><body>hello</body></message>')
+ self.assertEqual(1, len(msgs))
+
+ d.ProcessNonBlocking('<message><x:y/></message>')
+ # we should not have been disconnected after that message
+ self.assertEqual(0, len(conn.mockGetNamedCalls('pollend')))
+
+ # we should be able to keep parsing
+ d.ProcessNonBlocking('<message><body>still here?</body></message>')
+ self.assertEqual(2, len(msgs))
+
+if __name__ == '__main__':
+ unittest.main()