Update the test suite.

- monkey-patch our own monkey-patched idle_call to run events immediatly
  rather than adding them to the event queue, and add a fake transport
  with a fake socket.
- remove the test file related to xep_0059 as it relies on blocking
  behavior, and comment out one xep_0030 test uses xep_0059
- remove many instances of threading and sleep()s because they do
  nothing except waste time and introduce race conditions.
- keep exactly two sleep() in IoT xeps because they rely on timeouts
This commit is contained in:
mathieui 2015-02-12 12:23:47 +01:00
parent 4d063e287e
commit 1e2665df19
No known key found for this signature in database
GPG Key ID: C59F84CEEFD616E3
25 changed files with 211 additions and 684 deletions

View File

@ -6,6 +6,6 @@
See the file LICENSE for copying permission. See the file LICENSE for copying permission.
""" """
from slixmpp.test.mocksocket import TestSocket from slixmpp.test.mocksocket import TestSocket, TestTransport
from slixmpp.test.livesocket import TestLiveSocket from slixmpp.test.livesocket import TestLiveSocket
from slixmpp.test.slixtest import * from slixmpp.test.slixtest import *

View File

@ -150,3 +150,92 @@ class TestSocket(object):
return self.recv_queue.get(block, timeout) return self.recv_queue.get(block, timeout)
except: except:
return None return None
class TestTransport(object):
"""
A transport socket that reads and writes to queues instead
of an actual networking socket.
Methods:
next_sent -- Return the next sent stanza.
recv_data -- Make a stanza available to read next.
recv -- Read the next stanza from the socket.
send -- Write a stanza to the socket.
makefile -- Dummy call, returns self.
read -- Read the next stanza from the socket.
"""
def __init__(self, xmpp):
self.xmpp = xmpp
self.socket = TestSocket()
# ------------------------------------------------------------------
# Testing Interface
def next_sent(self, timeout=None):
"""
Get the next stanza that has been 'sent'.
Arguments:
timeout -- Optional timeout for waiting for a new value.
"""
return self.socket.next_sent()
def disconnect_error(self):
"""
Simulate a disconnect error by raising a socket.error exception
for any current or further socket operations.
"""
self.socket.disconnect_error()
# ------------------------------------------------------------------
# Socket Interface
def recv(self, *args, **kwargs):
"""
Read a value from the received queue.
Arguments:
Placeholders. Same as for socket.Socket.recv.
"""
return
def write(self, data):
"""
Send data by placing it in the send queue.
Arguments:
data -- String value to write.
"""
self.socket.send(data)
return len(data)
# ------------------------------------------------------------------
# File Socket
def makefile(self, *args, **kwargs):
"""
File socket version to use with ElementTree.
Arguments:
Placeholders, same as socket.Socket.makefile()
"""
return self
def read(self, block=True, timeout=None, **kwargs):
"""
Implement the file socket interface.
Arguments:
block -- Indicate if the read should block until a
value is ready.
timeout -- Time in seconds a block should last before
returning None.
"""
return self.socket.recv(block, timeout, **kwargs)
def get_extra_info(self, *args, **kwargs):
return self.socket
def abort(self, *args, **kwargs):
return

View File

