summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2010-08-05 20:23:07 -0400
committerLance Stout <lancestout@gmail.com>2010-08-05 20:23:07 -0400
commit58f77d898f82ab108fa17d562a32c68d3ea35306 (patch)
tree441530e8518726fb55b2056340fa5ea03bec7638 /tests
parentc54466596f3dcc7a35a41c49fff0d057d4a8ed8f (diff)
downloadslixmpp-58f77d898f82ab108fa17d562a32c68d3ea35306.tar.gz
slixmpp-58f77d898f82ab108fa17d562a32c68d3ea35306.tar.bz2
slixmpp-58f77d898f82ab108fa17d562a32c68d3ea35306.tar.xz
slixmpp-58f77d898f82ab108fa17d562a32c68d3ea35306.zip
Updated tests to use a relative import for SleekTest to please Python3.
Fixed some tabs/spaces issues.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_addresses.py203
-rw-r--r--tests/test_chatstates.py76
-rw-r--r--tests/test_disco.py98
-rw-r--r--tests/test_errorstanzas.py8
-rw-r--r--tests/test_events.py2
-rw-r--r--tests/test_forms.py20
-rw-r--r--tests/test_gmail.py2
-rw-r--r--tests/test_iqstanzas.py22
-rw-r--r--tests/test_jid.py2
-rw-r--r--tests/test_messagestanzas.py2
-rw-r--r--tests/test_presencestanzas.py2
-rw-r--r--tests/test_pubsubstanzas.py274
-rw-r--r--tests/test_stream.py2
13 files changed, 357 insertions, 356 deletions
diff --git a/tests/test_addresses.py b/tests/test_addresses.py
index 63d11003..450e1362 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 testAddAddress(self):
- """Testing adding extended stanza address."""
- msg = self.Message()
- msg['addresses'].addAddress(atype='to', jid='to@header1.org')
- self.checkMessage(msg, """
- <message>
- <addresses xmlns="http://jabber.org/protocol/address">
- <address jid="to@header1.org" type="to" />
- </addresses>
- </message>
- """)
-
- msg = self.Message()
- msg['addresses'].addAddress(atype='replyto',
- jid='replyto@header1.org',
- desc='Reply address')
- self.checkMessage(msg, """
- <message>
- <addresses xmlns="http://jabber.org/protocol/address">
- <address jid="replyto@header1.org" type="replyto" desc="Reply address" />
- </addresses>
- </message>
- """)
-
- def testAddAddresses(self):
- """Testing adding multiple extended stanza addresses."""
-
- xmlstring = """
- <message>
- <addresses xmlns="http://jabber.org/protocol/address">
- <address jid="replyto@header1.org" type="replyto" desc="Reply address" />
- <address jid="cc@header2.org" type="cc" />
- <address jid="bcc@header2.org" type="bcc" />
- </addresses>
- </message>
- """
-
- 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',
+ 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, """
+ <message>
+ <addresses xmlns="http://jabber.org/protocol/address">
+ <address jid="to@header1.org" type="to" />
+ </addresses>
+ </message>
+ """)
+
+ msg = self.Message()
+ msg['addresses'].addAddress(atype='replyto',
+ jid='replyto@header1.org',
+ desc='Reply address')
+ self.checkMessage(msg, """
+ <message>
+ <addresses xmlns="http://jabber.org/protocol/address">
+ <address jid="replyto@header1.org" type="replyto" desc="Reply address" />
+ </addresses>
+ </message>
+ """)
+
+ def testAddAddresses(self):
+ """Testing adding multiple extended stanza addresses."""
+
+ xmlstring = """
+ <message>
+ <addresses xmlns="http://jabber.org/protocol/address">
+ <address jid="replyto@header1.org" type="replyto" desc="Reply address" />
+ <address jid="cc@header2.org" type="cc" />
+ <address jid="bcc@header2.org" type="bcc" />
+ </addresses>
+ </message>
+ """
+
+ 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',
'desc':'Reply address'}]
- 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."""
-
- msg = self.Message()
- addr = msg['addresses'].addAddress(atype='to',
- jid='to@header1.org',
- node='foo')
- self.checkMessage(msg, """
- <message>
- <addresses xmlns="http://jabber.org/protocol/address">
- <address node="foo" jid="to@header1.org" type="to" />
- </addresses>
- </message>
- """)
-
- addr['uri'] = 'mailto:to@header2.org'
- self.checkMessage(msg, """
- <message>
- <addresses xmlns="http://jabber.org/protocol/address">
- <address type="to" uri="mailto:to@header2.org" />
- </addresses>
- </message>
- """)
-
- def testDelivered(self):
- """Testing delivered attribute of extended stanza addresses."""
-
- xmlstring = """
- <message>
- <addresses xmlns="http://jabber.org/protocol/address">
- <address %s jid="to@header1.org" type="to" />
- </addresses>
- </message>
- """
-
- 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'] = False
- 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."""
+
+ msg = self.Message()
+ addr = msg['addresses'].addAddress(atype='to',
+ jid='to@header1.org',
+ node='foo')
+ self.checkMessage(msg, """
+ <message>
+ <addresses xmlns="http://jabber.org/protocol/address">
+ <address node="foo" jid="to@header1.org" type="to" />
+ </addresses>
+ </message>
+ """)
+
+ addr['uri'] = 'mailto:to@header2.org'
+ self.checkMessage(msg, """
+ <message>
+ <addresses xmlns="http://jabber.org/protocol/address">
+ <address type="to" uri="mailto:to@header2.org" />
+ </addresses>
+ </message>
+ """)
+
+ def testDelivered(self):
+ """Testing delivered attribute of extended stanza addresses."""
+
+ xmlstring = """
+ <message>
+ <addresses xmlns="http://jabber.org/protocol/address">
+ <address %s jid="to@header1.org" type="to" />
+ </addresses>
+ </message>
+ """
+
+ 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'] = False
+ self.checkMessage(msg, xmlstring % '')
suite = unittest.TestLoader().loadTestsFromTestCase(TestAddresses)
diff --git a/tests/test_chatstates.py b/tests/test_chatstates.py
index bcacb9e5..74359df9 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 = """
- <message>
- <%s xmlns="http://jabber.org/protocol/chatstates" />
- </message>
- """
-
- 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'].inactive()
- self.checkMessage(msg, xmlstring % 'inactive',
- use_values=False)
-
- msg['chat_state'].paused()
- self.checkMessage(msg, xmlstring % 'paused',
- use_values=False)
+ 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 = """
+ <message>
+ <%s xmlns="http://jabber.org/protocol/chatstates" />
+ </message>
+ """
+
+ 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'].inactive()
+ self.checkMessage(msg, xmlstring % 'inactive',
+ 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 96a12e2a..2cc50ee0 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, """
<iq id="0">
@@ -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, """
<iq id="0">
@@ -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, """
<iq id="0">
@@ -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 788d6c12..d6fafc59 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 8f391e1d..bbc5832e 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 7d37506d..d5710633 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):
</message>
""")
- 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 b2e70d21..dd256e27 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 9ae59297..98a01a26 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, """
<iq id="0" />
""")
-
+
def testPayload(self):
"""Test setting Iq stanza payload."""
iq = self.Iq()
@@ -38,10 +38,10 @@ class TestIqStanzas(SleekTest):
</iq>
""")
- 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, """
<iq id="test" type="error">
@@ -72,21 +72,21 @@ class TestIqStanzas(SleekTest):
</iq>
""")
- 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, """
<iq id="0" />
""")
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, """
<iq id="0" type="result" />
""")
diff --git a/tests/test_jid.py b/tests/test_jid.py
index 8b4c9761..cddac424 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 9b7b0a3f..2a1567da 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 6c11263f..d6a5a388 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 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):
</affiliations>
</pubsub>
</iq>""")
-
+
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, """
<iq id="0">
<pubsub xmlns="http://jabber.org/protocol/pubsub">
<subscriptions>
@@ -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, """
<iq id="0">
<pubsub xmlns="http://jabber.org/protocol/pubsub">
<subscription node="testnode alsdkjfas" jid="fritzy@netflint.net/sleekxmpp" subscription="unconfigured">
@@ -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, """
<iq id="0">
<pubsub xmlns="http://jabber.org/protocol/pubsub">
<items>
@@ -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, """
<iq id="0">
@@ -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, """
<iq id="0">
<state xmlns="http://jabber.org/protocol/psstate" node="mynode" item="myitem">
<claimed xmlns="http://andyet.net/protocol/pubsubqueue" />
@@ -144,16 +144,16 @@ class TestPubsubStanzas(SleekTest):
</iq>""")
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, """
- <iq id="0">
+ <iq id="0">
<pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
<default node="mynode" type="leaf">
<x xmlns="jabber:x:data" type="form">
@@ -166,54 +166,54 @@ class TestPubsubStanzas(SleekTest):
</iq>""", 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, """
- <iq id="0">
- <pubsub xmlns="http://jabber.org/protocol/pubsub">
- <subscribe node="cheese" jid="fritzy@netflint.net/sleekxmpp">
- <options node="cheese" jid="fritzy@netflint.net/sleekxmpp">
- <x xmlns="jabber:x:data" type="form">
- <field var="pubsub#title" type="text-single">
- <value>This thing is awesome</value>
- </field>
- </x>
- </options>
- </subscribe>
- </pubsub>
- </iq>""", use_values=False)
+ <iq id="0">
+ <pubsub xmlns="http://jabber.org/protocol/pubsub">
+ <subscribe node="cheese" jid="fritzy@netflint.net/sleekxmpp">
+ <options node="cheese" jid="fritzy@netflint.net/sleekxmpp">
+ <x xmlns="jabber:x:data" type="form">
+ <field var="pubsub#title" type="text-single">
+ <value>this thing is awesome</value>
+ </field>
+ </x>
+ </options>
+ </subscribe>
+ </pubsub>
+ </iq>""", 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("""
<thinger xmlns="http://andyet.net/protocol/thinger" x="1" y='2'>
<child1 />
<child2 normandy='cheese' foo='bar' />
</thinger>""")
- payload2 = ET.fromstring("""
+ payload2 = ET.fromstring("""
<thinger2 xmlns="http://andyet.net/protocol/thinger2" x="12" y='22'>
<child12 />
<child22 normandy='cheese2' foo='bar2' />
</thinger2>""")
- 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, """
<iq id="0">
<pubsub xmlns="http://jabber.org/protocol/pubsub">
@@ -235,19 +235,19 @@ class TestPubsubStanzas(SleekTest):
</iq>""")
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, """
- <iq id="0">
+ <iq id="0">
<pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
<delete node="thingers" />
</pubsub>
</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):
</iq>""")
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, """
<message type="normal">
<event xmlns="http://jabber.org/protocol/pubsub#event">
<items node="cheese">
@@ -369,21 +369,21 @@ class TestPubsubStanzas(SleekTest):
</message>""")
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, """
<message type="normal">
<event xmlns="http://jabber.org/protocol/pubsub#event">
<items node="cheese">
@@ -398,24 +398,24 @@ class TestPubsubStanzas(SleekTest):
</message>""")
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, """
<message type="normal">
<event xmlns="http://jabber.org/protocol/pubsub#event">
<items node="cheese">
@@ -430,12 +430,12 @@ class TestPubsubStanzas(SleekTest):
</message>""")
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, """
<message type="headline">
<event xmlns="http://jabber.org/protocol/pubsub#event">
<collection node="cheeseburger">
@@ -445,12 +445,12 @@ class TestPubsubStanzas(SleekTest):
</message>""")
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, """
<message type="headline">
<event xmlns="http://jabber.org/protocol/pubsub#event">
<collection node="cheeseburger">
@@ -460,15 +460,15 @@ class TestPubsubStanzas(SleekTest):
</message>""")
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, """
- <message type="headline">
+ <message type="headline">
<event xmlns="http://jabber.org/protocol/pubsub#event">
<configuration node="cheese">
<x xmlns="jabber:x:data" type="form">
@@ -481,11 +481,11 @@ class TestPubsubStanzas(SleekTest):
</message>""")
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, """
<message type="headline">
<event xmlns="http://jabber.org/protocol/pubsub#event">
<purge node="pickles" />
@@ -493,15 +493,15 @@ class TestPubsubStanzas(SleekTest):
</message>""")
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, """
<message type="headline">
<event xmlns="http://jabber.org/protocol/pubsub#event">
<subscription node="pickles" subid="aabb1122" jid="fritzy@netflint.net/test" subscription="subscribed" expiry="presence" />
diff --git a/tests/test_stream.py b/tests/test_stream.py
index c2f2667e..6e240747 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