summaryrefslogtreecommitdiff
path: root/tests/test_stream_xep_0323.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_stream_xep_0323.py')
-rw-r--r--tests/test_stream_xep_0323.py71
1 files changed, 22 insertions, 49 deletions
diff --git a/tests/test_stream_xep_0323.py b/tests/test_stream_xep_0323.py
index 94f1d638..42230e1f 100644
--- a/tests/test_stream_xep_0323.py
+++ b/tests/test_stream_xep_0323.py
@@ -5,12 +5,12 @@ import datetime
import time
import threading
-from sleekxmpp.test import *
-from sleekxmpp.xmlstream import ElementBase
-from sleekxmpp.plugins.xep_0323.device import Device
+from slixmpp.test import *
+from slixmpp.xmlstream import ElementBase
+from slixmpp.plugins.xep_0323.device import Device
-class TestStreamSensorData(SleekTest):
+class TestStreamSensorData(SlixTest):
"""
Test using the XEP-0323 plugin.
@@ -455,8 +455,6 @@ class TestStreamSensorData(SleekTest):
</iq>
""")
- time.sleep(.1)
-
self.failUnless(results == ["rejected"],
"Rejected callback was not properly executed")
@@ -494,8 +492,6 @@ class TestStreamSensorData(SleekTest):
</iq>
""")
- time.sleep(.1)
-
self.failUnless(results == ["accepted"],
"Accepted callback was not properly executed")
@@ -517,13 +513,10 @@ class TestStreamSensorData(SleekTest):
for f in fields:
callback_data["field_" + f['name']] = f
- t1= threading.Thread(name="request_data",
- target=self.xmpp['xep_0323'].request_data,
- kwargs={"from_jid": "tester@localhost",
- "to_jid": "you@google.com",
- "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("""
@@ -567,9 +560,6 @@ class TestStreamSensorData(SleekTest):
</message>
""")
- t1.join()
- time.sleep(.5)
-
self.failUnlessEqual(results, ["accepted","fields","done"])
# self.assertIn("nodeId", callback_data);
self.assertTrue("nodeId" in callback_data)
@@ -592,7 +582,7 @@ class TestStreamSensorData(SleekTest):
self.recv("""
<iq type='get'
from='master@clayster.com/amr'
- to='tester@localhost'
+ to='tester@localhost/resource'
id='disco1'>
<query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>
@@ -617,7 +607,7 @@ class TestStreamSensorData(SleekTest):
self.recv("""
<iq type='get'
from='master@clayster.com/amr'
- to='tester@localhost'
+ to='tester@localhost/resource'
id='disco1'>
<query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>
@@ -625,7 +615,7 @@ class TestStreamSensorData(SleekTest):
self.send("""
<iq type='result'
- from='tester@localhost'
+ from='tester@localhost/resource'
to='master@clayster.com/amr'
id='disco1'>
<query xmlns='http://jabber.org/protocol/disco#info'>
@@ -651,14 +641,10 @@ class TestStreamSensorData(SleekTest):
callback_data["timestamp"] = timestamp
callback_data["error_msg"] = error_msg
- t1= threading.Thread(name="request_data",
- target=self.xmpp['xep_0323'].request_data,
- kwargs={"from_jid": "tester@localhost",
- "to_jid": "you@google.com",
- "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.send("""
<iq type='get'
from='tester@localhost'
@@ -688,10 +674,7 @@ class TestStreamSensorData(SleekTest):
</message>
""")
- t1.join()
- time.sleep(.5)
-
- self.failUnlessEqual(results, ["accepted","failure"])
+ self.failUnlessEqual(results, ["accepted","failure"]);
# self.assertIn("nodeId", callback_data);
self.assertTrue("nodeId" in callback_data)
self.failUnlessEqual(callback_data["nodeId"], "Device33")
@@ -737,7 +720,7 @@ class TestStreamSensorData(SleekTest):
</iq>
""")
- time.sleep(2)
+ time.sleep(1)
self.send("""
<message from='device@clayster.com'
@@ -1033,13 +1016,10 @@ class TestStreamSensorData(SleekTest):
for f in fields:
callback_data["field_" + f['name']] = f
- t1= threading.Thread(name="request_data",
- target=self.xmpp['xep_0323'].request_data,
- kwargs={"from_jid": "tester@localhost",
- "to_jid": "you@google.com",
- "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("""
@@ -1090,10 +1070,7 @@ class TestStreamSensorData(SleekTest):
</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.assertTrue("nodeId" in callback_data)
self.failUnlessEqual(callback_data["nodeId"], "Device33")
@@ -1161,8 +1138,6 @@ class TestStreamSensorData(SleekTest):
</iq>
""")
- time.sleep(.5)
-
self.failUnlessEqual(results, ["accepted","cancelled"])
def testDelayedRequestCancel(self):
@@ -1239,8 +1214,6 @@ class TestStreamSensorData(SleekTest):
</iq>
""")
- time.sleep(2)
-
# Ensure we don't get anything after cancellation
self.send(None)