Skip to content

Commit

Permalink
Correctly report disco identity for PubSubService without PubSubResou…
Browse files Browse the repository at this point in the history
…rce.

Author: ralphm.
Fixes #64.
  • Loading branch information
ralphm committed Jan 10, 2010
1 parent 1abdb68 commit cbf7758
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
8 changes: 5 additions & 3 deletions wokkel/pubsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,7 @@ class PubSubService(XMPPHandler, IQHandlerMixin):
def __init__(self, resource=None):
self.resource = resource
self.discoIdentity = {'category': 'pubsub',
'type': 'generic',
'type': 'service',
'name': 'Generic Publish-Subscribe Service'}

self.pubSubFeatures = []
Expand Down Expand Up @@ -1092,7 +1092,9 @@ def toInfo(nodeInfo, info):
features = resource.features
getInfo = resource.getInfo
else:
category, idType, name = self.discoIdentity
category = self.discoIdentity['category']
idType = self.discoIdentity['type']
name = self.discoIdentity['name']
identity = disco.DiscoIdentity(category, idType, name)
features = self.pubSubFeatures
getInfo = self.getNodeInfo
Expand All @@ -1103,7 +1105,7 @@ def toInfo(nodeInfo, info):
info.extend([disco.DiscoFeature("%s#%s" % (NS_PUBSUB, feature))
for feature in features])

d = getInfo(requestor, target, nodeIdentifier or '')
d = defer.maybeDeferred(getInfo, requestor, target, nodeIdentifier or '')
d.addCallback(toInfo, info)
d.addErrback(log.err)
return d
Expand Down
17 changes: 17 additions & 0 deletions wokkel/test/test_pubsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -3156,6 +3156,23 @@ def setUp(self):
self.service.send = self.stub.xmlstream.send


def test_getDiscoInfo(self):
"""
Test getDiscoInfo calls getNodeInfo and returns some minimal info.
"""
def cb(info):
discoInfo = disco.DiscoInfo()
for item in info:
discoInfo.append(item)
self.assertIn(('pubsub', 'service'), discoInfo.identities)
self.assertIn(disco.NS_DISCO_ITEMS, discoInfo.features)

d = self.service.getDiscoInfo(JID('[email protected]/home'),
JID('pubsub.example.org'), '')
d.addCallback(cb)
return d


def test_publish(self):
"""
Non-overridden L{PubSubService.publish} yields unsupported error.
Expand Down

0 comments on commit cbf7758

Please sign in to comment.