From e39a2395d7d5b1490e66316cd46b3f31b787cb37 Mon Sep 17 00:00:00 2001 From: Nathan Fritz Date: Fri, 15 Jan 2010 21:07:28 -0800 Subject: xep 30 and 50 always reply from jid iq sent to --- tests/test_pubsubstanzas.py | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'tests') 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 = """""" + xmlstring = """""" 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("""""") + payload2 = ET.fromstring("""""") + 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 = """""" + 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) -- cgit v1.2.3