Changeset 32:55864b12be3d


Ignore:
Timestamp:
Sep 29, 2008, 9:43:56 PM (13 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Convert:
svn:b33ecbfc-034c-dc11-8662-000475d9059e/trunk@67
Message:

Make requests for subscriptions work again.

Author: mmalone (ralphm).
Reviewer: ralphm.
Fixes #22.

Location:
wokkel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wokkel/pubsub.py

    r30 r32  
    703703            response = domish.Element((NS_PUBSUB, 'pubsub'))
    704704            subscriptions = response.addElement('subscriptions')
    705             for node, subscriber, state in result:
     705            for subscription in result:
    706706                item = subscriptions.addElement('subscription')
    707                 item['node'] = node
    708                 item['jid'] = subscriber.full()
    709                 item['subscription'] = state
     707                item['node'] = subscription.nodeIdentifier
     708                item['jid'] = subscription.subscriber.full()
     709                item['subscription'] = subscription.state
    710710            return response
    711711
  • wokkel/test/test_pubsub.py

    r30 r32  
    574574
    575575
     576    def test_onSubscriptions(self):
     577        """
     578        A subscriptions request should result in
     579        L{PubSubService.subscriptions} being called and the result prepared
     580        for the response.
     581        """
     582
     583        xml = """
     584        <iq type='get' to='pubsub.example.org'
     585                       from='user@example.org'>
     586          <pubsub xmlns='http://jabber.org/protocol/pubsub'>
     587            <subscriptions/>
     588          </pubsub>
     589        </iq>
     590        """
     591
     592        def cb(element):
     593            self.assertEqual('pubsub', element.name)
     594            self.assertEqual(NS_PUBSUB, element.uri)
     595            self.assertEqual(NS_PUBSUB, element.subscriptions.uri)
     596            children = list(element.subscriptions.elements())
     597            self.assertEqual(1, len(children))
     598            subscription = children[0]
     599            self.assertEqual('subscription', subscription.name)
     600            self.assertEqual(NS_PUBSUB, subscription.uri)
     601            self.assertEqual('user@example.org', subscription['jid'])
     602            self.assertEqual('test', subscription['node'])
     603            self.assertEqual('subscribed', subscription['subscription'])
     604
     605
     606        def subscriptions(requestor, service):
     607            self.assertEqual(JID('user@example.org'), requestor)
     608            self.assertEqual(JID('pubsub.example.org'), service)
     609            subscription = pubsub.Subscription('test', JID('user@example.org'),
     610                                               'subscribed')
     611            return defer.succeed([subscription])
     612
     613        self.service.subscriptions = subscriptions
     614        d = self.handleRequest(xml)
     615        d.addCallback(cb)
     616        return d
     617
     618
    576619    def test_onDefault(self):
    577620        """
Note: See TracChangeset for help on using the changeset viewer.