Ignore:
Timestamp:
Oct 4, 2016, 9:53:27 AM (6 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Parents:
225:58dd11c3ddd5 (diff), 224:16fca7e4806f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
hg-git-rename-source:
git
Message:

Merge branch 'master' into item-retract

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wokkel/test/test_pubsub.py

    r222 r226  
    907907
    908908
     909    def test_retractItems(self):
     910        """
     911        Test sending items retraction.
     912        """
     913        d = self.protocol.retractItems(JID('pubsub.example.org'), 'test',
     914                                       itemIdentifiers=['item1', 'item2'])
     915
     916        iq = self.stub.output[-1]
     917        self.assertEquals('pubsub.example.org', iq.getAttribute('to'))
     918        self.assertEquals('set', iq.getAttribute('type'))
     919        self.assertEquals('pubsub', iq.pubsub.name)
     920        self.assertEquals(NS_PUBSUB, iq.pubsub.uri)
     921        children = list(domish.generateElementsQNamed(iq.pubsub.children,
     922                                                      'retract', NS_PUBSUB))
     923        self.assertEquals(1, len(children))
     924        child = children[0]
     925        self.assertEquals('test', child['node'])
     926        itemIdentifiers = [item.getAttribute('id') for item in
     927                           domish.generateElementsQNamed(child.children, 'item',
     928                                                         NS_PUBSUB)]
     929        self.assertEquals(['item1', 'item2'], itemIdentifiers)
     930
     931        self.stub.send(toResponse(iq, 'result'))
     932        return d
     933
     934
     935    def test_retractItemsWithSender(self):
     936        """
     937        Test retracting items request from a specific JID.
     938        """
     939        d = self.protocol.retractItems(JID('pubsub.example.org'), 'test',
     940                                       itemIdentifiers=['item1', 'item2'],
     941                                       sender=JID('user@example.org'))
     942
     943        iq = self.stub.output[-1]
     944        self.assertEquals('user@example.org', iq['from'])
     945
     946        self.stub.send(toResponse(iq, 'result'))
     947        return d
     948
     949
    909950    def test_getOptions(self):
    910951        def cb(form):
  • wokkel/test/test_pubsub.py

    r225 r226  
    55Tests for L{wokkel.pubsub}
    66"""
     7
     8from __future__ import division, absolute_import
    79
    810from zope.interface import verify
     
    113115        element = subscription.toElement()
    114116        self.assertEqual('1234', element.getAttribute('subid'))
     117
     118
     119
     120class ItemTests(unittest.TestCase):
     121    """
     122    Tests for L{pubsub.Item}.
     123    """
     124
     125    def test_payloadRaw(self):
     126        """
     127        Adding a payload as a string assumes serialized XML.
     128        """
     129        payload = "<test xmlns='foo'/>"
     130        item = pubsub.Item(payload=payload)
     131        self.assertEqual(payload, item.children[0])
     132
     133
     134    def test_payloadElement(self):
     135        """
     136        Adding a payload as an domish Element, just adds that element as child.
     137        """
     138        payload = domish.Element(('foo', 'test'))
     139        item = pubsub.Item(payload=payload)
     140        self.assertIs(payload, item.children[0])
    115141
    116142
     
    802828
    803829
     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
    804870    def test_itemsWithSubscriptionIdentifier(self):
    805871        """
     
    29553021        def configureSet(request):
    29563022            self.assertEquals(['pubsub#deliver_payloads'],
    2957                               request.options.keys())
     3023                              list(request.options.keys()))
    29583024
    29593025        self.resource.getConfigurationOptions = getConfigurationOptions
Note: See TracChangeset for help on using the changeset viewer.