mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-12-18 03:00:18 +00:00
More pubsub unit tests!
This commit is contained in:
parent
cc504ab07c
commit
3623a7a16a
3 changed files with 111 additions and 14 deletions
|
@ -206,7 +206,10 @@ class xep_0060(base_plugin):
|
||||||
be executed when a reply stanza is received.
|
be executed when a reply stanza is received.
|
||||||
"""
|
"""
|
||||||
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='get')
|
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='get')
|
||||||
iq['pubsub_owner']['default']['node'] = node
|
if node is None:
|
||||||
|
iq['pubsub_owner']['default']
|
||||||
|
else:
|
||||||
|
iq['pubsub_owner']['configure']['node'] = node
|
||||||
return iq.send(block=block, callback=callback, timeout=timeout)
|
return iq.send(block=block, callback=callback, timeout=timeout)
|
||||||
|
|
||||||
def get_node_subscriptions(self, jid, node, ifrom=None, block=True,
|
def get_node_subscriptions(self, jid, node, ifrom=None, block=True,
|
||||||
|
@ -276,7 +279,7 @@ class xep_0060(base_plugin):
|
||||||
callback=None, timeout=None):
|
callback=None, timeout=None):
|
||||||
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='set')
|
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='set')
|
||||||
iq['pubsub_owner']['configure']['node'] = node
|
iq['pubsub_owner']['configure']['node'] = node
|
||||||
iq['pubsub_owner']['configure']['config'] = config
|
iq['pubsub_owner']['configure']['form'].values = config.values
|
||||||
return iq.send(block=block, callback=callback, timeout=timeout)
|
return iq.send(block=block, callback=callback, timeout=timeout)
|
||||||
|
|
||||||
def publish(self, jid, node, item_id=None, payload=None, items=None,
|
def publish(self, jid, node, item_id=None, payload=None, items=None,
|
||||||
|
|
|
@ -63,18 +63,12 @@ class OwnerConfigure(Configure):
|
||||||
name = 'configure'
|
name = 'configure'
|
||||||
plugin_attrib = 'configure'
|
plugin_attrib = 'configure'
|
||||||
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
||||||
interfaces = set(('node', 'config'))
|
interfaces = set(('node',))
|
||||||
plugin_attrib_map = {}
|
plugin_attrib_map = {}
|
||||||
plugin_tag_map = {}
|
plugin_tag_map = {}
|
||||||
|
|
||||||
def getConfig(self):
|
|
||||||
return self['form']
|
|
||||||
|
|
||||||
def setConfig(self, value):
|
|
||||||
self['form'].setStanzaValues(value.getStanzaValues())
|
|
||||||
return self
|
|
||||||
|
|
||||||
registerStanzaPlugin(PubsubOwner, OwnerConfigure)
|
registerStanzaPlugin(PubsubOwner, OwnerConfigure)
|
||||||
|
registerStanzaPlugin(OwnerConfigure, xep_0004.Form)
|
||||||
|
|
||||||
class OwnerDefault(OwnerConfigure):
|
class OwnerDefault(OwnerConfigure):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
||||||
|
|
|
@ -292,14 +292,36 @@ class TestStreamPubsub(SleekTest):
|
||||||
|
|
||||||
self.recv("""
|
self.recv("""
|
||||||
<iq type="result" id="1"
|
<iq type="result" id="1"
|
||||||
to="foo@comp.example.com/bar" from="pubsub.example.com" />
|
to="tester@localhost" from="pubsub.example.com" />
|
||||||
""")
|
""")
|
||||||
|
|
||||||
t.join()
|
t.join()
|
||||||
|
|
||||||
def testGetDefaultNodeConfig(self):
|
def testGetDefaultNodeConfig(self):
|
||||||
"""Tes t retrieving the default config for a given node."""
|
"""Test retrieving the default node config for a pubsub service."""
|
||||||
t = threading.Thread(name='default_config',
|
t = threading.Thread(name='default_config',
|
||||||
|
target=self.xmpp['xep_0060'].get_node_config,
|
||||||
|
args=('pubsub.example.com', None))
|
||||||
|
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="tester@localhost" from="pubsub.example.com" />
|
||||||
|
""")
|
||||||
|
|
||||||
|
t.join()
|
||||||
|
|
||||||
|
def testGetNodeConfig(self):
|
||||||
|
"""Test getting the config for a given node."""
|
||||||
|
t = threading.Thread(name='node_config',
|
||||||
target=self.xmpp['xep_0060'].get_node_config,
|
target=self.xmpp['xep_0060'].get_node_config,
|
||||||
args=('pubsub.example.com', 'somenode'))
|
args=('pubsub.example.com', 'somenode'))
|
||||||
t.start()
|
t.start()
|
||||||
|
@ -307,17 +329,95 @@ class TestStreamPubsub(SleekTest):
|
||||||
self.send("""
|
self.send("""
|
||||||
<iq type="get" id="1" to="pubsub.example.com">
|
<iq type="get" id="1" to="pubsub.example.com">
|
||||||
<pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
|
<pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
|
||||||
<default node="somenode" />
|
<configure node="somenode" />
|
||||||
</pubsub>
|
</pubsub>
|
||||||
</iq>
|
</iq>
|
||||||
""", use_values=False)
|
""", use_values=False)
|
||||||
|
|
||||||
self.recv("""
|
self.recv("""
|
||||||
<iq type="result" id="1"
|
<iq type="result" id="1"
|
||||||
to="foo@comp.example.com/bar" from="pubsub.example.com" />
|
to="tester@localhost" from="pubsub.example.com" />
|
||||||
""")
|
""")
|
||||||
|
|
||||||
t.join()
|
t.join()
|
||||||
|
|
||||||
|
def testSetNodeConfig(self):
|
||||||
|
"""Test setting the configuration for a node."""
|
||||||
|
form = self.xmpp['xep_0004'].make_form()
|
||||||
|
form.add_field(var='FORM_TYPE', ftype='hidden',
|
||||||
|
value='http://jabber.org/protocol/pubsub#node_config')
|
||||||
|
form.add_field(var='pubsub#title', ftype='text-single',
|
||||||
|
value='This is awesome!')
|
||||||
|
form['type'] = 'submit'
|
||||||
|
|
||||||
|
t = threading.Thread(name='set_config',
|
||||||
|
target=self.xmpp['xep_0060'].set_node_config,
|
||||||
|
args=('pubsub.example.com', 'somenode', form))
|
||||||
|
t.start()
|
||||||
|
|
||||||
|
self.send("""
|
||||||
|
<iq type="set" id="1" to="pubsub.example.com">
|
||||||
|
<pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
|
||||||
|
<configure node="somenode">
|
||||||
|
<x xmlns="jabber:x:data" type="submit">
|
||||||
|
<field var="FORM_TYPE">
|
||||||
|
<value>http://jabber.org/protocol/pubsub#node_config</value>
|
||||||
|
</field>
|
||||||
|
<field var="pubsub#title">
|
||||||
|
<value>This is awesome!</value>
|
||||||
|
</field>
|
||||||
|
</x>
|
||||||
|
</configure>
|
||||||
|
</pubsub>
|
||||||
|
</iq>
|
||||||
|
""")
|
||||||
|
|
||||||
|
self.recv("""
|
||||||
|
<iq type="result" id="1"
|
||||||
|
to="tester@localhost" from="pubsub.example.com" />
|
||||||
|
""")
|
||||||
|
|
||||||
|
t.join()
|
||||||
|
|
||||||
|
def testPublishSingle(self):
|
||||||
|
"""Test publishing a single item."""
|
||||||
|
pass
|
||||||
|
|
||||||
|
def testPublishSingleOptions(self):
|
||||||
|
"""Test publishing a single item, with options."""
|
||||||
|
|
||||||
|
|
||||||
|
def testPublishMulti(self):
|
||||||
|
"""Test publishing multiple items."""
|
||||||
|
pass
|
||||||
|
|
||||||
|
def testPublishMultiOptions(self):
|
||||||
|
"""Test publishing multiple items, with options."""
|
||||||
|
pass
|
||||||
|
|
||||||
|
def testRetract(self):
|
||||||
|
"""Test deleting an item."""
|
||||||
|
pass
|
||||||
|
|
||||||
|
def testPurge(self):
|
||||||
|
"""Test removing all items from a node."""
|
||||||
|
pass
|
||||||
|
|
||||||
|
def testGetItem(self):
|
||||||
|
"""Test retrieving a single item."""
|
||||||
|
pass
|
||||||
|
|
||||||
|
def testGetLatestItems(self):
|
||||||
|
"""Test retrieving the most recent N items."""
|
||||||
|
pass
|
||||||
|
|
||||||
|
def testGetAllItems(self):
|
||||||
|
"""Test retrieving all items."""
|
||||||
|
pass
|
||||||
|
|
||||||
|
def testGetSpecificItems(self):
|
||||||
|
"""Test retrieving a specific set of items."""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamPubsub)
|
suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamPubsub)
|
||||||
|
|
Loading…
Reference in a new issue