From 6b7fde10d3a63353f303abd969bb2c47d3ae3d5f Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Tue, 30 Aug 2011 22:27:02 -0700 Subject: Test pubsub subscribe. --- tests/test_stream_xep_0060.py | 81 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) (limited to 'tests/test_stream_xep_0060.py') diff --git a/tests/test_stream_xep_0060.py b/tests/test_stream_xep_0060.py index 1d912ca5..a740884e 100644 --- a/tests/test_stream_xep_0060.py +++ b/tests/test_stream_xep_0060.py @@ -124,5 +124,86 @@ class TestStreamPubsub(SleekTest): t.join() + def testSubscribe(self): + """Test subscribing to a node""" + + def run_test(jid, bare, ifrom, send, recv): + t = threading.Thread(name='subscribe', + target=self.xmpp['xep_0060'].subscribe, + args=('pubsub.example.com', 'some_node'), + kwargs={'subscribee': jid, + 'bare': bare, + 'ifrom': ifrom}) + t.start() + self.send(send) + self.recv(recv) + t.join() + + # Case 1: No subscribee, default 'from' JID, bare JID + run_test(None, True, None, + """ + + + + + + """, + """ + + """) + + # Case 2: No subscribee, given 'from' JID, bare JID + run_test(None, True, 'foo@comp.example.com/bar', + """ + + + + + + """, + """ + + """) + + # Case 3: No subscribee, given 'from' JID, full JID + run_test(None, False, 'foo@comp.example.com/bar', + """ + + + + + + """, + """ + + """) + + # Case 4: Subscribee + run_test('user@example.com/foo', True, 'foo@comp.example.com/bar', + """ + + + + + + """, + """ + + """) + + def testSubscribeWithOptions(self): + pass + + def testUnsubscribe(self): + pass + + suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamPubsub) -- cgit v1.2.3