pubsub test work

This commit is contained in:
Nathan Fritz 2010-04-23 01:34:28 -07:00
parent e2f841146a
commit c4fa3ab654
2 changed files with 9 additions and 11 deletions

View file

@ -110,13 +110,12 @@ class TestPubsubServer(unittest.TestCase):
def test011createcollectionnode(self): def test011createcollectionnode(self):
"Create a collection node" "Create a collection node"
self.failUnless(self.xmpp1['xep_0060'].create_node(self.pshost, "testnode3", self.statev['defaultconfig'], True)) self.failUnless(self.xmpp1['xep_0060'].create_node(self.pshost, "testnode3", self.statev['defaultconfig'], True), "Could not create collection node")
def test900cleanup(self):
def test999cleanup(self):
"Cleaning up" "Cleaning up"
self.failUnless(self.xmpp1['xep_0060'].deleteNode(self.pshost, 'testnode5'), "Could not delete test node.") self.failUnless(self.xmpp1['xep_0060'].deleteNode(self.pshost, 'testnode2'), "Could not delete test node.")
self.failUnless(self.xmpp1['xep_0060'].deleteNode(self.pshost, 'testnode3'), "Could not delete collection test node.") self.failUnless(self.xmpp1['xep_0060'].deleteNode(self.pshost, 'testnode3'), "Could not delete collection node")
if __name__ == '__main__': if __name__ == '__main__':

View file

@ -172,9 +172,8 @@ class xep_0060(base.base_plugin):
iq.append(pubsub) iq.append(pubsub)
iq.attrib['to'] = jid iq.attrib['to'] = jid
iq.attrib['from'] = self.xmpp.fulljid iq.attrib['from'] = self.xmpp.fulljid
id = iq['id']
result = iq.send() result = iq.send()
if result is not None and result is not False and result.attrib.get('type', 'error') != 'error': if result is not None and result is not False and result['type'] != 'error':
return True return True
else: else:
return False return False
@ -216,6 +215,9 @@ class xep_0060(base.base_plugin):
if result is None or result is False or result['type'] == 'error': return False if result is None or result is False or result['type'] == 'error': return False
return True return True
def addItem(self, jid, node, items=[]):
return self.setItem(jid, node, items)
def deleteItem(self, jid, node, item): def deleteItem(self, jid, node, item):
pubsub = ET.Element('{http://jabber.org/protocol/pubsub}pubsub') pubsub = ET.Element('{http://jabber.org/protocol/pubsub}pubsub')
retract = ET.Element('retract') retract = ET.Element('retract')
@ -232,9 +234,6 @@ class xep_0060(base.base_plugin):
if result is None or result is False or result['type'] == 'error': return False if result is None or result is False or result['type'] == 'error': return False
return True return True
def addItem(self, jid, node, items=[]):
return setItem(jid, node, items)
def getNodes(self, jid): def getNodes(self, jid):
response = self.xmpp.plugin['xep_0030'].getItems(jid) response = self.xmpp.plugin['xep_0030'].getItems(jid)
items = response.findall('{http://jabber.org/protocol/disco#items}query/{http://jabber.org/protocol/disco#items}item') items = response.findall('{http://jabber.org/protocol/disco#items}query/{http://jabber.org/protocol/disco#items}item')