Ignore:
Timestamp:
Oct 4, 2016, 9:39:09 AM (5 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Parents:
220:c8a97efc6fa6 (diff), 221:cd2b3dff1f2f (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-get-by-ids

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wokkel/test/test_pubsub.py

    r220 r222  
    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
     
    29542980        def configureSet(request):
    29552981            self.assertEquals(['pubsub#deliver_payloads'],
    2956                               request.options.keys())
     2982                              list(request.options.keys()))
    29572983
    29582984        self.resource.getConfigurationOptions = getConfigurationOptions
  • 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.