Changeset 52:118fafcc5c5b


Ignore:
Timestamp:
Apr 7, 2009, 11:55:53 AM (11 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Convert:
svn:b33ecbfc-034c-dc11-8662-000475d9059e/trunk@164
Message:

Fix regression in returning node meta data.

Author: ralphm.
Fixes #42.

Location:
wokkel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wokkel/pubsub.py

    r49 r52  
    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 '')
  • wokkel/test/test_pubsub.py

    r47 r52  
    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
     
    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):
     
    517518        def getNodeInfo(requestor, target, nodeIdentifier):
    518519            return defer.succeed(None)
     520
     521        self.service.getNodeInfo = getNodeInfo
     522        d = self.service.getDiscoInfo(JID('user@example.org/home'),
     523                                      JID('pubsub.example.org'), '')
     524        d.addCallback(cb)
     525        return d
     526
     527
     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})
    519568
    520569        self.service.getNodeInfo = getNodeInfo
Note: See TracChangeset for help on using the changeset viewer.