diff options
author | Nathan Fritz <fritzy@netflint.net> | 2010-01-25 10:40:50 -0800 |
---|---|---|
committer | Nathan Fritz <fritzy@netflint.net> | 2010-01-25 10:40:50 -0800 |
commit | 65dd83d4e174fc5f88ea90b32dd9e3ebf1787294 (patch) | |
tree | 9710ceeebb74d49c6ae1926bae7be5188c4a9066 /tests | |
parent | 6e4c1128ec8f01d31c7714c13db02ff20c7a0a40 (diff) | |
parent | 6b130eb94775da8675750a0a9aed75fa6f328137 (diff) | |
download | slixmpp-65dd83d4e174fc5f88ea90b32dd9e3ebf1787294.tar.gz slixmpp-65dd83d4e174fc5f88ea90b32dd9e3ebf1787294.tar.bz2 slixmpp-65dd83d4e174fc5f88ea90b32dd9e3ebf1787294.tar.xz slixmpp-65dd83d4e174fc5f88ea90b32dd9e3ebf1787294.zip |
Merge branch 'master' of github.com:fritzy/SleekXMPP
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_pubsubstanzas.py | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/tests/test_pubsubstanzas.py b/tests/test_pubsubstanzas.py index b84a5170..4c3737d7 100644 --- a/tests/test_pubsubstanzas.py +++ b/tests/test_pubsubstanzas.py @@ -1,5 +1,6 @@ import unittest from xml.etree import cElementTree as ET +from sleekxmpp.xmlstream.matcher.stanzapath import StanzaPath class testpubsubstanzas(unittest.TestCase): @@ -23,7 +24,8 @@ class testpubsubstanzas(unittest.TestCase): iq3 = self.ps.Iq() values = iq2.getValues() iq3.setValues(values) - self.failUnless(xmlstring == str(iq) == str(iq2) == str(iq3)) + self.failUnless(xmlstring == str(iq) == str(iq2) == str(iq3), "3 methods for creating stanza don't match") + self.failUnless(iq.match('iq@id=0/pubsub/affiliations/affiliation@node=testnode2@affiliation=publisher'), 'Match path failed') def testSubscriptions(self): "Testing iq/pubsub/subscriptions/subscription stanzas" @@ -34,9 +36,10 @@ class testpubsubstanzas(unittest.TestCase): sub2 = self.ps.Subscription() sub2['node'] = 'testnode2' sub2['jid'] = 'boogers@bork.top/bill' + sub2['subscription'] = 'subscribed' iq['pubsub']['subscriptions'].append(sub1) iq['pubsub']['subscriptions'].append(sub2) - xmlstring = """<iq id="0"><pubsub xmlns="http://jabber.org/protocol/pubsub"><subscriptions><subscription node="testnode" jid="steve@myserver.tld/someresource" /><subscription node="testnode2" jid="boogers@bork.top/bill" /></subscriptions></pubsub></iq>""" + xmlstring = """<iq id="0"><pubsub xmlns="http://jabber.org/protocol/pubsub"><subscriptions><subscription node="testnode" jid="steve@myserver.tld/someresource" /><subscription node="testnode2" jid="boogers@bork.top/bill" subscription="subscribed" /></subscriptions></pubsub></iq>""" iq2 = self.ps.Iq(None, self.ps.ET.fromstring(xmlstring)) iq3 = self.ps.Iq() values = iq2.getValues() @@ -124,5 +127,30 @@ class testpubsubstanzas(unittest.TestCase): values = iq2.getValues() iq3.setValues(values) self.failUnless(xmlstring == str(iq) == str(iq2) == str(iq3)) + + def testPublish(self): + iq = self.ps.Iq() + iq['pubsub']['publish']['node'] = 'thingers' + payload = ET.fromstring("""<thinger xmlns="http://andyet.net/protocol/thinger" x="1" y='2'><child1 /><child2 normandy='cheese' foo='bar' /></thinger>""") + payload2 = ET.fromstring("""<thinger2 xmlns="http://andyet.net/protocol/thinger2" x="12" y='22'><child12 /><child22 normandy='cheese2' foo='bar2' /></thinger2>""") + item = self.ps.Item() + item['id'] = 'asdf' + item['payload'] = payload + item2 = self.ps.Item() + item2['id'] = 'asdf2' + item2['payload'] = payload2 + iq['pubsub']['publish'].append(item) + iq['pubsub']['publish'].append(item2) + xmlstring = """<iq id="0"><pubsub xmlns="http://jabber.org/protocol/pubsub"><publish node="thingers"><item id="asdf"><thinger xmlns="http://andyet.net/protocol/thinger" y="2" x="1"><child1 /><child2 foo="bar" normandy="cheese" /></thinger></item><item id="asdf2"><thinger2 xmlns="http://andyet.net/protocol/thinger2" y="22" x="12"><child12 /><child22 foo="bar2" normandy="cheese2" /></thinger2></item></publish></pubsub></iq>""" + iq2 = self.ps.Iq(None, self.ps.ET.fromstring(xmlstring)) + iq3 = self.ps.Iq() + values = iq2.getValues() + iq3.setValues(values) + #print() + #print(xmlstring) + #print(iq) + #print(iq2) + #print(iq3) + self.failUnless(xmlstring == str(iq) == str(iq2) == str(iq3)) suite = unittest.TestLoader().loadTestsFromTestCase(testpubsubstanzas) |