summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2021-02-27 13:16:18 +0100
committermathieui <mathieui@mathieui.net>2021-02-27 13:16:18 +0100
commit059cb290d8ae567ef189d83c45a1e38b1f3ab9dc (patch)
treeb8a85ab9a91bf7663701a077607a67a07fcc485a /tests
parent5f9ab45a5e161c3035a844184736b3180dae6047 (diff)
parent3cdec464a550b775d8c251f37b863a6e2212c5d5 (diff)
downloadslixmpp-059cb290d8ae567ef189d83c45a1e38b1f3ab9dc.tar.gz
slixmpp-059cb290d8ae567ef189d83c45a1e38b1f3ab9dc.tar.bz2
slixmpp-059cb290d8ae567ef189d83c45a1e38b1f3ab9dc.tar.xz
slixmpp-059cb290d8ae567ef189d83c45a1e38b1f3ab9dc.zip
Merge branch 'async-interal-api-break-everything' into 'master'
Make the internal "api" async See merge request poezio/slixmpp!128
Diffstat (limited to 'tests')
-rw-r--r--tests/test_stream_xep_0030.py9
-rw-r--r--tests/test_stream_xep_0047.py28
-rw-r--r--tests/test_stream_xep_0077.py4
3 files changed, 25 insertions, 16 deletions
diff --git a/tests/test_stream_xep_0030.py b/tests/test_stream_xep_0030.py
index d1ad9087..8cba8280 100644
--- a/tests/test_stream_xep_0030.py
+++ b/tests/test_stream_xep_0030.py
@@ -1,5 +1,5 @@
+import asyncio
import time
-import threading
import unittest
from slixmpp.test import SlixTest
@@ -288,7 +288,9 @@ class TestStreamDisco(SlixTest):
self.xmpp.add_event_handler('disco_info', handle_disco_info)
- self.xmpp['xep_0030'].get_info('user@localhost', 'foo')
+
+ self.xmpp.wrap(self.xmpp['xep_0030'].get_info('user@localhost', 'foo'))
+ self.wait_()
self.send("""
<iq type="get" to="user@localhost" id="1">
@@ -483,7 +485,8 @@ class TestStreamDisco(SlixTest):
self.xmpp.add_event_handler('disco_items', handle_disco_items)
- self.xmpp['xep_0030'].get_items('user@localhost', 'foo')
+ self.xmpp.wrap(self.xmpp['xep_0030'].get_items('user@localhost', 'foo'))
+ self.wait_()
self.send("""
<iq type="get" to="user@localhost" id="1">
diff --git a/tests/test_stream_xep_0047.py b/tests/test_stream_xep_0047.py
index 53225df5..a44ffbec 100644
--- a/tests/test_stream_xep_0047.py
+++ b/tests/test_stream_xep_0047.py
@@ -14,7 +14,7 @@ class TestInBandByteStreams(SlixTest):
def tearDown(self):
self.stream_close()
- async def testOpenStream(self):
+ def testOpenStream(self):
"""Test requesting a stream, successfully"""
events = []
@@ -25,8 +25,9 @@ class TestInBandByteStreams(SlixTest):
self.xmpp.add_event_handler('ibb_stream_start', on_stream_start)
- await self.xmpp['xep_0047'].open_stream('tester@localhost/receiver',
- sid='testing')
+ self.xmpp.wrap(self.xmpp['xep_0047'].open_stream('tester@localhost/receiver',
+ sid='testing'))
+ self.wait_()
self.send("""
<iq type="set" to="tester@localhost/receiver" id="1">
@@ -45,7 +46,7 @@ class TestInBandByteStreams(SlixTest):
self.assertEqual(events, ['ibb_stream_start'])
- async def testAysncOpenStream(self):
+ def testAysncOpenStream(self):
"""Test requesting a stream, aysnc"""
events = set()
@@ -58,9 +59,10 @@ class TestInBandByteStreams(SlixTest):
self.xmpp.add_event_handler('ibb_stream_start', on_stream_start)
- await self.xmpp['xep_0047'].open_stream('tester@localhost/receiver',
- sid='testing',
- callback=stream_callback)
+ self.xmpp.wrap(self.xmpp['xep_0047'].open_stream('tester@localhost/receiver',
+ sid='testing',
+ callback=stream_callback))
+ self.wait_()
self.send("""
<iq type="set" to="tester@localhost/receiver" id="1">
@@ -79,7 +81,7 @@ class TestInBandByteStreams(SlixTest):
self.assertEqual(events, {'ibb_stream_start', 'callback'})
- async def testSendData(self):
+ def testSendData(self):
"""Test sending data over an in-band bytestream."""
streams = []
@@ -89,13 +91,14 @@ class TestInBandByteStreams(SlixTest):
streams.append(stream)
def on_stream_data(d):
- data.append(d['data'])
+ data.append(d.read())
self.xmpp.add_event_handler('ibb_stream_start', on_stream_start)
self.xmpp.add_event_handler('ibb_stream_data', on_stream_data)
- self.xmpp['xep_0047'].open_stream('tester@localhost/receiver',
- sid='testing')
+ self.xmpp.wrap(self.xmpp['xep_0047'].open_stream('tester@localhost/receiver',
+ sid='testing'))
+ self.wait_()
self.send("""
<iq type="set" to="tester@localhost/receiver" id="1">
@@ -116,7 +119,8 @@ class TestInBandByteStreams(SlixTest):
# Test sending data out
- await stream.send("Testing")
+ self.xmpp.wrap(stream.send("Testing"))
+ self.wait_()
self.send("""
<iq type="set" id="2"
diff --git a/tests/test_stream_xep_0077.py b/tests/test_stream_xep_0077.py
index c47c4de5..69fc9255 100644
--- a/tests/test_stream_xep_0077.py
+++ b/tests/test_stream_xep_0077.py
@@ -91,7 +91,9 @@ class TestRegistration(SlixTest):
self.send("<iq type='result' id='reg2' from='shakespeare.lit' to='bill@shakespeare.lit/globe'/>")
pseudo_iq = self.xmpp.Iq()
pseudo_iq["from"] = "bill@shakespeare.lit/globe"
- user = self.xmpp["xep_0077"].api["user_get"](None, None, None, pseudo_iq)
+ fut = self.xmpp.wrap(self.xmpp["xep_0077"].api["user_get"](None, None, None, pseudo_iq))
+ self.run_coro(fut)
+ user = fut.result()
self.assertEqual(user["username"], "bill")
self.assertEqual(user["password"], "Calliope")
self.recv(