mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-24 03:00:15 +00:00
Add ability for a user to get retrieve subscriptions, with tests.
This commit is contained in:
parent
993829b23f
commit
ec01e45ed1
3 changed files with 36 additions and 2 deletions
|
@ -171,6 +171,12 @@ class xep_0060(base_plugin):
|
||||||
iq['pubsub']['unsubscribe']['subid'] = subid
|
iq['pubsub']['unsubscribe']['subid'] = subid
|
||||||
return iq.send(block=block, callback=callback, timeout=timeout)
|
return iq.send(block=block, callback=callback, timeout=timeout)
|
||||||
|
|
||||||
|
def get_subscriptions(self, jid, node=None, ifrom=None, block=True,
|
||||||
|
callback=None, timeout=None):
|
||||||
|
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='get')
|
||||||
|
iq['pubsub']['subscriptions']['node'] = node
|
||||||
|
return iq.send(block=block, callback=callback, timeout=timeout)
|
||||||
|
|
||||||
def get_subscription_options(self, jid, node, user_jid, ifrom=None,
|
def get_subscription_options(self, jid, node, user_jid, ifrom=None,
|
||||||
block=True, callback=None, timeout=None):
|
block=True, callback=None, timeout=None):
|
||||||
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='get')
|
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='get')
|
||||||
|
|
|
@ -65,7 +65,7 @@ class Subscriptions(ElementBase):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub'
|
namespace = 'http://jabber.org/protocol/pubsub'
|
||||||
name = 'subscriptions'
|
name = 'subscriptions'
|
||||||
plugin_attrib = 'subscriptions'
|
plugin_attrib = 'subscriptions'
|
||||||
interfaces = set(tuple())
|
interfaces = set(('node',))
|
||||||
plugin_attrib_map = {}
|
plugin_attrib_map = {}
|
||||||
plugin_tag_map = {}
|
plugin_tag_map = {}
|
||||||
subitem = (Subscription,)
|
subitem = (Subscription,)
|
||||||
|
|
|
@ -626,7 +626,7 @@ class TestStreamPubsub(SleekTest):
|
||||||
""")
|
""")
|
||||||
|
|
||||||
def testGetNodeSubscriptions(self):
|
def testGetNodeSubscriptions(self):
|
||||||
"""Test retrieving the subscriptions for a node."""
|
"""Test retrieving all subscriptions for a node."""
|
||||||
self.xmpp['xep_0060'].get_node_subscriptions(
|
self.xmpp['xep_0060'].get_node_subscriptions(
|
||||||
'pubsub.example.com',
|
'pubsub.example.com',
|
||||||
'somenode',
|
'somenode',
|
||||||
|
@ -639,4 +639,32 @@ class TestStreamPubsub(SleekTest):
|
||||||
</iq>
|
</iq>
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
def testGetSubscriptions(self):
|
||||||
|
"""Test retrieving a users's subscriptions."""
|
||||||
|
self.xmpp['xep_0060'].get_subscriptions(
|
||||||
|
'pubsub.example.com',
|
||||||
|
block=False)
|
||||||
|
self.send("""
|
||||||
|
<iq type="get" id="1" to="pubsub.example.com">
|
||||||
|
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
||||||
|
<subscriptions />
|
||||||
|
</pubsub>
|
||||||
|
</iq>
|
||||||
|
""")
|
||||||
|
|
||||||
|
def testGetSubscriptionsForNode(self):
|
||||||
|
"""Test retrieving a users's subscriptions for a given node."""
|
||||||
|
self.xmpp['xep_0060'].get_subscriptions(
|
||||||
|
'pubsub.example.com',
|
||||||
|
node='somenode',
|
||||||
|
block=False)
|
||||||
|
self.send("""
|
||||||
|
<iq type="get" id="1" to="pubsub.example.com">
|
||||||
|
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
||||||
|
<subscriptions node="somenode" />
|
||||||
|
</pubsub>
|
||||||
|
</iq>
|
||||||
|
""")
|
||||||
|
|
||||||
|
|
||||||
suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamPubsub)
|
suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamPubsub)
|
||||||
|
|
Loading…
Reference in a new issue