@ -10,15 +10,19 @@ import unittest
from queue import Queue from queue import Queue
from xml.parsers.expat import ExpatError from xml.parsers.expat import ExpatError
from slixmpp.test import TestTransport
from slixmpp import ClientXMPP, ComponentXMPP from slixmpp import ClientXMPP, ComponentXMPP
from slixmpp.stanza import Message, Iq, Presence from slixmpp.stanza import Message, Iq, Presence
from slixmpp.test import TestSocket, TestLiveSocket
from slixmpp.xmlstream import ET from slixmpp.xmlstream import ET
from slixmpp.xmlstream import ElementBase from slixmpp.xmlstream import ElementBase
from slixmpp.xmlstream.tostring import tostring from slixmpp.xmlstream.tostring import tostring
from slixmpp.xmlstream.matcher import StanzaPath, MatcherId, MatchIDSender from slixmpp.xmlstream.matcher import StanzaPath, MatcherId, MatchIDSender
from slixmpp.xmlstream.matcher import MatchXMLMask, MatchXPath from slixmpp.xmlstream.matcher import MatchXMLMask, MatchXPath
import asyncio
cls = asyncio.get_event_loop().__class__
cls.idle_call = lambda self, callback: callback()
class SlixTest(unittest.TestCase): class SlixTest(unittest.TestCase):
@ -326,41 +330,27 @@ class SlixTest(unittest.TestCase):
else: else:
raise ValueError("Unknown XMPP connection mode.") raise ValueError("Unknown XMPP connection mode.")
self.xmpp.connection_made(TestTransport(self.xmpp))
self.xmpp.session_bind_event.set()
# Remove unique ID prefix to make it easier to test # Remove unique ID prefix to make it easier to test
self.xmpp._id_prefix = '' self.xmpp._id_prefix = ''
self.xmpp._disconnect_wait_for_threads = False
self.xmpp.default_lang = None self.xmpp.default_lang = None
self.xmpp.peer_default_lang = None self.xmpp.peer_default_lang = None
# We will use this to wait for the session_start event # Simulate connecting for mock sockets.
# for live connections. self.xmpp.auto_reconnect = False
skip_queue = Queue()
if socket == 'mock': # Must have the stream header ready for xmpp.process() to work.
self.xmpp.set_socket(TestSocket()) if not header:
header = self.xmpp.stream_header
# Simulate connecting for mock sockets. self.xmpp.data_received(header)
self.xmpp.auto_reconnect = False
self.xmpp.state._set_state('connected')
# Must have the stream header ready for xmpp.process() to work. if skip:
if not header: self.xmpp.socket.next_sent()
header = self.xmpp.stream_header if mode == 'component':
self.xmpp.socket.recv_data(header) self.xmpp.socket.next_sent()
elif socket == 'live':
self.xmpp.socket_class = TestLiveSocket
def wait_for_session(x):
self.xmpp.socket.clear()
skip_queue.put('started')
self.xmpp.add_event_handler('session_start', wait_for_session)
if server is not None:
self.xmpp.connect((server, port))
else:
self.xmpp.connect()
else:
raise ValueError("Unknown socket type.")
if plugins is None: if plugins is None:
self.xmpp.register_plugins() self.xmpp.register_plugins()
@ -372,19 +362,6 @@ class SlixTest(unittest.TestCase):
# this to True in tests related to those plugins. # this to True in tests related to those plugins.
self.xmpp.use_message_ids = False self.xmpp.use_message_ids = False
self.xmpp.process(threaded=True)
if skip:
if socket != 'live':
# Mark send queue as usable
self.xmpp.session_bind_event.set()
self.xmpp.session_started_event.set()
# Clear startup stanzas
self.xmpp.socket.next_sent(timeout=1)
if mode == 'component':
self.xmpp.socket.next_sent(timeout=1)
else:
skip_queue.get(block=True, timeout=10)
def make_header(self, sto='', def make_header(self, sto='',
sfrom='', sfrom='',
sid='', sid='',
@ -447,24 +424,7 @@ class SlixTest(unittest.TestCase):
timeout -- Time to wait in seconds for data to be received by timeout -- Time to wait in seconds for data to be received by
a live connection. a live connection.
""" """
if self.xmpp.socket.is_live: self.xmpp.data_received(data)
# we are working with a live connection, so we should
# verify what has been received instead of simulating
# receiving data.
recv_data = self.xmpp.socket.next_recv(timeout)
if recv_data is None:
self.fail("No stanza was received.")
xml = self.parse_xml(recv_data)
self.fix_namespaces(xml, 'jabber:client')
stanza = self.xmpp._build_stanza(xml, 'jabber:client')
self.check(stanza, data,
method=method,
defaults=defaults,
use_values=use_values)
else:
# place the data in the dummy socket receiving queue.
data = str(data)
self.xmpp.socket.recv_data(data)
def recv_header(self, sto='', def recv_header(self, sto='',
sfrom='', sfrom='',
@ -522,7 +482,7 @@ class SlixTest(unittest.TestCase):
if list(recv_xml): if list(recv_xml):
# We received more than just the header # We received more than just the header
for xml in recv_xml: for xml in recv_xml:
self.xmpp.socket.recv_data(tostring(xml)) self.xmpp.data_received(tostring(xml))
attrib = recv_xml.attrib attrib = recv_xml.attrib
recv_xml.clear() recv_xml.clear()
@ -540,31 +500,7 @@ class SlixTest(unittest.TestCase):
if method is None and hasattr(self, 'match_method'): if method is None and hasattr(self, 'match_method'):
method = getattr(self, 'match_method') method = getattr(self, 'match_method')
if self.xmpp.socket.is_live: self.xmpp.socket.data_received(data)
# we are working with a live connection, so we should
# verify what has been received instead of simulating
# receiving data.
recv_data = self.xmpp.socket.next_recv(timeout)
xml = self.parse_xml(data)
recv_xml = self.parse_xml(recv_data)
if recv_data is None:
self.fail("No stanza was received.")
if method == 'exact':
self.failUnless(self.compare(xml, recv_xml),
"Features do not match.\nDesired:\n%s\nReceived:\n%s" % (
tostring(xml), tostring(recv_xml)))
elif method == 'mask':
matcher = MatchXMLMask(xml)
self.failUnless(matcher.match(recv_xml),
"Stanza did not match using %s method:\n" % method + \
"Criteria:\n%s\n" % tostring(xml) + \
"Stanza:\n%s" % tostring(recv_xml))
else:
raise ValueError("Uknown matching method: %s" % method)
else:
# place the data in the dummy socket receiving queue.
data = str(data)
self.xmpp.socket.recv_data(data)
def send_header(self, sto='', def send_header(self, sto='',
sfrom='', sfrom='',
@ -682,7 +618,7 @@ class SlixTest(unittest.TestCase):
that the XMPP client is disconnected after an error. that the XMPP client is disconnected after an error.
""" """
if hasattr(self, 'xmpp') and self.xmpp is not None: if hasattr(self, 'xmpp') and self.xmpp is not None:
self.xmpp.socket.recv_data(self.xmpp.stream_footer) self.xmpp.data_received(self.xmpp.stream_footer)
self.xmpp.disconnect() self.xmpp.disconnect()
# ------------------------------------------------------------------ # ------------------------------------------------------------------

View File

@ -22,9 +22,6 @@ class TestEvents(SlixTest):
self.xmpp.event("test_event") self.xmpp.event("test_event")
self.xmpp.event("test_event") self.xmpp.event("test_event")
# Give the event queue time to process.
time.sleep(0.1)
msg = "Event was not triggered the correct number of times: %s" msg = "Event was not triggered the correct number of times: %s"
self.failUnless(happened == [True, True], msg) self.failUnless(happened == [True, True], msg)
@ -43,9 +40,6 @@ class TestEvents(SlixTest):
# Should not trigger because it was deleted # Should not trigger because it was deleted
self.xmpp.event("test_event", {}) self.xmpp.event("test_event", {})
# Give the event queue time to process.
time.sleep(0.1)
msg = "Event was not triggered the correct number of times: %s" msg = "Event was not triggered the correct number of times: %s"
self.failUnless(happened == [True], msg % happened) self.failUnless(happened == [True], msg % happened)
@ -66,9 +60,6 @@ class TestEvents(SlixTest):
self.xmpp.add_event_handler("test_event", handletestevent) self.xmpp.add_event_handler("test_event", handletestevent)
self.xmpp.event("test_event", {}) self.xmpp.event("test_event", {})
# Give the event queue time to process.
time.sleep(0.1)
msg = "Event was not triggered the correct number of times: %s" msg = "Event was not triggered the correct number of times: %s"
self.failUnless(happened == [True, True], msg % happened) self.failUnless(happened == [True, True], msg % happened)
@ -86,9 +77,6 @@ class TestEvents(SlixTest):
# Should not trigger because it was deleted # Should not trigger because it was deleted
self.xmpp.event("test_event", {}) self.xmpp.event("test_event", {})
# Give the event queue time to process.
time.sleep(0.1)
msg = "Event was not triggered the correct number of times: %s" msg = "Event was not triggered the correct number of times: %s"
self.failUnless(happened == [True], msg % happened) self.failUnless(happened == [True], msg % happened)

View File

@ -61,7 +61,7 @@ class TestStanzaBase(SlixTest):
stanza['from'] = "sender@example.com" stanza['from'] = "sender@example.com"
stanza['payload'] = ET.Element("{foo}foo") stanza['payload'] = ET.Element("{foo}foo")
stanza.reply() stanza = stanza.reply()
self.failUnless(str(stanza['to'] == "sender@example.com"), self.failUnless(str(stanza['to'] == "sender@example.com"),
"Stanza reply did not change 'to' attribute.") "Stanza reply did not change 'to' attribute.")

View File

@ -82,7 +82,7 @@ class TestIqStanzas(SlixTest):
iq = self.Iq() iq = self.Iq()
iq['to'] = 'user@localhost' iq['to'] = 'user@localhost'
iq['type'] = 'get' iq['type'] = 'get'
iq.reply() iq = iq.reply()
self.check(iq, """ self.check(iq, """
<iq id="0" type="result" /> <iq id="0" type="result" />

View File

@ -17,7 +17,7 @@ class TestMessageStanzas(SlixTest):
msg['from'] = 'room@someservice.someserver.tld/somenick' msg['from'] = 'room@someservice.someserver.tld/somenick'
msg['type'] = 'groupchat' msg['type'] = 'groupchat'
msg['body'] = "this is a message" msg['body'] = "this is a message"
msg.reply() msg = msg.reply()
self.failUnless(str(msg['to']) == 'room@someservice.someserver.tld') self.failUnless(str(msg['to']) == 'room@someservice.someserver.tld')
def testAttribProperty(self): def testAttribProperty(self):

View File

@ -86,7 +86,7 @@ class TestIBB(SlixTest):
self.check(iq, """ self.check(iq, """
<iq type="set"> <iq type="set">
<data xmlns="http://jabber.org/protocol/ibb" seq="0">c2xlZWt4bXBw</data> <data xmlns="http://jabber.org/protocol/ibb" seq="0">c2xpeG1wcA==</data>
</iq> </iq>
""") """)

View File

@ -16,7 +16,7 @@ class TestStreamTester(SlixTest):
self.stream_start(mode='client') self.stream_start(mode='client')
def echo(msg): def echo(msg):
msg.reply('Thanks for sending: %(body)s' % msg).send() msg.reply('Thanks for sending: %s' % msg['body']).send()
self.xmpp.add_event_handler('message', echo) self.xmpp.add_event_handler('message', echo)
@ -58,23 +58,4 @@ class TestStreamTester(SlixTest):
self.stream_start(mode='client', skip=False) self.stream_start(mode='client', skip=False)
self.send_header(sto='localhost') self.send_header(sto='localhost')
def testStreamDisconnect(self):
"""Test that the test socket can simulate disconnections."""
self.stream_start()
events = set()
def stream_error(event):
events.add('socket_error')
self.xmpp.add_event_handler('socket_error', stream_error)
self.stream_disconnect()
self.xmpp.send_raw(' ')
time.sleep(.1)
self.failUnless('socket_error' in events,
"Stream error event not raised: %s" % events)
suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamTester) suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamTester)

View File

@ -13,40 +13,11 @@ class TestStreamExceptions(SlixTest):
def tearDown(self): def tearDown(self):
self.stream_close() self.stream_close()
def testExceptionReply(self):
"""Test that raising an exception replies with the original stanza."""
def message(msg):
msg.reply()
msg['body'] = 'Body changed'
raise XMPPError(clear=False)
self.stream_start()
self.xmpp.add_event_handler('message', message)
self.recv("""
<message>
<body>This is going to cause an error.</body>
</message>
""")
self.send("""
<message type="error">
<body>This is going to cause an error.</body>
<error type="cancel" code="500">
<undefined-condition
xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" />
</error>
</message>
""")
def testExceptionContinueWorking(self): def testExceptionContinueWorking(self):
"""Test that Slixmpp continues to respond after an XMPPError is raised.""" """Test that Slixmpp continues to respond after an XMPPError is raised."""
def message(msg): def message(msg):
msg.reply() raise XMPPError(clear=True)
msg['body'] = 'Body changed'
raise XMPPError(clear=False)
self.stream_start() self.stream_start()
self.xmpp.add_event_handler('message', message) self.xmpp.add_event_handler('message', message)
@ -59,7 +30,6 @@ class TestStreamExceptions(SlixTest):
self.send(""" self.send("""
<message type="error"> <message type="error">
<body>This is going to cause an error.</body>
<error type="cancel" code="500"> <error type="cancel" code="500">
<undefined-condition <undefined-condition
xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" /> xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" />
@ -75,7 +45,6 @@ class TestStreamExceptions(SlixTest):
self.send(""" self.send("""
<message type="error"> <message type="error">
<body>This is going to cause an error.</body>
<error type="cancel" code="500"> <error type="cancel" code="500">
<undefined-condition <undefined-condition
xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" /> xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" />
@ -151,38 +120,8 @@ class TestStreamExceptions(SlixTest):
</iq> </iq>
""", use_values=False) """, use_values=False)
def testThreadedXMPPErrorException(self):
"""Test raising an XMPPError exception in a threaded handler."""
def message(msg):
raise XMPPError(condition='feature-not-implemented',
text="We don't do things that way here.",
etype='cancel')
self.stream_start()
self.xmpp.add_event_handler('message', message,
threaded=True)
self.recv("""
<message>
<body>This is going to cause an error.</body>
</message>
""")
self.send("""
<message type="error">
<error type="cancel" code="501">
<feature-not-implemented
xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" />
<text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">
We don&apos;t do things that way here.
</text>
</error>
</message>
""")
def testUnknownException(self): def testUnknownException(self):
"""Test raising an generic exception in a threaded handler.""" """Test raising an generic exception in a handler."""
raised_errors = [] raised_errors = []

View File

@ -47,8 +47,6 @@ class TestFilters(SlixTest):
</message> </message>
""") """)
time.sleep(0.5)
self.assertEqual(data, ['', 'testing filter'], self.assertEqual(data, ['', 'testing filter'],
'Incoming filter did not apply %s' % data) 'Incoming filter did not apply %s' % data)

View File

@ -48,15 +48,15 @@ class TestHandlers(SlixTest):
iq['id'] = 'test' iq['id'] = 'test'
iq['type'] = 'set' iq['type'] = 'set'
iq['query'] = 'test' iq['query'] = 'test'
reply = iq.send(block=True) def callback_waiter(result):
if reply:
self.xmpp.send_raw(""" self.xmpp.send_raw("""
<message> <message>
<body>Successful: %s</body> <body>Successful: %s</body>
</message> </message>
""" % reply['query']) """ % result['query'])
iq.send(callback=callback_waiter)
self.xmpp.add_event_handler('message', waiter_handler, threaded=True) self.xmpp.add_event_handler('message', waiter_handler)
# Send message to trigger waiter_handler # Send message to trigger waiter_handler
self.recv(""" self.recv("""
@ -93,11 +93,11 @@ class TestHandlers(SlixTest):
iq['type'] = 'set' iq['type'] = 'set'
iq['query'] = 'test2' iq['query'] = 'test2'
try: try:
reply = iq.send(block=True, timeout=0) reply = iq.send(timeout=0)
except IqTimeout: except IqTimeout:
pass pass
self.xmpp.add_event_handler('message', waiter_handler, threaded=True) self.xmpp.add_event_handler('message', waiter_handler)
# Start test by triggerig waiter_handler # Start test by triggerig waiter_handler
self.recv("""<message><body>Start Test</body></message>""") self.recv("""<message><body>Start Test</body></message>""")
@ -109,9 +109,6 @@ class TestHandlers(SlixTest):
iq['query'] = 'test2' iq['query'] = 'test2'
self.send(iq) self.send(iq)
# Give the event queue time to process.
time.sleep(0.1)
# Check that the waiter is no longer registered # Check that the waiter is no longer registered
waiter_exists = self.xmpp.remove_handler('IqWait_test2') waiter_exists = self.xmpp.remove_handler('IqWait_test2')
@ -148,41 +145,9 @@ class TestHandlers(SlixTest):
</iq> </iq>
""") """)
# Give event queue time to process
time.sleep(0.1)
self.failUnless(events == ['foo'], self.failUnless(events == ['foo'],
"Iq callback was not executed: %s" % events) "Iq callback was not executed: %s" % events)
def testIqTimeoutCallback(self):
"""Test that iq.send(tcallback=handle_foo, timeout_callback=handle_timeout) works."""
events = []
def handle_foo(iq):
events.append('foo')
def handle_timeout(iq):
events.append('timeout')
iq = self.Iq()
iq['type'] = 'get'
iq['id'] = 'test-foo'
iq['to'] = 'user@localhost'
iq['query'] = 'foo'
iq.send(callback=handle_foo, timeout_callback=handle_timeout, timeout=0.05)
self.send("""
<iq type="get" id="test-foo" to="user@localhost">
<query xmlns="foo" />
</iq>
""")
# Give event queue time to process
time.sleep(1)
self.failUnless(events == ['timeout'],
"Iq timeout was not executed: %s" % events)
def testMultipleHandlersForStanza(self): def testMultipleHandlersForStanza(self):
""" """
Test that multiple handlers for a single stanza work Test that multiple handlers for a single stanza work
@ -235,18 +200,15 @@ class TestHandlers(SlixTest):
events = [] events = []
def run_test(): def callback(result):
# Check that Iq was sent by waiter_handler
iq = self.Iq()
iq['id'] = 'test'
iq['to'] = 'tester@slixmpp.com/test'
iq['type'] = 'set'
iq['query'] = 'test'
result = iq.send()
events.append(result['from'].full) events.append(result['from'].full)
t = threading.Thread(name="sender_test", target=run_test) iq = self.Iq()
t.start() iq['id'] = 'test'
iq['to'] = 'tester@slixmpp.com/test'
iq['type'] = 'set'
iq['query'] = 'test'
iq.send(callback=callback)
self.recv(""" self.recv("""
<iq id="test" from="evil@slixmpp.com/bad" type="result"> <iq id="test" from="evil@slixmpp.com/bad" type="result">
@ -271,13 +233,7 @@ class TestHandlers(SlixTest):
</iq> </iq>
""") """)
t.join()
time.sleep(0.1)
self.assertEqual(events, ['tester@slixmpp.com/test'], "Did not timeout on bad sender") self.assertEqual(events, ['tester@slixmpp.com/test'], "Did not timeout on bad sender")
suite = unittest.TestLoader().loadTestsFromTestCase(TestHandlers) suite = unittest.TestLoader().loadTestsFromTestCase(TestHandlers)

View File

@ -38,9 +38,6 @@ class TestStreamPresence(SlixTest):
to="tester@localhost"/> to="tester@localhost"/>
""") """)
# Give event queue time to process.
time.sleep(0.1)
self.assertEqual(events, set(('unavailable',)), self.assertEqual(events, set(('unavailable',)),
"Got offline incorrectly triggered: %s." % events) "Got offline incorrectly triggered: %s." % events)
@ -83,9 +80,6 @@ class TestStreamPresence(SlixTest):
type="unavailable" /> type="unavailable" />
""") """)
# Give event queue time to process.
time.sleep(0.1)
self.assertEqual(events, ['got_offline'], self.assertEqual(events, ['got_offline'],
"Got offline incorrectly triggered: %s" % events) "Got offline incorrectly triggered: %s" % events)
@ -108,9 +102,6 @@ class TestStreamPresence(SlixTest):
to="tester@localhost" /> to="tester@localhost" />
""") """)
# Give event queue time to process.
time.sleep(0.1)
expected = set(('presence_available', 'got_online')) expected = set(('presence_available', 'got_online'))
self.assertEqual(events, expected, self.assertEqual(events, expected,
"Incorrect events triggered: %s" % events) "Incorrect events triggered: %s" % events)
@ -242,8 +233,6 @@ class TestStreamPresence(SlixTest):
<presence type="unsubscribed" /> <presence type="unsubscribed" />
""") """)
time.sleep(.5)
self.assertEqual(events, ptypes, self.assertEqual(events, ptypes,
"Not all events raised: %s" % events) "Not all events raised: %s" % events)
@ -364,8 +353,6 @@ class TestStreamPresence(SlixTest):
</presence> </presence>
""") """)
time.sleep(0.3)
self.assertEqual(events, ['available', 'away', 'dnd', 'chat', self.assertEqual(events, ['available', 'away', 'dnd', 'chat',
'xa', 'unavailable', 'available', 'xa', 'unavailable', 'available',
'available', 'dnd'], 'available', 'dnd'],

View File

@ -24,9 +24,7 @@ class TestStreamRoster(SlixTest):
self.xmpp.add_event_handler('roster_update', roster_updates.append) self.xmpp.add_event_handler('roster_update', roster_updates.append)
# Since get_roster blocks, we need to run it in a thread. self.xmpp.get_roster()
t = threading.Thread(name='get_roster', target=self.xmpp.get_roster)
t.start()
self.send(""" self.send("""
<iq type="get" id="1"> <iq type="get" id="1">
@ -47,12 +45,6 @@ class TestStreamRoster(SlixTest):
</iq> </iq>
""") """)
# Wait for get_roster to return.
t.join()
# Give the event queue time to process.
time.sleep(.1)
self.check_roster('tester@localhost', 'user@localhost', self.check_roster('tester@localhost', 'user@localhost',
name='User', name='User',
subscription='from', subscription='from',
@ -96,8 +88,6 @@ class TestStreamRoster(SlixTest):
subscription='both', subscription='both',
groups=['Friends', 'Examples']) groups=['Friends', 'Examples'])
# Give the event queue time to process.
time.sleep(.1)
self.failUnless('roster_update' in events, self.failUnless('roster_update' in events,
"Roster updated event not triggered: %s" % events) "Roster updated event not triggered: %s" % events)
@ -170,16 +160,6 @@ class TestStreamRoster(SlixTest):
</iq> </iq>
""") """)
def testRosterTimeout(self):
"""Test handling a timed out roster request."""
self.stream_start()
def do_test():
self.xmpp.get_roster(timeout=0)
time.sleep(.1)
self.assertRaises(IqTimeout, do_test)
def testRosterCallback(self): def testRosterCallback(self):
"""Test handling a roster request callback.""" """Test handling a roster request callback."""
self.stream_start() self.stream_start()
@ -188,12 +168,7 @@ class TestStreamRoster(SlixTest):
def roster_callback(iq): def roster_callback(iq):
events.append('roster_callback') events.append('roster_callback')
# Since get_roster blocks, we need to run it in a thread. self.xmpp.get_roster(callback=roster_callback)
t = threading.Thread(name='get_roster',
target=self.xmpp.get_roster,
kwargs={str('block'): False,
str('callback'): roster_callback})
t.start()
self.send(""" self.send("""
<iq type="get" id="1"> <iq type="get" id="1">
@ -213,12 +188,6 @@ class TestStreamRoster(SlixTest):
</iq> </iq>
""") """)
# Wait for get_roster to return.
t.join()
# Give the event queue time to process.
time.sleep(.1)
self.failUnless(events == ['roster_callback'], self.failUnless(events == ['roster_callback'],
"Roster timeout event not triggered: %s." % events) "Roster timeout event not triggered: %s." % events)
@ -235,9 +204,6 @@ class TestStreamRoster(SlixTest):
</iq> </iq>
""") """)
# Give the event queue time to process.
time.sleep(.1)
self.check_roster('tester@localhost', 'andré@foo', self.check_roster('tester@localhost', 'andré@foo',
subscription='both', subscription='both',
groups=['Unicode']) groups=['Unicode'])
@ -253,9 +219,6 @@ class TestStreamRoster(SlixTest):
</presence> </presence>
""") """)
# Give the event queue time to process.
time.sleep(.1)
result = self.xmpp.client_roster['andré@foo'].resources result = self.xmpp.client_roster['andré@foo'].resources
expected = {'bar': {'status':'Testing', expected = {'bar': {'status':'Testing',
'show':'away', 'show':'away',
@ -298,8 +261,8 @@ class TestStreamRoster(SlixTest):
self.stream_start() self.stream_start()
self.assertTrue('rosterver' not in self.xmpp.features) self.assertTrue('rosterver' not in self.xmpp.features)
t = threading.Thread(name='get_roster', target=self.xmpp.get_roster) self.xmpp.get_roster()
t.start()
self.send(""" self.send("""
<iq type="get" id="1"> <iq type="get" id="1">
<query xmlns="jabber:iq:roster" /> <query xmlns="jabber:iq:roster" />
@ -309,16 +272,14 @@ class TestStreamRoster(SlixTest):
<iq to="tester@localhost" type="result" id="1" /> <iq to="tester@localhost" type="result" id="1" />
""") """)
t.join()
def testBootstrapRosterVer(self): def testBootstrapRosterVer(self):
"""Test bootstrapping with roster versioning.""" """Test bootstrapping with roster versioning."""
self.stream_start() self.stream_start()
self.xmpp.features.add('rosterver') self.xmpp.features.add('rosterver')
self.xmpp.client_roster.version = '' self.xmpp.client_roster.version = ''
t = threading.Thread(name='get_roster', target=self.xmpp.get_roster) self.xmpp.get_roster()
t.start()
self.send(""" self.send("""
<iq type="get" id="1"> <iq type="get" id="1">
<query xmlns="jabber:iq:roster" ver="" /> <query xmlns="jabber:iq:roster" ver="" />
@ -328,8 +289,6 @@ class TestStreamRoster(SlixTest):
<iq to="tester@localhost" type="result" id="1" /> <iq to="tester@localhost" type="result" id="1" />
""") """)
t.join()
def testExistingRosterVer(self): def testExistingRosterVer(self):
"""Test using a stored roster version.""" """Test using a stored roster version."""
@ -337,8 +296,8 @@ class TestStreamRoster(SlixTest):
self.xmpp.features.add('rosterver') self.xmpp.features.add('rosterver')
self.xmpp.client_roster.version = '42' self.xmpp.client_roster.version = '42'
t = threading.Thread(name='get_roster', target=self.xmpp.get_roster) self.xmpp.get_roster()
t.start()
self.send(""" self.send("""
<iq type="get" id="1"> <iq type="get" id="1">
<query xmlns="jabber:iq:roster" ver="42" /> <query xmlns="jabber:iq:roster" ver="42" />
@ -348,7 +307,5 @@ class TestStreamRoster(SlixTest):
<iq to="tester@localhost" type="result" id="1" /> <iq to="tester@localhost" type="result" id="1" />
""") """)
t.join()
suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamRoster) suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamRoster)

View File

@ -288,10 +288,7 @@ class TestStreamDisco(SlixTest):
self.xmpp.add_event_handler('disco_info', handle_disco_info) self.xmpp.add_event_handler('disco_info', handle_disco_info)
t = threading.Thread(name="get_info", self.xmpp['xep_0030'].get_info('user@localhost', 'foo')
target=self.xmpp['xep_0030'].get_info,
args=('user@localhost', 'foo'))
t.start()
self.send(""" self.send("""
<iq type="get" to="user@localhost" id="1"> <iq type="get" to="user@localhost" id="1">
@ -310,11 +307,6 @@ class TestStreamDisco(SlixTest):
</iq> </iq>
""") """)
# Wait for disco#info request to be received.
t.join()
time.sleep(0.1)
self.assertEqual(events, set(('disco_info',)), self.assertEqual(events, set(('disco_info',)),
"Disco info event was not triggered: %s" % events) "Disco info event was not triggered: %s" % events)
@ -491,10 +483,7 @@ class TestStreamDisco(SlixTest):
self.xmpp.add_event_handler('disco_items', handle_disco_items) self.xmpp.add_event_handler('disco_items', handle_disco_items)
t = threading.Thread(name="get_items", self.xmpp['xep_0030'].get_items('user@localhost', 'foo')
target=self.xmpp['xep_0030'].get_items,
args=('user@localhost', 'foo'))
t.start()
self.send(""" self.send("""
<iq type="get" to="user@localhost" id="1"> <iq type="get" to="user@localhost" id="1">
@ -513,11 +502,6 @@ class TestStreamDisco(SlixTest):
</iq> </iq>
""") """)
# Wait for disco#items request to be received.
t.join()
time.sleep(0.1)
items = set([('user@localhost', 'bar', 'Test'), items = set([('user@localhost', 'bar', 'Test'),
('user@localhost', 'baz', 'Test 2')]) ('user@localhost', 'baz', 'Test 2')])
self.assertEqual(events, set(('disco_items',)), self.assertEqual(events, set(('disco_items',)),
@ -525,6 +509,7 @@ class TestStreamDisco(SlixTest):
self.assertEqual(results, items, self.assertEqual(results, items,
"Unexpected items: %s" % results) "Unexpected items: %s" % results)
'''
def testGetItemsIterator(self): def testGetItemsIterator(self):
"""Test interaction between XEP-0030 and XEP-0059 plugins.""" """Test interaction between XEP-0030 and XEP-0059 plugins."""
@ -571,6 +556,7 @@ class TestStreamDisco(SlixTest):
self.assertEqual(raised_exceptions, [True], self.assertEqual(raised_exceptions, [True],
"StopIteration was not raised: %s" % raised_exceptions) "StopIteration was not raised: %s" % raised_exceptions)
'''
suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamDisco) suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamDisco)

View File

@ -24,11 +24,8 @@ class TestInBandByteStreams(SlixTest):
self.xmpp.add_event_handler('ibb_stream_start', on_stream_start) self.xmpp.add_event_handler('ibb_stream_start', on_stream_start)
t = threading.Thread(name='open_stream', self.xmpp['xep_0047'].open_stream('tester@localhost/receiver',
target=self.xmpp['xep_0047'].open_stream, sid='testing')
args=('tester@localhost/receiver',),
kwargs={'sid': 'testing'})
t.start()
self.send(""" self.send("""
<iq type="set" to="tester@localhost/receiver" id="1"> <iq type="set" to="tester@localhost/receiver" id="1">
@ -45,10 +42,6 @@ class TestInBandByteStreams(SlixTest):
from="tester@localhost/receiver" /> from="tester@localhost/receiver" />
""") """)
t.join()
time.sleep(0.2)
self.assertEqual(events, ['ibb_stream_start']) self.assertEqual(events, ['ibb_stream_start'])
def testAysncOpenStream(self): def testAysncOpenStream(self):
@ -64,13 +57,9 @@ class TestInBandByteStreams(SlixTest):
self.xmpp.add_event_handler('ibb_stream_start', on_stream_start) self.xmpp.add_event_handler('ibb_stream_start', on_stream_start)
t = threading.Thread(name='open_stream', self.xmpp['xep_0047'].open_stream('tester@localhost/receiver',
target=self.xmpp['xep_0047'].open_stream, sid='testing',
args=('tester@localhost/receiver',), callback=stream_callback)
kwargs={'sid': 'testing',
'block': False,
'callback': stream_callback})
t.start()
self.send(""" self.send("""
<iq type="set" to="tester@localhost/receiver" id="1"> <iq type="set" to="tester@localhost/receiver" id="1">
@ -87,10 +76,6 @@ class TestInBandByteStreams(SlixTest):
from="tester@localhost/receiver" /> from="tester@localhost/receiver" />
""") """)
t.join()
time.sleep(0.2)
self.assertEqual(events, set(['ibb_stream_start', 'callback'])) self.assertEqual(events, set(['ibb_stream_start', 'callback']))
def testSendData(self): def testSendData(self):
@ -108,11 +93,8 @@ class TestInBandByteStreams(SlixTest):
self.xmpp.add_event_handler('ibb_stream_start', on_stream_start) self.xmpp.add_event_handler('ibb_stream_start', on_stream_start)
self.xmpp.add_event_handler('ibb_stream_data', on_stream_data) self.xmpp.add_event_handler('ibb_stream_data', on_stream_data)
t = threading.Thread(name='open_stream', self.xmpp['xep_0047'].open_stream('tester@localhost/receiver',
target=self.xmpp['xep_0047'].open_stream, sid='testing')
args=('tester@localhost/receiver',),
kwargs={'sid': 'testing'})
t.start()
self.send(""" self.send("""
<iq type="set" to="tester@localhost/receiver" id="1"> <iq type="set" to="tester@localhost/receiver" id="1">
@ -129,10 +111,6 @@ class TestInBandByteStreams(SlixTest):
from="tester@localhost/receiver" /> from="tester@localhost/receiver" />
""") """)
t.join()
time.sleep(0.2)
stream = streams[0] stream = streams[0]

View File

@ -623,9 +623,6 @@ class TestAdHocCommands(SlixTest):
</iq> </iq>
""") """)
# Give the event queue time to process
time.sleep(0.3)
self.failUnless(results == ['foo', 'bar', 'baz'], self.failUnless(results == ['foo', 'bar', 'baz'],
'Incomplete command workflow: %s' % results) 'Incomplete command workflow: %s' % results)
@ -689,9 +686,6 @@ class TestAdHocCommands(SlixTest):
</iq> </iq>
""") """)
# Give the event queue time to process
time.sleep(0.3)
self.failUnless(results == ['foo', 'bar'], self.failUnless(results == ['foo', 'bar'],
'Incomplete command workflow: %s' % results) 'Incomplete command workflow: %s' % results)
@ -730,9 +724,6 @@ class TestAdHocCommands(SlixTest):
</iq> </iq>
""") """)
# Give the event queue time to process
time.sleep(0.3)
self.failUnless(results == ['foo'], self.failUnless(results == ['foo'],
'Incomplete command workflow: %s' % results) 'Incomplete command workflow: %s' % results)
@ -768,14 +759,8 @@ class TestAdHocCommands(SlixTest):
</iq> </iq>
""") """)
# Give the event queue time to process
time.sleep(0.3)
self.failUnless(results == ['foo'], self.failUnless(results == ['foo'],
'Incomplete command workflow: %s' % results) 'Incomplete command workflow: %s' % results)
suite = unittest.TestLoader().loadTestsFromTestCase(TestAdHocCommands) suite = unittest.TestLoader().loadTestsFromTestCase(TestAdHocCommands)

