source: ralphm-patches/pubsub-disco-info-42.patch @ 7:0fbac5c2e97d

Last change on this file since 7:0fbac5c2e97d was 7:0fbac5c2e97d, checked in by Ralph Meijer <ralphm@…>, 13 years ago

Save current state.

File size: 3.2 KB
  • wokkel/pubsub.py

    diff -r d6bbf24ef053 wokkel/pubsub.py
    a b  
    567567                for metaDatum in metaData:
    568568                    form.addField(data_form.Field.fromDict(metaDatum))
    569569
    570                 info.append(form.toElement())
     570                info.append(form)
    571571
    572572        d = self.getNodeInfo(requestor, target, nodeIdentifier or '')
    573573        d.addCallback(toInfo)
  • wokkel/test/test_pubsub.py

    diff -r d6bbf24ef053 wokkel/test/test_pubsub.py
    a b  
    1313from twisted.words.protocols.jabber import error
    1414from twisted.words.protocols.jabber.jid import JID
    1515
    16 from wokkel import data_form, iwokkel, pubsub, shim
     16from wokkel import data_form, disco, iwokkel, pubsub, shim
    1717from wokkel.test.helpers import TestableRequestHandlerMixin, XmlStreamStub
    1818
    1919try:
     
    2626NS_PUBSUB_ERRORS = 'http://jabber.org/protocol/pubsub#errors'
    2727NS_PUBSUB_EVENT = 'http://jabber.org/protocol/pubsub#event'
    2828NS_PUBSUB_OWNER = 'http://jabber.org/protocol/pubsub#owner'
     29NS_PUBSUB_META_DATA = 'http://jabber.org/protocol/pubsub#meta-data'
    2930
    3031def calledAsync(fn):
    3132    """
     
    524525        return d
    525526
    526527
     528    def test_getDiscoInfoNodeType(self):
     529        """
     530        Test getDiscoInfo with node type.
     531        """
     532        def cb(info):
     533            discoInfo = disco.DiscoInfo()
     534            for item in info:
     535                discoInfo.append(item)
     536            self.assertIn(('pubsub', 'collection'), discoInfo.identities)
     537
     538        def getNodeInfo(requestor, target, nodeIdentifier):
     539            return defer.succeed({'type': 'collection',
     540                                  'meta-data': {}})
     541
     542        self.service.getNodeInfo = getNodeInfo
     543        d = self.service.getDiscoInfo(JID('user@example.org/home'),
     544                                      JID('pubsub.example.org'), '')
     545        d.addCallback(cb)
     546        return d
     547
     548
     549    def test_getDiscoInfoMetaData(self):
     550        """
     551        Test getDiscoInfo with returned meta data.
     552        """
     553        def cb(info):
     554            discoInfo = disco.DiscoInfo()
     555            for item in info:
     556                discoInfo.append(item)
     557
     558            self.assertIn(('pubsub', 'leaf'), discoInfo.identities)
     559            self.assertIn(NS_PUBSUB_META_DATA, discoInfo.extensions)
     560            form = discoInfo.extensions[NS_PUBSUB_META_DATA]
     561            self.assertIn('pubsub#node_type', form.fields)
     562
     563        def getNodeInfo(requestor, target, nodeIdentifier):
     564            metaData = [{'var': 'pubsub#persist_items',
     565                         'label': 'Persist items to storage',
     566                         'value': True}]
     567            return defer.succeed({'type': 'leaf', 'meta-data': metaData})
     568
     569        self.service.getNodeInfo = getNodeInfo
     570        d = self.service.getDiscoInfo(JID('user@example.org/home'),
     571                                      JID('pubsub.example.org'), '')
     572        d.addCallback(cb)
     573        return d
     574
     575
    527576    def test_onPublishNoNode(self):
    528577        """
    529578        The root node is always a collection, publishing is a bad request.
Note: See TracBrowser for help on using the repository browser.