[asterisk-commits] jpeeler: branch jpeeler/event_watcher r266 - /asterisk/team/jpeeler/event_wat...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Apr 29 14:55:16 CDT 2010


Author: jpeeler
Date: Thu Apr 29 14:55:13 2010
New Revision: 266

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=266
Log:
make timeout configurable and simplify test module

Modified:
    asterisk/team/jpeeler/event_watcher/tests/ami-monitor/client.py
    asterisk/team/jpeeler/event_watcher/tests/ami-monitor/run-test

Modified: asterisk/team/jpeeler/event_watcher/tests/ami-monitor/client.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/jpeeler/event_watcher/tests/ami-monitor/client.py?view=diff&rev=266&r1=265&r2=266
==============================================================================
--- asterisk/team/jpeeler/event_watcher/tests/ami-monitor/client.py (original)
+++ asterisk/team/jpeeler/event_watcher/tests/ami-monitor/client.py Thu Apr 29 14:55:13 2010
@@ -39,6 +39,7 @@
         self.testcount = 0
         self.passed = True
         self.callID = None
+        self.timeout_sec = 5
 
         self.reactorLock = threading.Lock()
         self.reactor_stopped = False
@@ -58,6 +59,9 @@
 
     def next_test(self, cb):
         self.next_test = cb
+
+    def set_timeout(self, seconds):
+        self.timeout_sec = seconds
 
     def set_test_obj(self, testobj):
         self.testobj = testobj
@@ -214,7 +218,7 @@
         method(self)
         if len(self.eventList) > 0:
             print "DEBUG: Rescheduling timeout"
-            self.callID = reactor.callLater(5, self.timeout)
+            self.callID = reactor.callLater(self.timeout_sec, self.timeout)
             return 0
     
         print "DEBUG: returning, no events..."

Modified: asterisk/team/jpeeler/event_watcher/tests/ami-monitor/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/jpeeler/event_watcher/tests/ami-monitor/run-test?view=diff&rev=266&r1=265&r2=266
==============================================================================
--- asterisk/team/jpeeler/event_watcher/tests/ami-monitor/run-test (original)
+++ asterisk/team/jpeeler/event_watcher/tests/ami-monitor/run-test Thu Apr 29 14:55:13 2010
@@ -46,27 +46,25 @@
         #watcher.add_event(event3)
         #watcher.set_ordered(True)
        
-    def main(self):
-        logging.basicConfig()
+def main():
+    logging.basicConfig()
     
-        manager.log.setLevel(logging.DEBUG)
-        watcher = client.EventWatcher()
-        watcher.log.setLevel(logging.DEBUG)
-        watcher.set_test_obj(self)
-    
-        reactor.callWhenRunning(watcher.start)
-        reactor.run()
-            
-        if watcher.passed:
-            print "DEBUG: all good!"
-            return 0
-        print "DEBUG: FAIL"
-        return 1
-          
-def main():
-    mytest = Test()
-    mytest.main()
-    
+    manager.log.setLevel(logging.DEBUG)
+    watcher = client.EventWatcher()
+    tester = Test()
+    watcher.log.setLevel(logging.DEBUG)
+    watcher.set_test_obj(tester)
+    watcher.set_timeout(5)
+   
+    reactor.callWhenRunning(watcher.start)
+    reactor.run()
+        
+    if watcher.passed:
+        print "DEBUG: all good!"
+        return 0
+    print "DEBUG: FAIL"
+    return 1
+      
 if __name__ == "__main__":
     sys.exit(main() or 0)
 




More information about the asterisk-commits mailing list