diff --git a/tests/test_stream_xep_0060.py b/tests/test_stream_xep_0060.py index a740884..634bcd4 100644 --- a/tests/test_stream_xep_0060.py +++ b/tests/test_stream_xep_0060.py @@ -201,9 +201,79 @@ class TestStreamPubsub(SleekTest): def testSubscribeWithOptions(self): pass - def testUnsubscribe(self): - pass + def testUnubscribe(self): + """Test unsubscribing from a node""" + def run_test(jid, bare, ifrom, send, recv): + t = threading.Thread(name='unsubscribe', + target=self.xmpp['xep_0060'].unsubscribe, + 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', + """ + + + + + + """, + """ + + """) suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamPubsub)