summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2011-08-12 16:47:58 -0700
committerLance Stout <lancestout@gmail.com>2011-08-12 16:47:58 -0700
commit484efff156e344fc3ca1a7377539132b702c0c78 (patch)
treefa051515b9dc15eb3a5ab1a8e8b9c2e25b920d17 /tests
parent89cffd43f48cfc835b70e137776eb8c2e73a0b67 (diff)
parent8f1d0e7a79b662e5f2849cea6e73716cc887e226 (diff)
downloadslixmpp-484efff156e344fc3ca1a7377539132b702c0c78.tar.gz
slixmpp-484efff156e344fc3ca1a7377539132b702c0c78.tar.bz2
slixmpp-484efff156e344fc3ca1a7377539132b702c0c78.tar.xz
slixmpp-484efff156e344fc3ca1a7377539132b702c0c78.zip
Merge branch 'develop' into roster
Conflicts: setup.py sleekxmpp/clientxmpp.py
Diffstat (limited to 'tests')
-rw-r--r--tests/test_stanza_xep_0004.py41
-rw-r--r--tests/test_stanza_xep_0060.py34
-rw-r--r--tests/test_stream_handlers.py5
-rw-r--r--tests/test_stream_roster.py15
4 files changed, 48 insertions, 47 deletions
diff --git a/tests/test_stanza_xep_0004.py b/tests/test_stanza_xep_0004.py
index bdc4a878..22f8b77d 100644
--- a/tests/test_stanza_xep_0004.py
+++ b/tests/test_stanza_xep_0004.py
@@ -1,4 +1,6 @@
from sleekxmpp.test import *
+from sleekxmpp.thirdparty import OrderedDict
+
import sleekxmpp.plugins.xep_0004 as xep_0004
@@ -47,21 +49,25 @@ class TestDataForms(SleekTest):
</message>
""")
- form['fields'] = [('f1', {'type': 'text-single',
- 'label': 'Username',
- 'required': True}),
- ('f2', {'type': 'text-private',
- 'label': 'Password',
- 'required': True}),
- ('f3', {'type': 'text-multi',
- 'label': 'Message',
- 'value': 'Enter message.\nA long one even.'}),
- ('f4', {'type': 'list-single',
- 'label': 'Message Type',
- 'options': [{'label': 'Cool!',
- 'value': 'cool'},
- {'label': 'Urgh!',
- 'value': 'urgh'}]})]
+ fields = OrderedDict()
+ fields['f1'] = {'type': 'text-single',
+ 'label': 'Username',
+ 'required': True}
+ fields['f2'] = {'type': 'text-private',
+ 'label': 'Password',
+ 'required': True}
+ fields['f3'] = {'type': 'text-multi',
+ 'label': 'Message',
+ 'value': 'Enter message.\nA long one even.'}
+ fields['f4'] = {'type': 'list-single',
+ 'label': 'Message Type',
+ 'options': [{'label': 'Cool!',
+ 'value': 'cool'},
+ {'label': 'Urgh!',
+ 'value': 'urgh'}]}
+ form['fields'] = fields
+
+
self.check(msg, """
<message>
<x xmlns="jabber:x:data" type="form">
@@ -92,9 +98,8 @@ class TestDataForms(SleekTest):
msg = self.Message()
form = msg['form']
- form.setFields([
- ('foo', {'type': 'text-single'}),
- ('bar', {'type': 'list-multi'})])
+ form.add_field(var='foo', ftype='text-single')
+ form.add_field(var='bar', ftype='list-multi')
form.setValues({'foo': 'Foo!',
'bar': ['a', 'b']})
diff --git a/tests/test_stanza_xep_0060.py b/tests/test_stanza_xep_0060.py
index d42c11bd..2427b787 100644
--- a/tests/test_stanza_xep_0060.py
+++ b/tests/test_stanza_xep_0060.py
@@ -182,7 +182,7 @@ class TestPubsubStanzas(SleekTest):
<subscribe node="cheese" jid="fritzy@netflint.net/sleekxmpp">
<options node="cheese" jid="fritzy@netflint.net/sleekxmpp">
<x xmlns="jabber:x:data" type="submit">
- <field var="pubsub#title" type="text-single">
+ <field var="pubsub#title">
<value>this thing is awesome</value>
</field>
</x>
@@ -306,42 +306,42 @@ class TestPubsubStanzas(SleekTest):
<create node="testnode2" />
<configure>
<x xmlns="jabber:x:data" type="submit">
- <field var="FORM_TYPE" type="hidden">
+ <field var="FORM_TYPE">
<value>http://jabber.org/protocol/pubsub#node_config</value>
</field>
- <field var="pubsub#node_type" type="list-single" label="Select the node type">
+ <field var="pubsub#node_type">
<value>leaf</value>
</field>
- <field var="pubsub#title" type="text-single" label="A friendly name for the node" />
- <field var="pubsub#deliver_notifications" type="boolean" label="Deliver event notifications">
+ <field var="pubsub#title" />
+ <field var="pubsub#deliver_notifications">
<value>1</value>
</field>
- <field var="pubsub#deliver_payloads" type="boolean" label="Deliver payloads with event notifications">
+ <field var="pubsub#deliver_payloads">
<value>1</value>
</field>
- <field var="pubsub#notify_config" type="boolean" label="Notify subscribers when the node configuration changes" />
- <field var="pubsub#notify_delete" type="boolean" label="Notify subscribers when the node is deleted" />
- <field var="pubsub#notify_retract" type="boolean" label="Notify subscribers when items are removed from the node">
+ <field var="pubsub#notify_config" />
+ <field var="pubsub#notify_delete" />
+ <field var="pubsub#notify_retract">
<value>1</value>
</field>
- <field var="pubsub#notify_sub" type="boolean" label="Notify owners about new subscribers and unsubscribes" />
- <field var="pubsub#persist_items" type="boolean" label="Persist items in storage" />
- <field var="pubsub#max_items" type="text-single" label="Max # of items to persist">
+ <field var="pubsub#notify_sub" />
+ <field var="pubsub#persist_items" />
+ <field var="pubsub#max_items">
<value>10</value>
</field>
- <field var="pubsub#subscribe" type="boolean" label="Whether to allow subscriptions">
+ <field var="pubsub#subscribe">
<value>1</value>
</field>
- <field var="pubsub#access_model" type="list-single" label="Specify the subscriber model">
+ <field var="pubsub#access_model">
<value>open</value>
</field>
- <field var="pubsub#publish_model" type="list-single" label="Specify the publisher model">
+ <field var="pubsub#publish_model">
<value>publishers</value>
</field>
- <field var="pubsub#send_last_published_item" type="list-single" label="Send last published item">
+ <field var="pubsub#send_last_published_item">
<value>never</value>
</field>
- <field var="pubsub#presence_based_delivery" type="boolean" label="Deliver notification only to available users" />
+ <field var="pubsub#presence_based_delivery" />
</x>
</configure>
</pubsub>
diff --git a/tests/test_stream_handlers.py b/tests/test_stream_handlers.py
index dae4456d..1b831e21 100644
--- a/tests/test_stream_handlers.py
+++ b/tests/test_stream_handlers.py
@@ -90,7 +90,10 @@ class TestHandlers(SleekTest):
iq['id'] = 'test2'
iq['type'] = 'set'
iq['query'] = 'test2'
- reply = iq.send(block=True, timeout=0)
+ try:
+ reply = iq.send(block=True, timeout=0)
+ except IqTimeout:
+ pass
self.xmpp.add_event_handler('message', waiter_handler, threaded=True)
diff --git a/tests/test_stream_roster.py b/tests/test_stream_roster.py
index aa8fc26f..1f83f0ec 100644
--- a/tests/test_stream_roster.py
+++ b/tests/test_stream_roster.py
@@ -107,19 +107,12 @@ class TestStreamRoster(SleekTest):
def testRosterTimeout(self):
"""Test handling a timed out roster request."""
self.stream_start()
- events = []
-
- def roster_timeout(event):
- events.append('roster_timeout')
-
- self.xmpp.add_event_handler('roster_timeout', roster_timeout)
- self.xmpp.get_roster(timeout=0)
- # Give the event queue time to process.
- time.sleep(.1)
+ def do_test():
+ self.xmpp.get_roster(timeout=0)
+ time.sleep(.1)
- self.failUnless(events == ['roster_timeout'],
- "Roster timeout event not triggered: %s." % events)
+ self.assertRaises(IqTimeout, do_test)
def testRosterCallback(self):
"""Test handling a roster request callback."""