From 58f77d898f82ab108fa17d562a32c68d3ea35306 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Thu, 5 Aug 2010 20:23:07 -0400 Subject: Updated tests to use a relative import for SleekTest to please Python3. Fixed some tabs/spaces issues. --- tests/test_pubsubstanzas.py | 274 ++++++++++++++++++++++---------------------- 1 file changed, 137 insertions(+), 137 deletions(-) (limited to 'tests/test_pubsubstanzas.py') diff --git a/tests/test_pubsubstanzas.py b/tests/test_pubsubstanzas.py index 794fa03a..cddfd12b 100644 --- a/tests/test_pubsubstanzas.py +++ b/tests/test_pubsubstanzas.py @@ -1,4 +1,4 @@ -from sleektest import * +from . sleektest import * import sleekxmpp.plugins.xep_0004 as xep_0004 import sleekxmpp.plugins.stanza_pubsub as pubsub @@ -25,7 +25,7 @@ class TestPubsubStanzas(SleekTest): """) - + def testSubscriptions(self): "Testing iq/pubsub/subscriptions/subscription stanzas" iq = self.Iq() @@ -38,7 +38,7 @@ class TestPubsubStanzas(SleekTest): sub2['subscription'] = 'subscribed' iq['pubsub']['subscriptions'].append(sub1) iq['pubsub']['subscriptions'].append(sub2) - self.checkIq(iq, """ + self.checkIq(iq, """ @@ -55,7 +55,7 @@ class TestPubsubStanzas(SleekTest): iq['pubsub']['subscription']['node'] = 'testnode alsdkjfas' iq['pubsub']['subscription']['jid'] = "fritzy@netflint.net/sleekxmpp" iq['pubsub']['subscription']['subscription'] = 'unconfigured' - self.checkIq(iq, """ + self.checkIq(iq, """ @@ -88,7 +88,7 @@ class TestPubsubStanzas(SleekTest): item2['payload'] = payload2 iq['pubsub']['items'].append(item) iq['pubsub']['items'].append(item2) - self.checkIq(iq, """ + self.checkIq(iq, """ @@ -112,8 +112,8 @@ class TestPubsubStanzas(SleekTest): "Testing iq/pubsub/create&configure stanzas" iq = self.Iq() iq['pubsub']['create']['node'] = 'mynode' - iq['pubsub']['configure']['form'].addField('pubsub#title', - ftype='text-single', + iq['pubsub']['configure']['form'].addField('pubsub#title', + ftype='text-single', value='This thing is awesome') self.checkIq(iq, """ @@ -131,12 +131,12 @@ class TestPubsubStanzas(SleekTest): def testState(self): "Testing iq/psstate stanzas" - iq = self.Iq() - iq['psstate']['node']= 'mynode' + iq = self.Iq() + iq['psstate']['node']= 'mynode' iq['psstate']['item']= 'myitem' pl = ET.Element('{http://andyet.net/protocol/pubsubqueue}claimed') iq['psstate']['payload'] = pl - self.checkIq(iq, """ + self.checkIq(iq, """ @@ -144,16 +144,16 @@ class TestPubsubStanzas(SleekTest): """) def testDefault(self): - "Testing iq/pubsub_owner/default stanzas" - iq = self.Iq() - iq['pubsub_owner']['default'] - iq['pubsub_owner']['default']['node'] = 'mynode' - iq['pubsub_owner']['default']['type'] = 'leaf' - iq['pubsub_owner']['default']['form'].addField('pubsub#title', - ftype='text-single', + "Testing iq/pubsub_owner/default stanzas" + iq = self.Iq() + iq['pubsub_owner']['default'] + iq['pubsub_owner']['default']['node'] = 'mynode' + iq['pubsub_owner']['default']['type'] = 'leaf' + iq['pubsub_owner']['default']['form'].addField('pubsub#title', + ftype='text-single', value='This thing is awesome') self.checkIq(iq, """ - + @@ -166,54 +166,54 @@ class TestPubsubStanzas(SleekTest): """, use_values=False) def testSubscribe(self): - "Testing iq/pubsub/subscribe stanzas" - iq = self.Iq() - iq['pubsub']['subscribe']['options'] - iq['pubsub']['subscribe']['node'] = 'cheese' - iq['pubsub']['subscribe']['jid'] = 'fritzy@netflint.net/sleekxmpp' - iq['pubsub']['subscribe']['options']['node'] = 'cheese' - iq['pubsub']['subscribe']['options']['jid'] = 'fritzy@netflint.net/sleekxmpp' - form = xep_0004.Form() - form.addField('pubsub#title', ftype='text-single', value='This thing is awesome') - iq['pubsub']['subscribe']['options']['options'] = form + "testing iq/pubsub/subscribe stanzas" + iq = self.Iq() + iq['pubsub']['subscribe']['options'] + iq['pubsub']['subscribe']['node'] = 'cheese' + iq['pubsub']['subscribe']['jid'] = 'fritzy@netflint.net/sleekxmpp' + iq['pubsub']['subscribe']['options']['node'] = 'cheese' + iq['pubsub']['subscribe']['options']['jid'] = 'fritzy@netflint.net/sleekxmpp' + form = xep_0004.Form() + form.addField('pubsub#title', ftype='text-single', value='this thing is awesome') + iq['pubsub']['subscribe']['options']['options'] = form self.checkIq(iq, """ - - - - - - - This thing is awesome - - - - - - """, use_values=False) + + + + + + + this thing is awesome + + + + + + """, use_values=False) def testPublish(self): - "Testing iq/pubsub/publish stanzas" - iq = self.Iq() - iq['pubsub']['publish']['node'] = 'thingers' - payload = ET.fromstring(""" + "Testing iq/pubsub/publish stanzas" + iq = self.Iq() + iq['pubsub']['publish']['node'] = 'thingers' + payload = ET.fromstring(""" """) - payload2 = ET.fromstring(""" + payload2 = ET.fromstring(""" """) - item = pubsub.Item() - item['id'] = 'asdf' - item['payload'] = payload - item2 = pubsub.Item() - item2['id'] = 'asdf2' - item2['payload'] = payload2 - iq['pubsub']['publish'].append(item) - iq['pubsub']['publish'].append(item2) - + item = pubsub.Item() + item['id'] = 'asdf' + item['payload'] = payload + item2 = pubsub.Item() + item2['id'] = 'asdf2' + item2['payload'] = payload2 + iq['pubsub']['publish'].append(item) + iq['pubsub']['publish'].append(item2) + self.checkIq(iq, """ @@ -235,19 +235,19 @@ class TestPubsubStanzas(SleekTest): """) def testDelete(self): - "Testing iq/pubsub_owner/delete stanzas" - iq = self.Iq() - iq['pubsub_owner']['delete']['node'] = 'thingers' + "Testing iq/pubsub_owner/delete stanzas" + iq = self.Iq() + iq['pubsub_owner']['delete']['node'] = 'thingers' self.checkIq(iq, """ - + """) def testCreateConfigGet(self): - """Testing getting config from full create""" - iq = self.Iq() + """Testing getting config from full create""" + iq = self.Iq() iq['to'] = 'pubsub.asdf' iq['from'] = 'fritzy@asdf/87292ede-524d-4117-9076-d934ed3db8e7' iq['type'] = 'set' @@ -348,16 +348,16 @@ class TestPubsubStanzas(SleekTest): """) def testItemEvent(self): - """Testing message/pubsub_event/items/item""" - msg = self.Message() - item = pubsub.EventItem() - pl = ET.Element('{http://netflint.net/protocol/test}test', {'failed':'3', 'passed':'24'}) - item['payload'] = pl - item['id'] = 'abc123' - msg['pubsub_event']['items'].append(item) - msg['pubsub_event']['items']['node'] = 'cheese' - msg['type'] = 'normal' - self.checkMessage(msg, """ + """Testing message/pubsub_event/items/item""" + msg = self.Message() + item = pubsub.EventItem() + pl = ET.Element('{http://netflint.net/protocol/test}test', {'failed':'3', 'passed':'24'}) + item['payload'] = pl + item['id'] = 'abc123' + msg['pubsub_event']['items'].append(item) + msg['pubsub_event']['items']['node'] = 'cheese' + msg['type'] = 'normal' + self.checkMessage(msg, """ @@ -369,21 +369,21 @@ class TestPubsubStanzas(SleekTest): """) def testItemsEvent(self): - """Testing multiple message/pubsub_event/items/item""" - msg = self.Message() - item = pubsub.EventItem() - item2 = pubsub.EventItem() - pl = ET.Element('{http://netflint.net/protocol/test}test', {'failed':'3', 'passed':'24'}) - pl2 = ET.Element('{http://netflint.net/protocol/test-other}test', {'total':'27', 'failed':'3'}) - item2['payload'] = pl2 - item['payload'] = pl - item['id'] = 'abc123' - item2['id'] = '123abc' - msg['pubsub_event']['items'].append(item) - msg['pubsub_event']['items'].append(item2) - msg['pubsub_event']['items']['node'] = 'cheese' - msg['type'] = 'normal' - self.checkMessage(msg, """ + """Testing multiple message/pubsub_event/items/item""" + msg = self.Message() + item = pubsub.EventItem() + item2 = pubsub.EventItem() + pl = ET.Element('{http://netflint.net/protocol/test}test', {'failed':'3', 'passed':'24'}) + pl2 = ET.Element('{http://netflint.net/protocol/test-other}test', {'total':'27', 'failed':'3'}) + item2['payload'] = pl2 + item['payload'] = pl + item['id'] = 'abc123' + item2['id'] = '123abc' + msg['pubsub_event']['items'].append(item) + msg['pubsub_event']['items'].append(item2) + msg['pubsub_event']['items']['node'] = 'cheese' + msg['type'] = 'normal' + self.checkMessage(msg, """ @@ -398,24 +398,24 @@ class TestPubsubStanzas(SleekTest): """) def testItemsEvent(self): - """Testing message/pubsub_event/items/item & retract mix""" - msg = self.Message() - item = pubsub.EventItem() - item2 = pubsub.EventItem() - pl = ET.Element('{http://netflint.net/protocol/test}test', {'failed':'3', 'passed':'24'}) - pl2 = ET.Element('{http://netflint.net/protocol/test-other}test', {'total':'27', 'failed':'3'}) - item2['payload'] = pl2 - retract = pubsub.EventRetract() - retract['id'] = 'aabbcc' - item['payload'] = pl - item['id'] = 'abc123' - item2['id'] = '123abc' - msg['pubsub_event']['items'].append(item) - msg['pubsub_event']['items'].append(retract) - msg['pubsub_event']['items'].append(item2) - msg['pubsub_event']['items']['node'] = 'cheese' - msg['type'] = 'normal' - self.checkMessage(msg, """ + """Testing message/pubsub_event/items/item & retract mix""" + msg = self.Message() + item = pubsub.EventItem() + item2 = pubsub.EventItem() + pl = ET.Element('{http://netflint.net/protocol/test}test', {'failed':'3', 'passed':'24'}) + pl2 = ET.Element('{http://netflint.net/protocol/test-other}test', {'total':'27', 'failed':'3'}) + item2['payload'] = pl2 + retract = pubsub.EventRetract() + retract['id'] = 'aabbcc' + item['payload'] = pl + item['id'] = 'abc123' + item2['id'] = '123abc' + msg['pubsub_event']['items'].append(item) + msg['pubsub_event']['items'].append(retract) + msg['pubsub_event']['items'].append(item2) + msg['pubsub_event']['items']['node'] = 'cheese' + msg['type'] = 'normal' + self.checkMessage(msg, """ @@ -430,12 +430,12 @@ class TestPubsubStanzas(SleekTest): """) def testCollectionAssociate(self): - """Testing message/pubsub_event/collection/associate""" - msg = self.Message() - msg['pubsub_event']['collection']['associate']['node'] = 'cheese' - msg['pubsub_event']['collection']['node'] = 'cheeseburger' - msg['type'] = 'headline' - self.checkMessage(msg, """ + """Testing message/pubsub_event/collection/associate""" + msg = self.Message() + msg['pubsub_event']['collection']['associate']['node'] = 'cheese' + msg['pubsub_event']['collection']['node'] = 'cheeseburger' + msg['type'] = 'headline' + self.checkMessage(msg, """ @@ -445,12 +445,12 @@ class TestPubsubStanzas(SleekTest): """) def testCollectionDisassociate(self): - """Testing message/pubsub_event/collection/disassociate""" - msg = self.Message() - msg['pubsub_event']['collection']['disassociate']['node'] = 'cheese' - msg['pubsub_event']['collection']['node'] = 'cheeseburger' - msg['type'] = 'headline' - self.checkMessage(msg, """ + """Testing message/pubsub_event/collection/disassociate""" + msg = self.Message() + msg['pubsub_event']['collection']['disassociate']['node'] = 'cheese' + msg['pubsub_event']['collection']['node'] = 'cheeseburger' + msg['type'] = 'headline' + self.checkMessage(msg, """ @@ -460,15 +460,15 @@ class TestPubsubStanzas(SleekTest): """) def testEventConfiguration(self): - """Testing message/pubsub_event/configuration/config""" - msg = self.Message() - msg['pubsub_event']['configuration']['node'] = 'cheese' - msg['pubsub_event']['configuration']['form'].addField('pubsub#title', - ftype='text-single', + """Testing message/pubsub_event/configuration/config""" + msg = self.Message() + msg['pubsub_event']['configuration']['node'] = 'cheese' + msg['pubsub_event']['configuration']['form'].addField('pubsub#title', + ftype='text-single', value='This thing is awesome') - msg['type'] = 'headline' + msg['type'] = 'headline' self.checkMessage(msg, """ - + @@ -481,11 +481,11 @@ class TestPubsubStanzas(SleekTest): """) def testEventPurge(self): - """Testing message/pubsub_event/purge""" - msg = self.Message() - msg['pubsub_event']['purge']['node'] = 'pickles' - msg['type'] = 'headline' - self.checkMessage(msg, """ + """Testing message/pubsub_event/purge""" + msg = self.Message() + msg['pubsub_event']['purge']['node'] = 'pickles' + msg['type'] = 'headline' + self.checkMessage(msg, """ @@ -493,15 +493,15 @@ class TestPubsubStanzas(SleekTest): """) def testEventSubscription(self): - """Testing message/pubsub_event/subscription""" - msg = self.Message() - msg['pubsub_event']['subscription']['node'] = 'pickles' - msg['pubsub_event']['subscription']['jid'] = 'fritzy@netflint.net/test' - msg['pubsub_event']['subscription']['subid'] = 'aabb1122' - msg['pubsub_event']['subscription']['subscription'] = 'subscribed' - msg['pubsub_event']['subscription']['expiry'] = 'presence' - msg['type'] = 'headline' - self.checkMessage(msg, """ + """Testing message/pubsub_event/subscription""" + msg = self.Message() + msg['pubsub_event']['subscription']['node'] = 'pickles' + msg['pubsub_event']['subscription']['jid'] = 'fritzy@netflint.net/test' + msg['pubsub_event']['subscription']['subid'] = 'aabb1122' + msg['pubsub_event']['subscription']['subscription'] = 'subscribed' + msg['pubsub_event']['subscription']['expiry'] = 'presence' + msg['type'] = 'headline' + self.checkMessage(msg, """ -- cgit v1.2.3