summaryrefslogtreecommitdiff
path: root/tests/test_stream_xep_0060.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2011-08-30 23:18:13 -0700
committerLance Stout <lancestout@gmail.com>2011-08-30 23:18:13 -0700
commit730c3fada0ddc09a0814fe6bed583c1f3acbbf3f (patch)
tree113b1a903d8fe05a4337fc7393875721bb04ca4a /tests/test_stream_xep_0060.py
parent628978fc8c08a45804983b1888f7dbea583d6a28 (diff)
downloadslixmpp-730c3fada0ddc09a0814fe6bed583c1f3acbbf3f.tar.gz
slixmpp-730c3fada0ddc09a0814fe6bed583c1f3acbbf3f.tar.bz2
slixmpp-730c3fada0ddc09a0814fe6bed583c1f3acbbf3f.tar.xz
slixmpp-730c3fada0ddc09a0814fe6bed583c1f3acbbf3f.zip
Add tests for pubsub unsubscribe.
Diffstat (limited to 'tests/test_stream_xep_0060.py')
-rw-r--r--tests/test_stream_xep_0060.py74
1 files changed, 72 insertions, 2 deletions
diff --git a/tests/test_stream_xep_0060.py b/tests/test_stream_xep_0060.py
index a740884e..634bcd4a 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,
+ """
+ <iq type="set" id="1" to="pubsub.example.com">
+ <pubsub xmlns="http://jabber.org/protocol/pubsub">
+ <unsubscribe node="some_node" jid="tester@localhost" />
+ </pubsub>
+ </iq>
+ """,
+ """
+ <iq type="result" id="1"
+ to="tester@localhost" from="pubsub.example.com" />
+ """)
+
+ # Case 2: No subscribee, given 'from' JID, bare JID
+ run_test(None, True, 'foo@comp.example.com/bar',
+ """
+ <iq type="set" id="2"
+ to="pubsub.example.com" from="foo@comp.example.com/bar">
+ <pubsub xmlns="http://jabber.org/protocol/pubsub">
+ <unsubscribe node="some_node" jid="foo@comp.example.com" />
+ </pubsub>
+ </iq>
+ """,
+ """
+ <iq type="result" id="2"
+ to="foo@comp.example.com/bar" from="pubsub.example.com" />
+ """)
+
+ # Case 3: No subscribee, given 'from' JID, full JID
+ run_test(None, False, 'foo@comp.example.com/bar',
+ """
+ <iq type="set" id="3"
+ to="pubsub.example.com" from="foo@comp.example.com/bar">
+ <pubsub xmlns="http://jabber.org/protocol/pubsub">
+ <unsubscribe node="some_node" jid="foo@comp.example.com/bar" />
+ </pubsub>
+ </iq>
+ """,
+ """
+ <iq type="result" id="3"
+ to="foo@comp.example.com/bar" from="pubsub.example.com" />
+ """)
+
+ # Case 4: Subscribee
+ run_test('user@example.com/foo', True, 'foo@comp.example.com/bar',
+ """
+ <iq type="set" id="4"
+ to="pubsub.example.com" from="foo@comp.example.com/bar">
+ <pubsub xmlns="http://jabber.org/protocol/pubsub">
+ <unsubscribe node="some_node" jid="user@example.com/foo" />
+ </pubsub>
+ </iq>
+ """,
+ """
+ <iq type="result" id="4"
+ to="foo@comp.example.com/bar" from="pubsub.example.com" />
+ """)
suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamPubsub)