mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-23 19:19:53 +00:00
Add tests for retrieving pubsub items.
This commit is contained in:
parent
0af35c2224
commit
002257b820
3 changed files with 58 additions and 4 deletions
|
@ -334,6 +334,7 @@ class xep_0060(base_plugin):
|
|||
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='get')
|
||||
item = self.stanza.Item()
|
||||
item['id'] = item_id
|
||||
iq['pubsub']['items']['node'] = node
|
||||
iq['pubsub']['items'].append(item)
|
||||
return iq.send(block=block, callback=callback, timeout=timeout)
|
||||
|
||||
|
|
|
@ -113,6 +113,9 @@ class Items(ElementBase):
|
|||
plugin_tag_map = {}
|
||||
subitem = (Item,)
|
||||
|
||||
def set_max_items(self, value):
|
||||
self._set_attr('max_items', str(value))
|
||||
|
||||
registerStanzaPlugin(Pubsub, Items)
|
||||
|
||||
class Create(ElementBase):
|
||||
|
|
|
@ -478,19 +478,69 @@ class TestStreamPubsub(SleekTest):
|
|||
|
||||
def testGetItem(self):
|
||||
"""Test retrieving a single item."""
|
||||
pass
|
||||
self.xmpp['xep_0060'].get_item(
|
||||
'pubsub.example.com',
|
||||
'somenode',
|
||||
'id42',
|
||||
block=False)
|
||||
self.send("""
|
||||
<iq type="get" id="1" to="pubsub.example.com">
|
||||
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
||||
<items node="somenode">
|
||||
<item id="id42" />
|
||||
</items>
|
||||
</pubsub>
|
||||
</iq>
|
||||
""")
|
||||
|
||||
def testGetLatestItems(self):
|
||||
"""Test retrieving the most recent N items."""
|
||||
pass
|
||||
self.xmpp['xep_0060'].get_items(
|
||||
'pubsub.example.com',
|
||||
'somenode',
|
||||
max_items=3,
|
||||
block=False)
|
||||
self.send("""
|
||||
<iq type="get" id="1" to="pubsub.example.com">
|
||||
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
||||
<items node="somenode" max_items="3" />
|
||||
</pubsub>
|
||||
</iq>
|
||||
""")
|
||||
|
||||
def testGetAllItems(self):
|
||||
"""Test retrieving all items."""
|
||||
pass
|
||||
self.xmpp['xep_0060'].get_items(
|
||||
'pubsub.example.com',
|
||||
'somenode',
|
||||
block=False)
|
||||
self.send("""
|
||||
<iq type="get" id="1" to="pubsub.example.com">
|
||||
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
||||
<items node="somenode" />
|
||||
</pubsub>
|
||||
</iq>
|
||||
""")
|
||||
|
||||
def testGetSpecificItems(self):
|
||||
"""Test retrieving a specific set of items."""
|
||||
pass
|
||||
self.xmpp['xep_0060'].get_items(
|
||||
'pubsub.example.com',
|
||||
'somenode',
|
||||
item_ids=['A', 'B', 'C'],
|
||||
block=False)
|
||||
self.send("""
|
||||
<iq type="get" id="1" to="pubsub.example.com">
|
||||
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
||||
<items node="somenode">
|
||||
<item id="A" />
|
||||
<item id="B" />
|
||||
<item id="C" />
|
||||
</items>
|
||||
</pubsub>
|
||||
</iq>
|
||||
""")
|
||||
|
||||
|
||||
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamPubsub)
|
||||
|
|
Loading…
Reference in a new issue