From 002257b8208e343661a68710a3ee936067bfdba0 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Thu, 1 Sep 2011 09:27:10 -0700 Subject: Add tests for retrieving pubsub items. --- sleekxmpp/plugins/xep_0060/pubsub.py | 1 + sleekxmpp/plugins/xep_0060/stanza/pubsub.py | 3 ++ tests/test_stream_xep_0060.py | 58 +++++++++++++++++++++++++++-- 3 files changed, 58 insertions(+), 4 deletions(-) diff --git a/sleekxmpp/plugins/xep_0060/pubsub.py b/sleekxmpp/plugins/xep_0060/pubsub.py index 627ad37a..c0038cee 100644 --- a/sleekxmpp/plugins/xep_0060/pubsub.py +++ b/sleekxmpp/plugins/xep_0060/pubsub.py @@ -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) diff --git a/sleekxmpp/plugins/xep_0060/stanza/pubsub.py b/sleekxmpp/plugins/xep_0060/stanza/pubsub.py index 9f3fbe22..d62fc661 100644 --- a/sleekxmpp/plugins/xep_0060/stanza/pubsub.py +++ b/sleekxmpp/plugins/xep_0060/stanza/pubsub.py @@ -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): diff --git a/tests/test_stream_xep_0060.py b/tests/test_stream_xep_0060.py index 4e2dca6d..0ac7d9fc 100644 --- a/tests/test_stream_xep_0060.py +++ b/tests/test_stream_xep_0060.py @@ -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(""" + + + + + + + + """) 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(""" + + + + + + """) def testGetAllItems(self): """Test retrieving all items.""" - pass + self.xmpp['xep_0060'].get_items( + 'pubsub.example.com', + 'somenode', + block=False) + self.send(""" + + + + + + """) 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(""" + + + + + + + + + + """) + suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamPubsub) -- cgit v1.2.3