Implement testAsync for python tests
authorDavid Reiss <dreiss@apache.org>
Mon, 18 Feb 2008 02:11:48 +0000 (02:11 +0000)
committerDavid Reiss <dreiss@apache.org>
Mon, 18 Feb 2008 02:11:48 +0000 (02:11 +0000)
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665485 13f79535-47bb-0310-9956-ffa450edef68

test/py/TestClient.py
test/py/TestServer.py

index ab2cba8..d7b65b7 100755 (executable)
@@ -86,6 +86,13 @@ class AbstractTest(unittest.TestCase):
       self.assertEqual(x.errorCode, 1001)
       self.assertEqual(x.message, 'Xception')
 
+  def testAsync(self):
+    start = time.time()
+    self.client.testAsync(2)
+    end = time.time()
+    self.assertTrue(end - start < 0.2,
+                    "async sleep took %f sec" % (end - start))
+
 class NormalBinaryTest(AbstractTest):
   protocol_factory = TBinaryProtocol.TBinaryProtocolFactory()
 
index 94a81c0..4c6cb8a 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 
-import sys, glob
+import sys, glob, time
 sys.path.insert(0, './gen-py')
 sys.path.insert(0, glob.glob('../../lib/py/build/lib.*')[0])
 
@@ -52,6 +52,11 @@ class TestHandler:
       x.message = str
       raise x
 
+  def testAsync(self, seconds):
+    print 'testAsync(%d) => sleeping...' % seconds
+    time.sleep(seconds)
+    print 'done sleeping'
+
 handler = TestHandler()
 processor = ThriftTest.Processor(handler)
 transport = TSocket.TServerSocket(9090)