From 58f77d898f82ab108fa17d562a32c68d3ea35306 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Thu, 5 Aug 2010 20:23:07 -0400 Subject: [PATCH] Updated tests to use a relative import for SleekTest to please Python3. Fixed some tabs/spaces issues. --- tests/test_addresses.py | 175 +++++++++++----------- tests/test_chatstates.py | 64 ++++---- tests/test_disco.py | 98 ++++++------ tests/test_errorstanzas.py | 8 +- tests/test_events.py | 2 +- tests/test_forms.py | 20 +-- tests/test_gmail.py | 2 +- tests/test_iqstanzas.py | 22 +-- tests/test_jid.py | 2 +- tests/test_messagestanzas.py | 2 +- tests/test_presencestanzas.py | 2 +- tests/test_pubsubstanzas.py | 274 +++++++++++++++++----------------- tests/test_stream.py | 2 +- 13 files changed, 337 insertions(+), 336 deletions(-) diff --git a/tests/test_addresses.py b/tests/test_addresses.py index 63d1100..450e136 100644 --- a/tests/test_addresses.py +++ b/tests/test_addresses.py @@ -1,110 +1,111 @@ -from sleektest import * +from . sleektest import * import sleekxmpp.plugins.xep_0033 as xep_0033 class TestAddresses(SleekTest): - def setUp(self): - registerStanzaPlugin(Message, xep_0033.Addresses) + def setUp(self): + registerStanzaPlugin(Message, xep_0033.Addresses) - def testAddAddress(self): - """Testing adding extended stanza address.""" - msg = self.Message() - msg['addresses'].addAddress(atype='to', jid='to@header1.org') - self.checkMessage(msg, """ - - -
- - - """) + def testAddAddress(self): + """Testing adding extended stanza address.""" + msg = self.Message() + msg['addresses'].addAddress(atype='to', jid='to@header1.org') + self.checkMessage(msg, """ + + +
+ + + """) - msg = self.Message() - msg['addresses'].addAddress(atype='replyto', - jid='replyto@header1.org', - desc='Reply address') - self.checkMessage(msg, """ - - -
- - - """) + msg = self.Message() + msg['addresses'].addAddress(atype='replyto', + jid='replyto@header1.org', + desc='Reply address') + self.checkMessage(msg, """ + + +
+ + + """) - def testAddAddresses(self): - """Testing adding multiple extended stanza addresses.""" + def testAddAddresses(self): + """Testing adding multiple extended stanza addresses.""" - xmlstring = """ - - -
-
-
- - - """ + xmlstring = """ + + +
+
+
+ + + """ - msg = self.Message() - msg['addresses'].setAddresses([{'type':'replyto', - 'jid':'replyto@header1.org', - 'desc':'Reply address'}, - {'type':'cc', - 'jid':'cc@header2.org'}, - {'type':'bcc', - 'jid':'bcc@header2.org'}]) - self.checkMessage(msg, xmlstring) + msg = self.Message() + msg['addresses'].setAddresses([ + {'type':'replyto', + 'jid':'replyto@header1.org', + 'desc':'Reply address'}, + {'type':'cc', + 'jid':'cc@header2.org'}, + {'type':'bcc', + 'jid':'bcc@header2.org'}]) + self.checkMessage(msg, xmlstring) - msg = self.Message() - msg['addresses']['replyto'] = [{'jid':'replyto@header1.org', + msg = self.Message() + msg['addresses']['replyto'] = [{'jid':'replyto@header1.org', 'desc':'Reply address'}] - msg['addresses']['cc'] = [{'jid':'cc@header2.org'}] - msg['addresses']['bcc'] = [{'jid':'bcc@header2.org'}] - self.checkMessage(msg, xmlstring) + msg['addresses']['cc'] = [{'jid':'cc@header2.org'}] + msg['addresses']['bcc'] = [{'jid':'bcc@header2.org'}] + self.checkMessage(msg, xmlstring) - def testAddURI(self): - """Testing adding URI attribute to extended stanza address.""" + def testAddURI(self): + """Testing adding URI attribute to extended stanza address.""" - msg = self.Message() - addr = msg['addresses'].addAddress(atype='to', - jid='to@header1.org', - node='foo') - self.checkMessage(msg, """ - - -
- - - """) + msg = self.Message() + addr = msg['addresses'].addAddress(atype='to', + jid='to@header1.org', + node='foo') + self.checkMessage(msg, """ + + +
+ + + """) - addr['uri'] = 'mailto:to@header2.org' - self.checkMessage(msg, """ - - -
- - - """) + addr['uri'] = 'mailto:to@header2.org' + self.checkMessage(msg, """ + + +
+ + + """) - def testDelivered(self): - """Testing delivered attribute of extended stanza addresses.""" + def testDelivered(self): + """Testing delivered attribute of extended stanza addresses.""" - xmlstring = """ - - -
- - - """ + xmlstring = """ + + +
+ + + """ - msg = self.Message() - addr = msg['addresses'].addAddress(jid='to@header1.org', atype='to') - self.checkMessage(msg, xmlstring % '') + msg = self.Message() + addr = msg['addresses'].addAddress(jid='to@header1.org', atype='to') + self.checkMessage(msg, xmlstring % '') - addr['delivered'] = True - self.checkMessage(msg, xmlstring % 'delivered="true"') + addr['delivered'] = True + self.checkMessage(msg, xmlstring % 'delivered="true"') - addr['delivered'] = False - self.checkMessage(msg, xmlstring % '') + addr['delivered'] = False + self.checkMessage(msg, xmlstring % '') suite = unittest.TestLoader().loadTestsFromTestCase(TestAddresses) diff --git a/tests/test_chatstates.py b/tests/test_chatstates.py index bcacb9e..74359df 100644 --- a/tests/test_chatstates.py +++ b/tests/test_chatstates.py @@ -1,44 +1,44 @@ -from sleektest import * +from . sleektest import * import sleekxmpp.plugins.xep_0085 as xep_0085 class TestChatStates(SleekTest): - def setUp(self): - registerStanzaPlugin(Message, xep_0085.Active) - registerStanzaPlugin(Message, xep_0085.Composing) - registerStanzaPlugin(Message, xep_0085.Gone) - registerStanzaPlugin(Message, xep_0085.Inactive) - registerStanzaPlugin(Message, xep_0085.Paused) - - def testCreateChatState(self): - """Testing creating chat states.""" - - xmlstring = """ - - <%s xmlns="http://jabber.org/protocol/chatstates" /> - - """ + def setUp(self): + registerStanzaPlugin(Message, xep_0085.Active) + registerStanzaPlugin(Message, xep_0085.Composing) + registerStanzaPlugin(Message, xep_0085.Gone) + registerStanzaPlugin(Message, xep_0085.Inactive) + registerStanzaPlugin(Message, xep_0085.Paused) - msg = self.Message() - msg['chat_state'].active() - self.checkMessage(msg, xmlstring % 'active', - use_values=False) + def testCreateChatState(self): + """Testing creating chat states.""" - msg['chat_state'].composing() - self.checkMessage(msg, xmlstring % 'composing', - use_values=False) + xmlstring = """ + + <%s xmlns="http://jabber.org/protocol/chatstates" /> + + """ + + msg = self.Message() + msg['chat_state'].active() + self.checkMessage(msg, xmlstring % 'active', + use_values=False) + + msg['chat_state'].composing() + self.checkMessage(msg, xmlstring % 'composing', + use_values=False) - msg['chat_state'].gone() - self.checkMessage(msg, xmlstring % 'gone', - use_values=False) + msg['chat_state'].gone() + self.checkMessage(msg, xmlstring % 'gone', + use_values=False) - msg['chat_state'].inactive() - self.checkMessage(msg, xmlstring % 'inactive', - use_values=False) + msg['chat_state'].inactive() + self.checkMessage(msg, xmlstring % 'inactive', + use_values=False) - msg['chat_state'].paused() - self.checkMessage(msg, xmlstring % 'paused', - use_values=False) + msg['chat_state'].paused() + self.checkMessage(msg, xmlstring % 'paused', + use_values=False) suite = unittest.TestLoader().loadTestsFromTestCase(TestChatStates) diff --git a/tests/test_disco.py b/tests/test_disco.py index 96a12e2..2cc50ee 100644 --- a/tests/test_disco.py +++ b/tests/test_disco.py @@ -1,4 +1,4 @@ -from sleektest import * +from . sleektest import * import sleekxmpp.plugins.xep_0030 as xep_0030 @@ -7,7 +7,7 @@ class TestDisco(SleekTest): def setUp(self): registerStanzaPlugin(Iq, xep_0030.DiscoInfo) registerStanzaPlugin(Iq, xep_0030.DiscoItems) - + def testCreateInfoQueryNoNode(self): """Testing disco#info query with no node.""" iq = self.Iq() @@ -61,7 +61,7 @@ class TestDisco(SleekTest): iq = self.Iq() iq['id'] = "0" iq['disco_info']['node'] = 'foo' - iq['disco_info'].addIdentity('conference', 'text', 'Chatroom') + iq['disco_info'].addIdentity('conference', 'text', 'Chatroom') self.checkIq(iq, """ @@ -76,8 +76,8 @@ class TestDisco(SleekTest): iq = self.Iq() iq['id'] = "0" iq['disco_info']['node'] = 'foo' - iq['disco_info'].addFeature('foo') - iq['disco_info'].addFeature('bar') + iq['disco_info'].addFeature('foo') + iq['disco_info'].addFeature('bar') self.checkIq(iq, """ @@ -93,9 +93,9 @@ class TestDisco(SleekTest): iq = self.Iq() iq['id'] = "0" iq['disco_items']['node'] = 'foo' - iq['disco_items'].addItem('user@localhost') - iq['disco_items'].addItem('user@localhost', 'foo') - iq['disco_items'].addItem('user@localhost', 'bar', 'Testing') + iq['disco_items'].addItem('user@localhost') + iq['disco_items'].addItem('user@localhost', 'foo') + iq['disco_items'].addItem('user@localhost', 'bar', 'Testing') self.checkIq(iq, """ @@ -109,68 +109,68 @@ class TestDisco(SleekTest): def testAddRemoveIdentities(self): """Test adding and removing identities to disco#info stanza""" - ids = [('automation', 'commands', 'AdHoc'), - ('conference', 'text', 'ChatRoom')] + ids = [('automation', 'commands', 'AdHoc'), + ('conference', 'text', 'ChatRoom')] - info = xep_0030.DiscoInfo() - info.addIdentity(*ids[0]) - self.failUnless(info.getIdentities() == [ids[0]]) + info = xep_0030.DiscoInfo() + info.addIdentity(*ids[0]) + self.failUnless(info.getIdentities() == [ids[0]]) - info.delIdentity('automation', 'commands') - self.failUnless(info.getIdentities() == []) + info.delIdentity('automation', 'commands') + self.failUnless(info.getIdentities() == []) - info.setIdentities(ids) - self.failUnless(info.getIdentities() == ids) + info.setIdentities(ids) + self.failUnless(info.getIdentities() == ids) - info.delIdentity('automation', 'commands') - self.failUnless(info.getIdentities() == [ids[1]]) + info.delIdentity('automation', 'commands') + self.failUnless(info.getIdentities() == [ids[1]]) - info.delIdentities() - self.failUnless(info.getIdentities() == []) + info.delIdentities() + self.failUnless(info.getIdentities() == []) def testAddRemoveFeatures(self): """Test adding and removing features to disco#info stanza""" - features = ['foo', 'bar', 'baz'] + features = ['foo', 'bar', 'baz'] - info = xep_0030.DiscoInfo() - info.addFeature(features[0]) - self.failUnless(info.getFeatures() == [features[0]]) + info = xep_0030.DiscoInfo() + info.addFeature(features[0]) + self.failUnless(info.getFeatures() == [features[0]]) - info.delFeature('foo') - self.failUnless(info.getFeatures() == []) + info.delFeature('foo') + self.failUnless(info.getFeatures() == []) - info.setFeatures(features) - self.failUnless(info.getFeatures() == features) + info.setFeatures(features) + self.failUnless(info.getFeatures() == features) - info.delFeature('bar') - self.failUnless(info.getFeatures() == ['foo', 'baz']) + info.delFeature('bar') + self.failUnless(info.getFeatures() == ['foo', 'baz']) - info.delFeatures() - self.failUnless(info.getFeatures() == []) + info.delFeatures() + self.failUnless(info.getFeatures() == []) def testAddRemoveItems(self): """Test adding and removing items to disco#items stanza""" - items = [('user@localhost', None, None), - ('user@localhost', 'foo', None), - ('user@localhost', 'bar', 'Test')] + items = [('user@localhost', None, None), + ('user@localhost', 'foo', None), + ('user@localhost', 'bar', 'Test')] - info = xep_0030.DiscoItems() - self.failUnless(True, ""+str(items[0])) + info = xep_0030.DiscoItems() + self.failUnless(True, ""+str(items[0])) - info.addItem(*(items[0])) - self.failUnless(info.getItems() == [items[0]], info.getItems()) + info.addItem(*(items[0])) + self.failUnless(info.getItems() == [items[0]], info.getItems()) - info.delItem('user@localhost') - self.failUnless(info.getItems() == []) + info.delItem('user@localhost') + self.failUnless(info.getItems() == []) - info.setItems(items) - self.failUnless(info.getItems() == items) + info.setItems(items) + self.failUnless(info.getItems() == items) - info.delItem('user@localhost', 'foo') - self.failUnless(info.getItems() == [items[0], items[2]]) + info.delItem('user@localhost', 'foo') + self.failUnless(info.getItems() == [items[0], items[2]]) + + info.delItems() + self.failUnless(info.getItems() == []) - info.delItems() - self.failUnless(info.getItems() == []) - suite = unittest.TestLoader().loadTestsFromTestCase(TestDisco) diff --git a/tests/test_errorstanzas.py b/tests/test_errorstanzas.py index 788d6c1..d6fafc5 100644 --- a/tests/test_errorstanzas.py +++ b/tests/test_errorstanzas.py @@ -1,7 +1,7 @@ -from sleektest import * +from . sleektest import * class TestErrorStanzas(SleekTest): - + def testSetup(self): """Test setting initial values in error stanza.""" msg = self.Message() @@ -16,7 +16,7 @@ class TestErrorStanzas(SleekTest): def testCondition(self): """Test modifying the error condition.""" - msg = self.Message() + msg = self.Message() msg['error']['condition'] = 'item-not-found' self.checkMessage(msg, """ @@ -42,7 +42,7 @@ class TestErrorStanzas(SleekTest): msg = self.Message() msg['error']['text'] = 'Error!' msg['error']['condition'] = 'internal-server-error' - + del msg['error']['condition'] self.checkMessage(msg, """ diff --git a/tests/test_events.py b/tests/test_events.py index 8f391e1..bbc5832 100644 --- a/tests/test_events.py +++ b/tests/test_events.py @@ -1,5 +1,5 @@ import sleekxmpp -from sleektest import * +from . sleektest import * class TestEvents(SleekTest): diff --git a/tests/test_forms.py b/tests/test_forms.py index 7d37506..d571063 100644 --- a/tests/test_forms.py +++ b/tests/test_forms.py @@ -1,4 +1,4 @@ -from sleektest import * +from . sleektest import * import sleekxmpp.plugins.xep_0004 as xep_0004 @@ -28,11 +28,11 @@ class TestDataForms(SleekTest): msg = self.Message() form = msg['form'] - form.addField(var='f1', - ftype='text-single', + form.addField(var='f1', + ftype='text-single', label='Text', - desc='A text field', - required=True, + desc='A text field', + required=True, value='Some text!') self.checkMessage(msg, """ @@ -47,8 +47,8 @@ class TestDataForms(SleekTest): """) - form['fields'] = [('f1', {'type': 'text-single', - 'label': 'Username', + form['fields'] = [('f1', {'type': 'text-single', + 'label': 'Username', 'required': True}), ('f2', {'type': 'text-private', 'label': 'Password', @@ -58,7 +58,7 @@ class TestDataForms(SleekTest): 'value': 'Enter message.\nA long one even.'}), ('f4', {'type': 'list-single', 'label': 'Message Type', - 'options': [{'label': 'Cool!', + 'options': [{'label': 'Cool!', 'value': 'cool'}, {'label': 'Urgh!', 'value': 'urgh'}]})] @@ -89,13 +89,13 @@ class TestDataForms(SleekTest): def testSetValues(self): """Testing setting form values""" - + msg = self.Message() form = msg['form'] form.setFields([ ('foo', {'type': 'text-single'}), ('bar', {'type': 'list-multi'})]) - + form.setValues({'foo': 'Foo!', 'bar': ['a', 'b']}) diff --git a/tests/test_gmail.py b/tests/test_gmail.py index b2e70d2..dd256e2 100644 --- a/tests/test_gmail.py +++ b/tests/test_gmail.py @@ -1,4 +1,4 @@ -from sleektest import * +from . sleektest import * import sleekxmpp.plugins.gmail_notify as gmail diff --git a/tests/test_iqstanzas.py b/tests/test_iqstanzas.py index 9ae5929..98a01a2 100644 --- a/tests/test_iqstanzas.py +++ b/tests/test_iqstanzas.py @@ -1,4 +1,4 @@ -from sleektest import * +from . sleektest import * from sleekxmpp.xmlstream.stanzabase import ET @@ -18,7 +18,7 @@ class TestIqStanzas(SleekTest): self.checkIq(iq, """ """) - + def testPayload(self): """Test setting Iq stanza payload.""" iq = self.Iq() @@ -38,10 +38,10 @@ class TestIqStanzas(SleekTest): """) - iq = self.Iq() + iq = self.Iq() iq['id'] = 'test' - iq['error']['condition'] = 'feature-not-implemented' - iq['error']['text'] = 'No handlers registered for this request.' + iq['error']['condition'] = 'feature-not-implemented' + iq['error']['text'] = 'No handlers registered for this request.' self.streamSendIq(iq, """ @@ -72,21 +72,21 @@ class TestIqStanzas(SleekTest): """) - self.failUnless(iq['query'] == 'query_ns2', "Query namespace doesn't match") + self.failUnless(iq['query'] == 'query_ns2', "Query namespace doesn't match") - del iq['query'] - self.checkIq(iq, """ + del iq['query'] + self.checkIq(iq, """ """) def testReply(self): """Test setting proper result type in Iq replies.""" iq = self.Iq() - iq['to'] = 'user@localhost' - iq['type'] = 'get' + iq['to'] = 'user@localhost' + iq['type'] = 'get' iq.reply() - self.checkIq(iq, """ + self.checkIq(iq, """ """) diff --git a/tests/test_jid.py b/tests/test_jid.py index 8b4c976..cddac42 100644 --- a/tests/test_jid.py +++ b/tests/test_jid.py @@ -1,4 +1,4 @@ -from sleektest import * +from . sleektest import * from sleekxmpp.xmlstream.jid import JID class TestJIDClass(SleekTest): diff --git a/tests/test_messagestanzas.py b/tests/test_messagestanzas.py index 9b7b0a3..2a1567d 100644 --- a/tests/test_messagestanzas.py +++ b/tests/test_messagestanzas.py @@ -1,4 +1,4 @@ -from sleektest import * +from . sleektest import * from sleekxmpp.stanza.message import Message from sleekxmpp.stanza.htmlim import HTMLIM diff --git a/tests/test_presencestanzas.py b/tests/test_presencestanzas.py index 6c11263..d6a5a38 100644 --- a/tests/test_presencestanzas.py +++ b/tests/test_presencestanzas.py @@ -1,5 +1,5 @@ import sleekxmpp -from sleektest import * +from . sleektest import * from sleekxmpp.stanza.presence import Presence diff --git a/tests/test_pubsubstanzas.py b/tests/test_pubsubstanzas.py index 794fa03..cddfd12 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, """ diff --git a/tests/test_stream.py b/tests/test_stream.py index c2f2667..6e24074 100644 --- a/tests/test_stream.py +++ b/tests/test_stream.py @@ -1,4 +1,4 @@ -from sleektest import * +from . sleektest import * import sleekxmpp.plugins.xep_0033 as xep_0033