View File

@ -1,163 +0,0 @@
import threading
import unittest
from slixmpp.test import SlixTest
from slixmpp.xmlstream import register_stanza_plugin
from slixmpp.plugins.xep_0030 import DiscoItems
from slixmpp.plugins.xep_0059 import ResultIterator, Set
class TestStreamSet(SlixTest):
def setUp(self):
register_stanza_plugin(DiscoItems, Set)
def tearDown(self):
self.stream_close()
def iter(self, rev=False):
q = self.xmpp.Iq()
q['type'] = 'get'
it = ResultIterator(q, 'disco_items', amount='1', reverse=rev)
for i in it:
for j in i['disco_items']['items']:
self.items.append(j[0])
def testResultIterator(self):
self.items = []
self.stream_start(mode='client')
t = threading.Thread(target=self.iter)
t.start()
self.send("""
<iq type="get" id="2">
<query xmlns="http://jabber.org/protocol/disco#items">
<set xmlns="http://jabber.org/protocol/rsm">
<max>1</max>
</set>
</query>
</iq>
""")
self.recv("""
<iq type="result" id="2">
<query xmlns="http://jabber.org/protocol/disco#items">
<item jid="item1" />
<set xmlns="http://jabber.org/protocol/rsm">
<last>item1</last>
</set>
</query>
</iq>
""")
self.send("""
<iq type="get" id="3">
<query xmlns="http://jabber.org/protocol/disco#items">
<set xmlns="http://jabber.org/protocol/rsm">
<max>1</max>
<after>item1</after>
</set>
</query>
</iq>
""")
self.recv("""
<iq type="result" id="3">
<query xmlns="http://jabber.org/protocol/disco#items">
<item jid="item2" />
<set xmlns="http://jabber.org/protocol/rsm">
<last>item2</last>
</set>
</query>
</iq>
""")
self.send("""
<iq type="get" id="4">
<query xmlns="http://jabber.org/protocol/disco#items">
<set xmlns="http://jabber.org/protocol/rsm">
<max>1</max>
<after>item2</after>
</set>
</query>
</iq>
""")
self.recv("""
<iq type="result" id="4">
<query xmlns="http://jabber.org/protocol/disco#items">
<item jid="item2" />
<set xmlns="http://jabber.org/protocol/rsm">
</set>
</query>
</iq>
""")
t.join()
self.failUnless(self.items == ['item1', 'item2'])
def testResultIteratorReverse(self):
self.items = []
self.stream_start(mode='client')
t = threading.Thread(target=self.iter, args=(True,))
t.start()
self.send("""
<iq type="get" id="2">
<query xmlns="http://jabber.org/protocol/disco#items">
<set xmlns="http://jabber.org/protocol/rsm">
<max>1</max>
<before />
</set>
</query>
</iq>
""")
self.recv("""
<iq type="result" id="2">
<query xmlns="http://jabber.org/protocol/disco#items">
<item jid="item2" />
<set xmlns="http://jabber.org/protocol/rsm">
<first>item2</first>
</set>
</query>
</iq>
""")
self.send("""
<iq type="get" id="3">
<query xmlns="http://jabber.org/protocol/disco#items">
<set xmlns="http://jabber.org/protocol/rsm">
<max>1</max>
<before>item2</before>
</set>
</query>
</iq>
""")
self.recv("""
<iq type="result" id="3">
<query xmlns="http://jabber.org/protocol/disco#items">
<item jid="item1" />
<set xmlns="http://jabber.org/protocol/rsm">
<first>item1</first>
</set>
</query>
</iq>
""")
self.send("""
<iq type="get" id="4">
<query xmlns="http://jabber.org/protocol/disco#items">
<set xmlns="http://jabber.org/protocol/rsm">
<max>1</max>
<before>item1</before>
</set>
</query>
</iq>
""")
self.recv("""
<iq type="result" id="4">
<query xmlns="http://jabber.org/protocol/disco#items">
<item jid="item1" />
<set xmlns="http://jabber.org/protocol/rsm">
</set>
</query>
</iq>
""")
t.join()
self.failUnless(self.items == ['item2', 'item1'])
suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamSet)

