From 1e2665df19a866d5676abec566b9d8f190ecdc80 Mon Sep 17 00:00:00 2001 From: mathieui Date: Thu, 12 Feb 2015 12:23:47 +0100 Subject: 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 --- tests/test_stream_xep_0323.py | 52 +++++++++++-------------------------------- 1 file changed, 13 insertions(+), 39 deletions(-) (limited to 'tests/test_stream_xep_0323.py') diff --git a/tests/test_stream_xep_0323.py b/tests/test_stream_xep_0323.py index d8e3b01f..1a25ec2a 100644 --- a/tests/test_stream_xep_0323.py +++ b/tests/test_stream_xep_0323.py @@ -455,8 +455,6 @@ class TestStreamSensorData(SlixTest): """) - time.sleep(.1) - self.failUnless(results == ["rejected"], "Rejected callback was not properly executed"); @@ -494,8 +492,6 @@ class TestStreamSensorData(SlixTest): """) - time.sleep(.1) - self.failUnless(results == ["accepted"], "Accepted callback was not properly executed"); @@ -517,13 +513,10 @@ class TestStreamSensorData(SlixTest): 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(SlixTest): """) - t1.join(); - time.sleep(.5) - self.failUnlessEqual(results, ["accepted","fields","done"]); # self.assertIn("nodeId", callback_data); self.assertTrue("nodeId" in callback_data) @@ -651,13 +641,10 @@ class TestStreamSensorData(SlixTest): 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(""" """) - t1.join(); - time.sleep(.5) - self.failUnlessEqual(results, ["accepted","failure"]); # self.assertIn("nodeId", callback_data); self.assertTrue("nodeId" in callback_data); @@ -737,7 +721,7 @@ class TestStreamSensorData(SlixTest): """) - time.sleep(2) + time.sleep(1) self.send(""" """) - t1.join(); - time.sleep(.5) - self.failUnlessEqual(results, ["queued","started","fields","done"]); # self.assertIn("nodeId", callback_data); self.assertTrue("nodeId" in callback_data); @@ -1161,8 +1139,6 @@ class TestStreamSensorData(SlixTest): """) - time.sleep(.5) - self.failUnlessEqual(results, ["accepted","cancelled"]); def testDelayedRequestCancel(self): @@ -1239,8 +1215,6 @@ class TestStreamSensorData(SlixTest): """) - time.sleep(2) - # Ensure we don't get anything after cancellation self.send(None) -- cgit v1.2.3