Ignore:
Location:
wokkel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wokkel/pubsub.py

    r212 r223  
    915915
    916916    def items(self, service, nodeIdentifier, maxItems=None,
    917               subscriptionIdentifier=None, sender=None):
     917              subscriptionIdentifier=None, sender=None, itemIdentifiers=None):
    918918        """
    919919        Retrieve previously published items from a publish subscribe node.
     
    932932            the results to the specific subscription.
    933933        @type subscriptionIdentifier: L{unicode}
     934
     935        @param itemIdentifiers: Identifiers of the items to be retrieved.
     936        @type itemIdentifiers: L{set} of L{unicode}
    934937        """
    935938        request = PubSubRequest('items')
     
    940943        request.subscriptionIdentifier = subscriptionIdentifier
    941944        request.sender = sender
     945        request.itemIdentifiers = itemIdentifiers
    942946
    943947        def cb(iq):
  • wokkel/test/test_pubsub.py

    r212 r222  
    828828
    829829
     830    def test_itemsWithItemIdentifiers(self):
     831        """
     832        Test sending items request with item identifiers.
     833        """
     834        def cb(items):
     835            self.assertEquals(2, len(items))
     836            self.assertEquals([item1, item2], items)
     837
     838        d = self.protocol.items(JID('pubsub.example.org'), 'test',
     839                                itemIdentifiers=['item1', 'item2'])
     840        d.addCallback(cb)
     841
     842        iq = self.stub.output[-1]
     843        self.assertEquals('pubsub.example.org', iq.getAttribute('to'))
     844        self.assertEquals('get', iq.getAttribute('type'))
     845        self.assertEquals('pubsub', iq.pubsub.name)
     846        self.assertEquals(NS_PUBSUB, iq.pubsub.uri)
     847        children = list(domish.generateElementsQNamed(iq.pubsub.children,
     848                                                      'items', NS_PUBSUB))
     849        self.assertEquals(1, len(children))
     850        child = children[0]
     851        self.assertEquals('test', child['node'])
     852        itemIdentifiers = [item.getAttribute('id') for item in
     853                           domish.generateElementsQNamed(child.children, 'item',
     854                                                         NS_PUBSUB)]
     855        self.assertEquals(['item1', 'item2'], itemIdentifiers)
     856
     857        response = toResponse(iq, 'result')
     858        items = response.addElement((NS_PUBSUB, 'pubsub')).addElement('items')
     859        items['node'] = 'test'
     860        item1 = items.addElement('item')
     861        item1['id'] = 'item1'
     862        item2 = items.addElement('item')
     863        item2['id'] = 'item2'
     864
     865        self.stub.send(response)
     866
     867        return d
     868
     869
    830870    def test_itemsWithSubscriptionIdentifier(self):
    831871        """
Note: See TracChangeset for help on using the changeset viewer.