[asterisk-commits] pabelanger: branch pabelanger/testClass r1119 - in /asterisk/team/pabelanger/...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Dec 8 19:21:48 CST 2010
Author: pabelanger
Date: Wed Dec 8 19:21:44 2010
New Revision: 1119
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=1119
Log:
Move reactor into TestCase
Modified:
asterisk/team/pabelanger/testClass/lib/python/asterisk/TestCase.py
asterisk/team/pabelanger/testClass/tests/manager/login/run-test
asterisk/team/pabelanger/testClass/tests/udptl/run-test
Modified: asterisk/team/pabelanger/testClass/lib/python/asterisk/TestCase.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/testClass/lib/python/asterisk/TestCase.py?view=diff&rev=1119&r1=1118&r2=1119
==============================================================================
--- asterisk/team/pabelanger/testClass/lib/python/asterisk/TestCase.py (original)
+++ asterisk/team/pabelanger/testClass/lib/python/asterisk/TestCase.py Wed Dec 8 19:21:44 2010
@@ -9,13 +9,22 @@
import sys
from optparse import OptionParser
+from twisted.internet import reactor
from asterisk import Asterisk
class TestCase(object):
ast = []
+ reactor_timeout = 30
+ passed = False
def __init__(self, argv):
+ """
+
+ Keywork arguments:
+ argv --
+
+ """
# get version info
parser = OptionParser()
parser.add_option("-v", "--version", dest="ast_version",
@@ -26,9 +35,11 @@
(self.options, args) = parser.parse_args(argv)
self.options.base = self.options.test_name.lstrip("tests/")
+ reactor.callWhenRunning(self.run)
+
def create_asterisk(self, count=1):
for c in range(count):
- print "Creating Asterisk instance %d..." % (c + 1)
+ print "Creating Asterisk instance %d ..." % (c + 1)
self.ast.append(Asterisk(base=self.options.base))
# Copy shared config files
self.ast[c].install_configs("%s/configs" %
@@ -39,11 +50,20 @@
def start_asterisk(self):
for index, item in enumerate(self.ast):
- print "Starting Asterisk instance %d..." % (index + 1)
+ print "Starting Asterisk instance %d ..." % (index + 1)
self.ast[index].start()
def stop_asterisk(self):
for index, item in enumerate(self.ast):
- print "Stopping Asterisk instance %d..." % (index + 1)
+ print "Stopping Asterisk instance %d ..." % (index + 1)
self.ast[index].stop()
+ def stop_reactor(self):
+ print "Stopping Reactor ..."
+ if reactor.running:
+ reactor.stop()
+
+ def run(self):
+ reactor.callLater(self.reactor_timeout, self.stop_reactor)
+
+
Modified: asterisk/team/pabelanger/testClass/tests/manager/login/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/testClass/tests/manager/login/run-test?view=diff&rev=1119&r1=1118&r2=1119
==============================================================================
--- asterisk/team/pabelanger/testClass/tests/manager/login/run-test (original)
+++ asterisk/team/pabelanger/testClass/tests/manager/login/run-test Wed Dec 8 19:21:44 2010
@@ -8,11 +8,7 @@
'''
import sys
-import os
-import shutil
-import time
-from twisted.application import service, internet
-from twisted.internet import reactor, defer
+from twisted.internet import reactor
from starpy import manager
sys.path.append("lib/python")
@@ -21,19 +17,11 @@
class AMILoginTest(TestCase):
def __init__(self, argv):
- self.passed = False
self.last_step = ""
self.ami = None
TestCase.__init__(self, argv)
self.create_asterisk()
-
- reactor.callWhenRunning(self.run)
-
- def stop_reactor(self):
- print "Stopping Reactor ..."
- if reactor.running:
- reactor.stop()
def log_last_step(self, step):
print step
@@ -55,8 +43,7 @@
self.log_last_step("Logging off")
def run(self):
- # A timeout in case things hang and fail
- reactor.callLater(20, self.stop_reactor)
+ TestCase.run(self)
self.log_last_step("Logging in to the AMI")
self.ami_factory = manager.AMIFactory("user", "mysecret")
Modified: asterisk/team/pabelanger/testClass/tests/udptl/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/testClass/tests/udptl/run-test?view=diff&rev=1119&r1=1118&r2=1119
==============================================================================
--- asterisk/team/pabelanger/testClass/tests/udptl/run-test (original)
+++ asterisk/team/pabelanger/testClass/tests/udptl/run-test Wed Dec 8 19:21:44 2010
@@ -7,12 +7,7 @@
the GNU General Public License Version 2.
'''
import sys
-import os
-import signal
-import subprocess
-from optparse import OptionParser
-from twisted.application import service, internet
-from twisted.internet import reactor, defer
+from twisted.internet import reactor
from starpy import manager
sys.path.append("lib/python")
@@ -23,12 +18,10 @@
class UdptlTest(TestCase):
def __init__(self, argv):
self.last_step = ""
- self.passed = False
+ self.reactor_timeout = 60
TestCase.__init__(self, argv)
self.create_asterisk(2)
-
- reactor.callWhenRunning(self.run)
def ami_on_connect1(self, ami):
self.log_last_step("Connected to AMI 1")
@@ -72,14 +65,9 @@
print step
self.lastStep = step
- def stop_reactor(self):
- print "Stopping reactor"
- if reactor.running:
- reactor.stop()
-
def run(self):
+ TestCase.run(self)
self.ami_login()
- self.shutdowncall = reactor.callLater(60, self.stop_reactor)
def main(argv=None):
@@ -97,3 +85,5 @@
if __name__ == "__main__":
sys.exit(main() or 0)
+
+# vim:sw=4:ts=4:expandtab:textwidth=79
More information about the asterisk-commits
mailing list