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
25 changed files with 211 additions and 684 deletions

View File

@@ -455,8 +455,6 @@ class TestStreamSensorData(SlixTest):
</iq>
""")
time.sleep(.1)
self.failUnless(results == ["rejected"],
"Rejected callback was not properly executed");
@@ -494,8 +492,6 @@ class TestStreamSensorData(SlixTest):
</iq>
""")
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):
</message>
""")
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("""
<iq type='get'
@@ -688,9 +675,6 @@ class TestStreamSensorData(SlixTest):
</message>
""")
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):
</iq>
""")
time.sleep(2)
time.sleep(1)
self.send("""
<message from='device@clayster.com'
@@ -1033,13 +1017,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("""
@@ -1090,9 +1071,6 @@ class TestStreamSensorData(SlixTest):
</message>
""")
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):
</iq>
""")
time.sleep(.5)
self.failUnlessEqual(results, ["accepted","cancelled"]);
def testDelayedRequestCancel(self):
@@ -1239,8 +1215,6 @@ class TestStreamSensorData(SlixTest):
</iq>
""")
time.sleep(2)
# Ensure we don't get anything after cancellation
self.send(None)