mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-27 11:09:56 +00:00
Fix requesting pubsub node configuration, and add tests.
- <default /> doesn't have a type attribute in the XEP - <configure /> isn't used anymore for requesting default configuration
This commit is contained in:
parent
5ec4e4a026
commit
2500a0649b
4 changed files with 48 additions and 14 deletions
|
@ -206,11 +206,7 @@ class xep_0060(base_plugin):
|
|||
be executed when a reply stanza is received.
|
||||
"""
|
||||
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='get')
|
||||
|
||||
if node is None:
|
||||
iq['pubsub_owner']['default']
|
||||
else:
|
||||
iq['pubsub_owner']['configure']['node'] = node
|
||||
iq['pubsub_owner']['default']['node'] = node
|
||||
return iq.send(block=block, callback=callback, timeout=timeout)
|
||||
|
||||
def get_node_subscriptions(self, jid, node, ifrom=None, block=True,
|
||||
|
|
|
@ -22,18 +22,13 @@ class DefaultConfig(ElementBase):
|
|||
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
||||
name = 'default'
|
||||
plugin_attrib = 'default'
|
||||
interfaces = set(('node', 'type', 'config'))
|
||||
interfaces = set(('node', 'config'))
|
||||
plugin_attrib_map = {}
|
||||
plugin_tag_map = {}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
ElementBase.__init__(self, *args, **kwargs)
|
||||
|
||||
def getType(self):
|
||||
t = self._getAttr('type')
|
||||
if not t: t = 'leaf'
|
||||
return t
|
||||
|
||||
def getConfig(self):
|
||||
return self['form']
|
||||
|
||||
|
|
|
@ -148,14 +148,13 @@ class TestPubsubStanzas(SleekTest):
|
|||
iq = self.Iq()
|
||||
iq['pubsub_owner']['default']
|
||||
iq['pubsub_owner']['default']['node'] = 'mynode'
|
||||
iq['pubsub_owner']['default']['type'] = 'leaf'
|
||||
iq['pubsub_owner']['default']['form'].addField('pubsub#title',
|
||||
ftype='text-single',
|
||||
value='This thing is awesome')
|
||||
self.check(iq, """
|
||||
<iq id="0">
|
||||
<pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
|
||||
<default node="mynode" type="leaf">
|
||||
<default node="mynode">
|
||||
<x xmlns="jabber:x:data" type="form">
|
||||
<field var="pubsub#title" type="text-single">
|
||||
<value>This thing is awesome</value>
|
||||
|
|
|
@ -275,5 +275,49 @@ class TestStreamPubsub(SleekTest):
|
|||
to="foo@comp.example.com/bar" from="pubsub.example.com" />
|
||||
""")
|
||||
|
||||
def testGetDefaultConfig(self):
|
||||
"""Test retrieving the default node configuration."""
|
||||
t = threading.Thread(name='default_config',
|
||||
target=self.xmpp['xep_0060'].get_node_config,
|
||||
args=('pubsub.example.com',))
|
||||
t.start()
|
||||
|
||||
self.send("""
|
||||
<iq type="get" id="1" to="pubsub.example.com">
|
||||
<pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
|
||||
<default />
|
||||
</pubsub>
|
||||
</iq>
|
||||
""", use_values=False)
|
||||
|
||||
self.recv("""
|
||||
<iq type="result" id="1"
|
||||
to="foo@comp.example.com/bar" from="pubsub.example.com" />
|
||||
""")
|
||||
|
||||
t.join()
|
||||
|
||||
def testGetDefaultNodeConfig(self):
|
||||
"""Tes t retrieving the default config for a given node."""
|
||||
t = threading.Thread(name='default_config',
|
||||
target=self.xmpp['xep_0060'].get_node_config,
|
||||
args=('pubsub.example.com', 'somenode'))
|
||||
t.start()
|
||||
|
||||
self.send("""
|
||||
<iq type="get" id="1" to="pubsub.example.com">
|
||||
<pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
|
||||
<default node="somenode" />
|
||||
</pubsub>
|
||||
</iq>
|
||||
""", use_values=False)
|
||||
|
||||
self.recv("""
|
||||
<iq type="result" id="1"
|
||||
to="foo@comp.example.com/bar" from="pubsub.example.com" />
|
||||
""")
|
||||
|
||||
t.join()
|
||||
|
||||
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamPubsub)
|
||||
|
|
Loading…
Reference in a new issue