View File

@ -20,10 +20,7 @@ class TestStreamPubsub(SlixTest):
def testCreateInstantNode(self): def testCreateInstantNode(self):
"""Test creating an instant node""" """Test creating an instant node"""
t = threading.Thread(name='create_node', self.xmpp['xep_0060'].create_node('pubsub.example.com', None)
target=self.xmpp['xep_0060'].create_node,
args=('pubsub.example.com', None))
t.start()
self.send(""" self.send("""
<iq type="set" id="1" to="pubsub.example.com"> <iq type="set" id="1" to="pubsub.example.com">
@ -42,14 +39,11 @@ class TestStreamPubsub(SlixTest):
</iq> </iq>
""") """)
t.join()
def testCreateNodeNoConfig(self): def testCreateNodeNoConfig(self):
"""Test creating a node without a config""" """Test creating a node without a config"""
self.xmpp['xep_0060'].create_node( self.xmpp['xep_0060'].create_node(
'pubsub.example.com', 'pubsub.example.com',
'princely_musings', 'princely_musings')
block=False)
self.send(""" self.send("""
<iq type="set" id="1" to="pubsub.example.com"> <iq type="set" id="1" to="pubsub.example.com">
<pubsub xmlns="http://jabber.org/protocol/pubsub"> <pubsub xmlns="http://jabber.org/protocol/pubsub">
@ -67,7 +61,7 @@ class TestStreamPubsub(SlixTest):
self.xmpp['xep_0060'].create_node( self.xmpp['xep_0060'].create_node(
'pubsub.example.com', 'pubsub.example.com',
'princely_musings', 'princely_musings',
config=form, block=False) config=form)
self.send(""" self.send("""
<iq type="set" id="1" to="pubsub.example.com"> <iq type="set" id="1" to="pubsub.example.com">
@ -91,8 +85,7 @@ class TestStreamPubsub(SlixTest):
"""Test deleting a node""" """Test deleting a node"""
self.xmpp['xep_0060'].delete_node( self.xmpp['xep_0060'].delete_node(
'pubsub.example.com', 'pubsub.example.com',
'some_node', 'some_node')
block=False)
self.send(""" self.send("""
<iq type="set" to="pubsub.example.com" id="1"> <iq type="set" to="pubsub.example.com" id="1">
<pubsub xmlns="http://jabber.org/protocol/pubsub#owner"> <pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
@ -108,8 +101,7 @@ class TestStreamPubsub(SlixTest):
""" """
self.xmpp['xep_0060'].subscribe( self.xmpp['xep_0060'].subscribe(
'pubsub.example.com', 'pubsub.example.com',
'somenode', 'somenode')
block=False)
self.send(""" self.send("""
<iq type="set" id="1" to="pubsub.example.com"> <iq type="set" id="1" to="pubsub.example.com">
<pubsub xmlns="http://jabber.org/protocol/pubsub"> <pubsub xmlns="http://jabber.org/protocol/pubsub">
@ -126,8 +118,7 @@ class TestStreamPubsub(SlixTest):
self.xmpp['xep_0060'].subscribe( self.xmpp['xep_0060'].subscribe(
'pubsub.example.com', 'pubsub.example.com',
'somenode', 'somenode',
ifrom='foo@comp.example.com/bar', ifrom='foo@comp.example.com/bar')
block=False)
self.send(""" self.send("""
<iq type="set" id="1" <iq type="set" id="1"
to="pubsub.example.com" from="foo@comp.example.com/bar"> to="pubsub.example.com" from="foo@comp.example.com/bar">
@ -146,8 +137,7 @@ class TestStreamPubsub(SlixTest):
'pubsub.example.com', 'pubsub.example.com',
'somenode', 'somenode',
ifrom='foo@comp.example.com/bar', ifrom='foo@comp.example.com/bar',
bare=False, bare=False)
block=False)
self.send(""" self.send("""
<iq type="set" id="1" <iq type="set" id="1"
to="pubsub.example.com" from="foo@comp.example.com/bar"> to="pubsub.example.com" from="foo@comp.example.com/bar">
@ -168,8 +158,7 @@ class TestStreamPubsub(SlixTest):
self.xmpp['xep_0060'].subscribe( self.xmpp['xep_0060'].subscribe(
'pubsub.example.com', 'pubsub.example.com',
'somenode', 'somenode',
bare=False, bare=False)
block=False)
self.send(""" self.send("""
<iq type="set" id="1" <iq type="set" id="1"
to="pubsub.example.com"> to="pubsub.example.com">
@ -188,8 +177,7 @@ class TestStreamPubsub(SlixTest):
'pubsub.example.com', 'pubsub.example.com',
'somenode', 'somenode',
subscribee='user@example.com/foo', subscribee='user@example.com/foo',
ifrom='foo@comp.example.com/bar', ifrom='foo@comp.example.com/bar')
block=False)
self.send(""" self.send("""
<iq type="set" id="1" <iq type="set" id="1"
to="pubsub.example.com" from="foo@comp.example.com/bar"> to="pubsub.example.com" from="foo@comp.example.com/bar">
@ -215,8 +203,7 @@ class TestStreamPubsub(SlixTest):
self.xmpp['xep_0060'].subscribe( self.xmpp['xep_0060'].subscribe(
'pubsub.example.com', 'pubsub.example.com',
'somenode', 'somenode',
options=opts, options=opts)
block=False)
self.send(""" self.send("""
<iq type="set" id="1" to="pubsub.example.com"> <iq type="set" id="1" to="pubsub.example.com">
<pubsub xmlns="http://jabber.org/protocol/pubsub"> <pubsub xmlns="http://jabber.org/protocol/pubsub">
@ -242,8 +229,7 @@ class TestStreamPubsub(SlixTest):
""" """
self.xmpp['xep_0060'].unsubscribe( self.xmpp['xep_0060'].unsubscribe(
'pubsub.example.com', 'pubsub.example.com',
'somenode', 'somenode')
block=False)
self.send(""" self.send("""
<iq type="set" id="1" to="pubsub.example.com"> <iq type="set" id="1" to="pubsub.example.com">
<pubsub xmlns="http://jabber.org/protocol/pubsub"> <pubsub xmlns="http://jabber.org/protocol/pubsub">
@ -260,8 +246,7 @@ class TestStreamPubsub(SlixTest):
self.xmpp['xep_0060'].unsubscribe( self.xmpp['xep_0060'].unsubscribe(
'pubsub.example.com', 'pubsub.example.com',
'somenode', 'somenode',
ifrom='foo@comp.example.com/bar', ifrom='foo@comp.example.com/bar')
block=False)
self.send(""" self.send("""
<iq type="set" id="1" <iq type="set" id="1"
to="pubsub.example.com" from="foo@comp.example.com/bar"> to="pubsub.example.com" from="foo@comp.example.com/bar">
@ -280,8 +265,7 @@ class TestStreamPubsub(SlixTest):
'pubsub.example.com', 'pubsub.example.com',
'somenode', 'somenode',
ifrom='foo@comp.example.com/bar', ifrom='foo@comp.example.com/bar',
bare=False, bare=False)
block=False)
self.send(""" self.send("""
<iq type="set" id="1" <iq type="set" id="1"
to="pubsub.example.com" from="foo@comp.example.com/bar"> to="pubsub.example.com" from="foo@comp.example.com/bar">
@ -302,8 +286,7 @@ class TestStreamPubsub(SlixTest):
self.xmpp['xep_0060'].unsubscribe( self.xmpp['xep_0060'].unsubscribe(
'pubsub.example.com', 'pubsub.example.com',
'somenode', 'somenode',
bare=False, bare=False)
block=False)
self.send(""" self.send("""
<iq type="set" id="1" <iq type="set" id="1"
to="pubsub.example.com"> to="pubsub.example.com">
@ -322,8 +305,7 @@ class TestStreamPubsub(SlixTest):
'pubsub.example.com', 'pubsub.example.com',
'somenode', 'somenode',
subscribee='user@example.com/foo', subscribee='user@example.com/foo',
ifrom='foo@comp.example.com/bar', ifrom='foo@comp.example.com/bar')
block=False)
self.send(""" self.send("""
<iq type="set" id="1" <iq type="set" id="1"
to="pubsub.example.com" from="foo@comp.example.com/bar"> to="pubsub.example.com" from="foo@comp.example.com/bar">
@ -336,8 +318,7 @@ class TestStreamPubsub(SlixTest):
def testGetDefaultNodeConfig(self): def testGetDefaultNodeConfig(self):
"""Test retrieving the default node config for a pubsub service.""" """Test retrieving the default node config for a pubsub service."""
self.xmpp['xep_0060'].get_node_config( self.xmpp['xep_0060'].get_node_config(
'pubsub.example.com', 'pubsub.example.com')
block=False)
self.send(""" self.send("""
<iq type="get" id="1" to="pubsub.example.com"> <iq type="get" id="1" to="pubsub.example.com">
<pubsub xmlns="http://jabber.org/protocol/pubsub#owner"> <pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
@ -350,8 +331,7 @@ class TestStreamPubsub(SlixTest):
"""Test getting the config for a given node.""" """Test getting the config for a given node."""
self.xmpp['xep_0060'].get_node_config( self.xmpp['xep_0060'].get_node_config(
'pubsub.example.com', 'pubsub.example.com',
'somenode', 'somenode')
block=False)
self.send(""" self.send("""
<iq type="get" id="1" to="pubsub.example.com"> <iq type="get" id="1" to="pubsub.example.com">
<pubsub xmlns="http://jabber.org/protocol/pubsub#owner"> <pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
@ -372,8 +352,7 @@ class TestStreamPubsub(SlixTest):
self.xmpp['xep_0060'].set_node_config( self.xmpp['xep_0060'].set_node_config(
'pubsub.example.com', 'pubsub.example.com',
'somenode', 'somenode',
form, form)
block=False)
self.send(""" self.send("""
<iq type="set" id="1" to="pubsub.example.com"> <iq type="set" id="1" to="pubsub.example.com">
<pubsub xmlns="http://jabber.org/protocol/pubsub#owner"> <pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
@ -395,8 +374,7 @@ class TestStreamPubsub(SlixTest):
"""Test publishing no items (in order to generate events)""" """Test publishing no items (in order to generate events)"""
self.xmpp['xep_0060'].publish( self.xmpp['xep_0060'].publish(
'pubsub.example.com', 'pubsub.example.com',
'somenode', 'somenode')
block=False)
self.send(""" self.send("""
<iq type="set" id="1" to="pubsub.example.com"> <iq type="set" id="1" to="pubsub.example.com">
<pubsub xmlns="http://jabber.org/protocol/pubsub"> <pubsub xmlns="http://jabber.org/protocol/pubsub">
@ -416,8 +394,7 @@ class TestStreamPubsub(SlixTest):
'pubsub.example.com', 'pubsub.example.com',
'somenode', 'somenode',
id='id42', id='id42',
payload=payload, payload=payload)
block=False)
self.send(""" self.send("""
<iq type="set" id="1" to="pubsub.example.com"> <iq type="set" id="1" to="pubsub.example.com">
<pubsub xmlns="http://jabber.org/protocol/pubsub"> <pubsub xmlns="http://jabber.org/protocol/pubsub">
@ -451,8 +428,7 @@ class TestStreamPubsub(SlixTest):
'somenode', 'somenode',
id='ID42', id='ID42',
payload=payload, payload=payload,
options=options, options=options)
block=False)
self.send(""" self.send("""
<iq type="set" id="1" to="pubsub.example.com"> <iq type="set" id="1" to="pubsub.example.com">
<pubsub xmlns="http://jabber.org/protocol/pubsub"> <pubsub xmlns="http://jabber.org/protocol/pubsub">
@ -483,8 +459,7 @@ class TestStreamPubsub(SlixTest):
'pubsub.example.com', 'pubsub.example.com',
'somenode', 'somenode',
'ID1', 'ID1',
notify=True, notify=True)
block=False)
self.send(""" self.send("""
<iq type="set" id="1" to="pubsub.example.com"> <iq type="set" id="1" to="pubsub.example.com">
<pubsub xmlns="http://jabber.org/protocol/pubsub"> <pubsub xmlns="http://jabber.org/protocol/pubsub">
@ -500,8 +475,7 @@ class TestStreamPubsub(SlixTest):
self.xmpp['xep_0060'].retract( self.xmpp['xep_0060'].retract(
'pubsub.example.com', 'pubsub.example.com',
'somenode', 'somenode',
'ID1', 'ID1')
block=False)
self.send(""" self.send("""
<iq type="set" id="1" to="pubsub.example.com"> <iq type="set" id="1" to="pubsub.example.com">
<pubsub xmlns="http://jabber.org/protocol/pubsub"> <pubsub xmlns="http://jabber.org/protocol/pubsub">
@ -516,8 +490,7 @@ class TestStreamPubsub(SlixTest):
"""Test removing all items from a node.""" """Test removing all items from a node."""
self.xmpp['xep_0060'].purge( self.xmpp['xep_0060'].purge(
'pubsub.example.com', 'pubsub.example.com',
'somenode', 'somenode')
block=False)
self.send(""" self.send("""
<iq type="set" id="1" to="pubsub.example.com"> <iq type="set" id="1" to="pubsub.example.com">
<pubsub xmlns="http://jabber.org/protocol/pubsub#owner"> <pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
@ -531,8 +504,7 @@ class TestStreamPubsub(SlixTest):
self.xmpp['xep_0060'].get_item( self.xmpp['xep_0060'].get_item(
'pubsub.example.com', 'pubsub.example.com',
'somenode', 'somenode',
'id42', 'id42')
block=False)
self.send(""" self.send("""
<iq type="get" id="1" to="pubsub.example.com"> <iq type="get" id="1" to="pubsub.example.com">
<pubsub xmlns="http://jabber.org/protocol/pubsub"> <pubsub xmlns="http://jabber.org/protocol/pubsub">
@ -548,8 +520,7 @@ class TestStreamPubsub(SlixTest):
self.xmpp['xep_0060'].get_items( self.xmpp['xep_0060'].get_items(
'pubsub.example.com', 'pubsub.example.com',
'somenode', 'somenode',
max_items=3, max_items=3)
block=False)
self.send(""" self.send("""
<iq type="get" id="1" to="pubsub.example.com"> <iq type="get" id="1" to="pubsub.example.com">
<pubsub xmlns="http://jabber.org/protocol/pubsub"> <pubsub xmlns="http://jabber.org/protocol/pubsub">
@ -562,8 +533,7 @@ class TestStreamPubsub(SlixTest):
"""Test retrieving all items.""" """Test retrieving all items."""
self.xmpp['xep_0060'].get_items( self.xmpp['xep_0060'].get_items(
'pubsub.example.com', 'pubsub.example.com',
'somenode', 'somenode')
block=False)
self.send(""" self.send("""
<iq type="get" id="1" to="pubsub.example.com"> <iq type="get" id="1" to="pubsub.example.com">
<pubsub xmlns="http://jabber.org/protocol/pubsub"> <pubsub xmlns="http://jabber.org/protocol/pubsub">
@ -577,8 +547,7 @@ class TestStreamPubsub(SlixTest):
self.xmpp['xep_0060'].get_items( self.xmpp['xep_0060'].get_items(
'pubsub.example.com', 'pubsub.example.com',
'somenode', 'somenode',
item_ids=['A', 'B', 'C'], item_ids=['A', 'B', 'C'])
block=False)
self.send(""" self.send("""
<iq type="get" id="1" to="pubsub.example.com"> <iq type="get" id="1" to="pubsub.example.com">
<pubsub xmlns="http://jabber.org/protocol/pubsub"> <pubsub xmlns="http://jabber.org/protocol/pubsub">
@ -594,8 +563,7 @@ class TestStreamPubsub(SlixTest):
def testGetSubscriptionGlobalDefaultOptions(self): def testGetSubscriptionGlobalDefaultOptions(self):
"""Test getting the subscription options for a node/JID.""" """Test getting the subscription options for a node/JID."""
self.xmpp['xep_0060'].get_subscription_options( self.xmpp['xep_0060'].get_subscription_options(
'pubsub.example.com', 'pubsub.example.com')
block=False)
self.send(""" self.send("""
<iq type="get" id="1" to="pubsub.example.com"> <iq type="get" id="1" to="pubsub.example.com">
<pubsub xmlns="http://jabber.org/protocol/pubsub"> <pubsub xmlns="http://jabber.org/protocol/pubsub">
@ -608,8 +576,7 @@ class TestStreamPubsub(SlixTest):
"""Test getting the subscription options for a node/JID.""" """Test getting the subscription options for a node/JID."""
self.xmpp['xep_0060'].get_subscription_options( self.xmpp['xep_0060'].get_subscription_options(
'pubsub.example.com', 'pubsub.example.com',
node='somenode', node='somenode')
block=False)
self.send(""" self.send("""
<iq type="get" id="1" to="pubsub.example.com"> <iq type="get" id="1" to="pubsub.example.com">
<pubsub xmlns="http://jabber.org/protocol/pubsub"> <pubsub xmlns="http://jabber.org/protocol/pubsub">
@ -623,8 +590,7 @@ class TestStreamPubsub(SlixTest):
self.xmpp['xep_0060'].get_subscription_options( self.xmpp['xep_0060'].get_subscription_options(
'pubsub.example.com', 'pubsub.example.com',
'somenode', 'somenode',
'tester@localhost', 'tester@localhost')
block=False)
self.send(""" self.send("""
<iq type="get" id="1" to="pubsub.example.com"> <iq type="get" id="1" to="pubsub.example.com">
<pubsub xmlns="http://jabber.org/protocol/pubsub"> <pubsub xmlns="http://jabber.org/protocol/pubsub">
@ -650,8 +616,7 @@ class TestStreamPubsub(SlixTest):
'pubsub.example.com', 'pubsub.example.com',
'somenode', 'somenode',
'tester@localhost', 'tester@localhost',
opts, opts)
block=False)
self.send(""" self.send("""
<iq type="get" id="1" to="pubsub.example.com"> <iq type="get" id="1" to="pubsub.example.com">
<pubsub xmlns="http://jabber.org/protocol/pubsub"> <pubsub xmlns="http://jabber.org/protocol/pubsub">
@ -673,8 +638,7 @@ class TestStreamPubsub(SlixTest):
"""Test retrieving all subscriptions for a node.""" """Test retrieving all subscriptions for a node."""
self.xmpp['xep_0060'].get_node_subscriptions( self.xmpp['xep_0060'].get_node_subscriptions(
'pubsub.example.com', 'pubsub.example.com',
'somenode', 'somenode')
block=False)
self.send(""" self.send("""
<iq type="get" id="1" to="pubsub.example.com"> <iq type="get" id="1" to="pubsub.example.com">
<pubsub xmlns="http://jabber.org/protocol/pubsub#owner"> <pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
@ -686,8 +650,7 @@ class TestStreamPubsub(SlixTest):
def testGetSubscriptions(self): def testGetSubscriptions(self):
"""Test retrieving a users's subscriptions.""" """Test retrieving a users's subscriptions."""
self.xmpp['xep_0060'].get_subscriptions( self.xmpp['xep_0060'].get_subscriptions(
'pubsub.example.com', 'pubsub.example.com')
block=False)
self.send(""" self.send("""
<iq type="get" id="1" to="pubsub.example.com"> <iq type="get" id="1" to="pubsub.example.com">
<pubsub xmlns="http://jabber.org/protocol/pubsub"> <pubsub xmlns="http://jabber.org/protocol/pubsub">
@ -700,8 +663,7 @@ class TestStreamPubsub(SlixTest):
"""Test retrieving a users's subscriptions for a given node.""" """Test retrieving a users's subscriptions for a given node."""
self.xmpp['xep_0060'].get_subscriptions( self.xmpp['xep_0060'].get_subscriptions(
'pubsub.example.com', 'pubsub.example.com',
node='somenode', node='somenode')
block=False)
self.send(""" self.send("""
<iq type="get" id="1" to="pubsub.example.com"> <iq type="get" id="1" to="pubsub.example.com">
<pubsub xmlns="http://jabber.org/protocol/pubsub"> <pubsub xmlns="http://jabber.org/protocol/pubsub">
@ -713,8 +675,7 @@ class TestStreamPubsub(SlixTest):
def testGetAffiliations(self): def testGetAffiliations(self):
"""Test retrieving a users's affiliations.""" """Test retrieving a users's affiliations."""
self.xmpp['xep_0060'].get_affiliations( self.xmpp['xep_0060'].get_affiliations(
'pubsub.example.com', 'pubsub.example.com')
block=False)
self.send(""" self.send("""
<iq type="get" id="1" to="pubsub.example.com"> <iq type="get" id="1" to="pubsub.example.com">
<pubsub xmlns="http://jabber.org/protocol/pubsub"> <pubsub xmlns="http://jabber.org/protocol/pubsub">
@ -727,8 +688,7 @@ class TestStreamPubsub(SlixTest):
"""Test retrieving a users's affiliations for a given node.""" """Test retrieving a users's affiliations for a given node."""
self.xmpp['xep_0060'].get_affiliations( self.xmpp['xep_0060'].get_affiliations(
'pubsub.example.com', 'pubsub.example.com',
node='somenode', node='somenode')
block=False)
self.send(""" self.send("""
<iq type="get" id="1" to="pubsub.example.com"> <iq type="get" id="1" to="pubsub.example.com">
<pubsub xmlns="http://jabber.org/protocol/pubsub"> <pubsub xmlns="http://jabber.org/protocol/pubsub">
@ -741,8 +701,7 @@ class TestStreamPubsub(SlixTest):
"""Test getting the affiliations for a node.""" """Test getting the affiliations for a node."""
self.xmpp['xep_0060'].get_node_affiliations( self.xmpp['xep_0060'].get_node_affiliations(
'pubsub.example.com', 'pubsub.example.com',
'somenode', 'somenode')
block=False)
self.send(""" self.send("""
<iq type="get" id="1" to="pubsub.example.com"> <iq type="get" id="1" to="pubsub.example.com">
<pubsub xmlns="http://jabber.org/protocol/pubsub#owner"> <pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
@ -757,8 +716,7 @@ class TestStreamPubsub(SlixTest):
'pubsub.example.com', 'pubsub.example.com',
'somenode', 'somenode',
subscriptions=[('user@example.com', 'subscribed'), subscriptions=[('user@example.com', 'subscribed'),
('foo@example.net', 'none')], ('foo@example.net', 'none')])
block=False)
self.send(""" self.send("""
<iq type="set" id="1" to="pubsub.example.com"> <iq type="set" id="1" to="pubsub.example.com">
<pubsub xmlns="http://jabber.org/protocol/pubsub#owner"> <pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
@ -776,8 +734,7 @@ class TestStreamPubsub(SlixTest):
'pubsub.example.com', 'pubsub.example.com',
'somenode', 'somenode',
affiliations=[('user@example.com', 'publisher'), affiliations=[('user@example.com', 'publisher'),
('foo@example.net', 'none')], ('foo@example.net', 'none')])
block=False)
self.send(""" self.send("""
<iq type="set" id="1" to="pubsub.example.com"> <iq type="set" id="1" to="pubsub.example.com">
<pubsub xmlns="http://jabber.org/protocol/pubsub#owner"> <pubsub xmlns="http://jabber.org/protocol/pubsub#owner">

View File

@ -15,13 +15,8 @@ class TestOOB(SlixTest):
url = 'http://github.com/fritzy/Slixmpp/blob/master/README' url = 'http://github.com/fritzy/Slixmpp/blob/master/README'
t = threading.Thread( self.xmpp['xep_0066'].send_oob('user@example.com', url,
name='send_oob', desc='Slixmpp README')
target=self.xmpp['xep_0066'].send_oob,
args=('user@example.com', url),
kwargs={'desc': 'Slixmpp README'})
t.start()
self.send(""" self.send("""
<iq to="user@example.com" type="set" id="1"> <iq to="user@example.com" type="set" id="1">
@ -38,7 +33,5 @@ class TestOOB(SlixTest):
from="user@example.com" /> from="user@example.com" />
""") """)
t.join()
suite = unittest.TestLoader().loadTestsFromTestCase(TestOOB) suite = unittest.TestLoader().loadTestsFromTestCase(TestOOB)

View File

@ -49,8 +49,6 @@ class TestStreamChatStates(SlixTest):
</message> </message>
""") """)
# Give event queue time to process
time.sleep(0.3)
expected = ['active', 'inactive', 'paused', 'composing', 'gone'] expected = ['active', 'inactive', 'paused', 'composing', 'gone']
self.failUnless(results == expected, self.failUnless(results == expected,
"Chat state event not handled: %s" % results) "Chat state event not handled: %s" % results)

View File

@ -35,16 +35,14 @@ class TestStreamSet(SlixTest):
def testMakeSoftwareVersionRequest(self): def testMakeSoftwareVersionRequest(self):
results = [] results = []
def query(): def callback(result):
r = self.xmpp['xep_0092'].get_version('foo@bar') results.append((result['software_version']['name'],
results.append((r['software_version']['name'], result['software_version']['version'],
r['software_version']['version'], result['software_version']['os']))
r['software_version']['os']))
self.stream_start(mode='client', plugins=['xep_0030', 'xep_0092']) self.stream_start(mode='client', plugins=['xep_0030', 'xep_0092'])
t = threading.Thread(target=query) self.xmpp['xep_0092'].get_version('foo@bar', callback=callback)
t.start()
self.send(""" self.send("""
<iq type="get" id="1" to="foo@bar"> <iq type="get" id="1" to="foo@bar">
@ -62,8 +60,6 @@ class TestStreamSet(SlixTest):
</iq> </iq>
""") """)
t.join()
expected = [('Foo', '1.0', 'Linux')] expected = [('Foo', '1.0', 'Linux')]
self.assertEqual(results, expected, self.assertEqual(results, expected,
"Did not receive expected results: %s" % results) "Did not receive expected results: %s" % results)

View File

@ -35,8 +35,6 @@ class TestStreamDirectInvite(SlixTest):
</message> </message>
""") """)
time.sleep(.5)
self.failUnless(events == [True], self.failUnless(events == [True],
"Event not raised: %s" % events) "Event not raised: %s" % events)

View File

@ -455,8 +455,6 @@ class TestStreamSensorData(SlixTest):
</iq> </iq>
""") """)
time.sleep(.1)
self.failUnless(results == ["rejected"], self.failUnless(results == ["rejected"],
"Rejected callback was not properly executed"); "Rejected callback was not properly executed");
@ -494,8 +492,6 @@ class TestStreamSensorData(SlixTest):
</iq> </iq>
""") """)
time.sleep(.1)
self.failUnless(results == ["accepted"], self.failUnless(results == ["accepted"],
"Accepted callback was not properly executed"); "Accepted callback was not properly executed");
@ -517,13 +513,10 @@ class TestStreamSensorData(SlixTest):
for f in fields: for f in fields:
callback_data["field_" + f['name']] = f; callback_data["field_" + f['name']] = f;
t1= threading.Thread(name="request_data", self.xmpp['xep_0323'].request_data(from_jid="tester@localhost",
target=self.xmpp['xep_0323'].request_data, to_jid="you@google.com",
kwargs={"from_jid": "tester@localhost", nodeIds=['Device33'],
"to_jid": "you@google.com", callback=my_callback)
"nodeIds": ['Device33'],
"callback": my_callback});
t1.start();
#self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", nodeIds=['Device33'], callback=my_callback); #self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", nodeIds=['Device33'], callback=my_callback);
self.send(""" self.send("""
@ -567,9 +560,6 @@ class TestStreamSensorData(SlixTest):
</message> </message>
""") """)
t1.join();
time.sleep(.5)
self.failUnlessEqual(results, ["accepted","fields","done"]); self.failUnlessEqual(results, ["accepted","fields","done"]);
# self.assertIn("nodeId", callback_data); # self.assertIn("nodeId", callback_data);
self.assertTrue("nodeId" in callback_data) self.assertTrue("nodeId" in callback_data)
@ -651,13 +641,10 @@ class TestStreamSensorData(SlixTest):
callback_data["timestamp"] = timestamp; callback_data["timestamp"] = timestamp;
callback_data["error_msg"] = error_msg; callback_data["error_msg"] = error_msg;
t1= threading.Thread(name="request_data", self.xmpp['xep_0323'].request_data(from_jid="tester@localhost",
target=self.xmpp['xep_0323'].request_data, to_jid="you@google.com",
kwargs={"from_jid": "tester@localhost", nodeIds=['Device33'],
"to_jid": "you@google.com", callback=my_callback)
"nodeIds": ['Device33'],
"callback": my_callback});
t1.start();
self.send(""" self.send("""
<iq type='get' <iq type='get'
@ -688,9 +675,6 @@ class TestStreamSensorData(SlixTest):
</message> </message>
""") """)
t1.join();
time.sleep(.5)
self.failUnlessEqual(results, ["accepted","failure"]); self.failUnlessEqual(results, ["accepted","failure"]);
# self.assertIn("nodeId", callback_data); # self.assertIn("nodeId", callback_data);
self.assertTrue("nodeId" in callback_data); self.assertTrue("nodeId" in callback_data);
@ -737,7 +721,7 @@ class TestStreamSensorData(SlixTest):
</iq> </iq>
""") """)
time.sleep(2) time.sleep(1)
self.send(""" self.send("""
<message from='device@clayster.com' <message from='device@clayster.com'
@ -1033,13 +1017,10 @@ class TestStreamSensorData(SlixTest):
for f in fields: for f in fields:
callback_data["field_" + f['name']] = f; callback_data["field_" + f['name']] = f;
t1= threading.Thread(name="request_data", self.xmpp['xep_0323'].request_data(from_jid="tester@localhost",
target=self.xmpp['xep_0323'].request_data, to_jid="you@google.com",
kwargs={"from_jid": "tester@localhost", nodeIds=['Device33'],
"to_jid": "you@google.com", callback=my_callback)
"nodeIds": ['Device33'],
"callback": my_callback});
t1.start();
#self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", nodeIds=['Device33'], callback=my_callback); #self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", nodeIds=['Device33'], callback=my_callback);
self.send(""" self.send("""
@ -1090,9 +1071,6 @@ class TestStreamSensorData(SlixTest):
</message> </message>
""") """)
t1.join();
time.sleep(.5)
self.failUnlessEqual(results, ["queued","started","fields","done"]); self.failUnlessEqual(results, ["queued","started","fields","done"]);
# self.assertIn("nodeId", callback_data); # self.assertIn("nodeId", callback_data);
self.assertTrue("nodeId" in callback_data); self.assertTrue("nodeId" in callback_data);
@ -1161,8 +1139,6 @@ class TestStreamSensorData(SlixTest):
</iq> </iq>
""") """)
time.sleep(.5)
self.failUnlessEqual(results, ["accepted","cancelled"]); self.failUnlessEqual(results, ["accepted","cancelled"]);
def testDelayedRequestCancel(self): def testDelayedRequestCancel(self):
@ -1239,8 +1215,6 @@ class TestStreamSensorData(SlixTest):
</iq> </iq>
""") """)
time.sleep(2)
# Ensure we don't get anything after cancellation # Ensure we don't get anything after cancellation
self.send(None) self.send(None)

View File

@ -189,7 +189,7 @@ class TestStreamControl(SlixTest):
</message> </message>
""") """)
time.sleep(.5) time.sleep(0.5)
self.assertEqual(myDevice._get_field_value("Temperature"), "17"); self.assertEqual(myDevice._get_field_value("Temperature"), "17");
@ -213,8 +213,6 @@ class TestStreamControl(SlixTest):
</message> </message>
""") """)
time.sleep(.5)
self.assertEqual(myDevice._get_field_value("Temperature"), "15"); self.assertEqual(myDevice._get_field_value("Temperature"), "15");
self.assertFalse(myDevice.has_control_field("Voltage", "int")); self.assertFalse(myDevice.has_control_field("Voltage", "int"));
@ -259,8 +257,6 @@ class TestStreamControl(SlixTest):
</iq> </iq>
""") """)
time.sleep(.5)
self.assertEqual(results, ["OK"]); self.assertEqual(results, ["OK"]);
def testRequestSetErrorAPI(self): def testRequestSetErrorAPI(self):
@ -305,8 +301,6 @@ class TestStreamControl(SlixTest):
</iq> </iq>
""") """)
time.sleep(.5)
self.assertEqual(results, ["OtherError"]); self.assertEqual(results, ["OtherError"]);
def testServiceDiscoveryClient(self): def testServiceDiscoveryClient(self):