summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--conn_tests/test_pubsubserver.py12
-rw-r--r--sleekxmpp/plugins/stanza_pubsub.py2
-rw-r--r--sleekxmpp/xmlstream/stanzabase.py2
-rw-r--r--tests/test_pubsubstanzas.py12
4 files changed, 24 insertions, 4 deletions
diff --git a/conn_tests/test_pubsubserver.py b/conn_tests/test_pubsubserver.py
index 80b86e46..1750636f 100644
--- a/conn_tests/test_pubsubserver.py
+++ b/conn_tests/test_pubsubserver.py
@@ -66,8 +66,20 @@ class TestPubsubServer(unittest.TestCase):
#print("%s == %s" % (nconfig.getValues(), self.statev['defaultconfig'].getValues()))
self.failUnless(nconfig.getValues() == self.statev['defaultconfig'].getValues(), "Configuration does not match")
self.failUnless(self.xmpp1['xep_0060'].setNodeConfig(self.pshost, 'testnode2', nconfig))
+
+ def test006subscribetonode(self):
+ """Subscribe to node from account 2"""
+ self.failUnless(self.xmpp2['xep_0060'].subscribe(self.pshost, "testnode2"))
+
+ def test007publishitem(self):
+ """Publishing item"""
+ item = ET.Element('{http://netflint.net/protocol/test}test')
+ result = self.xmpp1['xep_0060'].setItem(self.pshost, "testnode2", (('test_node1', item),))
+ self.failUnless(result)
+ #need to add check for update
def test999cleanup(self):
+ "Cleaning up"
self.failUnless(self.xmpp1['xep_0060'].deleteNode(self.pshost, 'testnode2'))
diff --git a/sleekxmpp/plugins/stanza_pubsub.py b/sleekxmpp/plugins/stanza_pubsub.py
index 1d8c86f2..d25c2b3a 100644
--- a/sleekxmpp/plugins/stanza_pubsub.py
+++ b/sleekxmpp/plugins/stanza_pubsub.py
@@ -2,6 +2,7 @@ from .. xmlstream.stanzabase import ElementBase, ET, JID
from .. stanza.iq import Iq
from .. basexmpp import basexmpp
from .. xmlstream.xmlstream import XMLStream
+import logging
from . import xep_0004
def stanzaPlugin(stanza, plugin):
@@ -283,7 +284,6 @@ class Configure(ElementBase):
self.xml.remove(config)
stanzaPlugin(Pubsub, Configure)
-stanzaPlugin(Create, Configure)
class DefaultConfig(ElementBase):
namespace = 'http://jabber.org/protocol/pubsub#owner'
diff --git a/sleekxmpp/xmlstream/stanzabase.py b/sleekxmpp/xmlstream/stanzabase.py
index 6ed5cbd0..f72aa6e2 100644
--- a/sleekxmpp/xmlstream/stanzabase.py
+++ b/sleekxmpp/xmlstream/stanzabase.py
@@ -120,6 +120,8 @@ class ElementBase(tostring.ToString):
if tagargs[0] not in (self.plugins, self.plugin_attrib): return False
founditerable = False
for iterable in self.iterables:
+ if nodes[1:] == []:
+ break
founditerable = iterable.match(nodes[1:])
if founditerable: break;
for evals in tagargs[1:]:
diff --git a/tests/test_pubsubstanzas.py b/tests/test_pubsubstanzas.py
index ed37314d..2d1bf3b7 100644
--- a/tests/test_pubsubstanzas.py
+++ b/tests/test_pubsubstanzas.py
@@ -85,12 +85,11 @@ class testpubsubstanzas(unittest.TestCase):
"Testing iq/pubsub/create&configure stanzas"
from sleekxmpp.plugins import xep_0004
iq = self.ps.Iq()
- iq['pubsub']['create']['configure']
iq['pubsub']['create']['node'] = 'mynode'
form = xep_0004.Form()
form.addField('pubsub#title', ftype='text-single', value='This thing is awesome')
- iq['pubsub']['create']['configure']['config'] = form
- xmlstring = """<iq id="0"><pubsub xmlns="http://jabber.org/protocol/pubsub"><create node="mynode"><configure><x xmlns="jabber:x:data" type="form"><field var="pubsub#title" type="text-single"><value>This thing is awesome</value></field></x></configure></create></pubsub></iq>"""
+ iq['pubsub']['configure']['config'] = form
+ xmlstring = """<iq id="0"><pubsub xmlns="http://jabber.org/protocol/pubsub"><create node="mynode" /><configure><x xmlns="jabber:x:data" type="form"><field var="pubsub#title" type="text-single"><value>This thing is awesome</value></field></x></configure></pubsub></iq>"""
iq2 = self.ps.Iq(None, self.ps.ET.fromstring(xmlstring))
iq3 = self.ps.Iq()
values = iq2.getValues()
@@ -162,5 +161,12 @@ class testpubsubstanzas(unittest.TestCase):
iq3 = self.ps.Iq()
iq3.setValues(iq2.getValues())
self.failUnless(xmlstring == str(iq) == str(iq2) == str(iq3))
+
+ def testCreateConfigGet(self):
+ """Testing getting config from full create"""
+ xml = """<iq to="pubsub.asdf" type="set" id="E" from="fritzy@asdf/87292ede-524d-4117-9076-d934ed3db8e7"><pubsub xmlns="http://jabber.org/protocol/pubsub"><create node="testnode2" /><configure><x xmlns="jabber:x:data" type="submit"><field var="FORM_TYPE" type="hidden"><value>http://jabber.org/protocol/pubsub#node_config</value></field><field var="pubsub#node_type" type="list-single" label="Select the node type"><value>leaf</value></field><field var="pubsub#title" type="text-single" label="A friendly name for the node" /><field var="pubsub#deliver_notifications" type="boolean" label="Deliver event notifications"><value>1</value></field><field var="pubsub#deliver_payloads" type="boolean" label="Deliver payloads with event notifications"><value>1</value></field><field var="pubsub#notify_config" type="boolean" label="Notify subscribers when the node configuration changes" /><field var="pubsub#notify_delete" type="boolean" label="Notify subscribers when the node is deleted" /><field var="pubsub#notify_retract" type="boolean" label="Notify subscribers when items are removed from the node"><value>1</value></field><field var="pubsub#notify_sub" type="boolean" label="Notify owners about new subscribers and unsubscribes" /><field var="pubsub#persist_items" type="boolean" label="Persist items in storage" /><field var="pubsub#max_items" type="text-single" label="Max # of items to persist"><value>10</value></field><field var="pubsub#subscribe" type="boolean" label="Whether to allow subscriptions"><value>1</value></field><field var="pubsub#access_model" type="list-single" label="Specify the subscriber model"><value>open</value></field><field var="pubsub#publish_model" type="list-single" label="Specify the publisher model"><value>publishers</value></field><field var="pubsub#send_last_published_item" type="list-single" label="Send last published item"><value>never</value></field><field var="pubsub#presence_based_delivery" type="boolean" label="Deliver notification only to available users" /></x></configure></pubsub></iq>"""
+ iq = self.ps.Iq(None, self.ps.ET.fromstring(xml))
+ config = iq['pubsub']['configure']['config']
+ self.failUnless(config.getValues() != {})
suite = unittest.TestLoader().loadTestsFromTestCase(testpubsubstanzas)