[asterisk-commits] pabelanger: testsuite/asterisk/trunk r1520 - in /asterisk/trunk: ./ configs/ ...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu May 19 11:54:48 CDT 2011


Author: pabelanger
Date: Thu May 19 11:54:42 2011
New Revision: 1520

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=1520
Log:
Remerge python TestCase class.

Added:
    asterisk/trunk/configs/manager.conf
      - copied unchanged from r1519, asterisk/team/pabelanger/testClass/configs/manager.conf
    asterisk/trunk/configs/manager.general.conf.inc
      - copied unchanged from r1519, asterisk/team/pabelanger/testClass/configs/manager.general.conf.inc
    asterisk/trunk/configs/manager.users.conf.inc
      - copied unchanged from r1519, asterisk/team/pabelanger/testClass/configs/manager.users.conf.inc
    asterisk/trunk/lib/python/asterisk/TestCase.py
      - copied unchanged from r1519, asterisk/team/pabelanger/testClass/lib/python/asterisk/TestCase.py
    asterisk/trunk/tests/fastagi/channel-status/configs/
      - copied from r1519, asterisk/team/pabelanger/testClass/tests/fastagi/channel-status/configs/
    asterisk/trunk/tests/fastagi/channel-status/configs/ast1/
      - copied from r1519, asterisk/team/pabelanger/testClass/tests/fastagi/channel-status/configs/ast1/
    asterisk/trunk/tests/fastagi/channel-status/configs/ast1/extensions.conf
      - copied unchanged from r1519, asterisk/team/pabelanger/testClass/tests/fastagi/channel-status/configs/ast1/extensions.conf
    asterisk/trunk/tests/fastagi/channel-status/configs/ast1/manager.general.conf.inc
      - copied unchanged from r1519, asterisk/team/pabelanger/testClass/tests/fastagi/channel-status/configs/ast1/manager.general.conf.inc
    asterisk/trunk/tests/fastagi/connect/configs/
      - copied from r1519, asterisk/team/pabelanger/testClass/tests/fastagi/connect/configs/
    asterisk/trunk/tests/fastagi/connect/configs/ast1/
      - copied from r1519, asterisk/team/pabelanger/testClass/tests/fastagi/connect/configs/ast1/
    asterisk/trunk/tests/fastagi/connect/configs/ast1/extensions.conf
      - copied unchanged from r1519, asterisk/team/pabelanger/testClass/tests/fastagi/connect/configs/ast1/extensions.conf
    asterisk/trunk/tests/fastagi/connect/configs/ast1/manager.general.conf.inc
      - copied unchanged from r1519, asterisk/team/pabelanger/testClass/tests/fastagi/connect/configs/ast1/manager.general.conf.inc
    asterisk/trunk/tests/fastagi/control-stream-file/configs/
      - copied from r1519, asterisk/team/pabelanger/testClass/tests/fastagi/control-stream-file/configs/
    asterisk/trunk/tests/fastagi/control-stream-file/configs/ast1/
      - copied from r1519, asterisk/team/pabelanger/testClass/tests/fastagi/control-stream-file/configs/ast1/
    asterisk/trunk/tests/fastagi/control-stream-file/configs/ast1/extensions.conf
      - copied unchanged from r1519, asterisk/team/pabelanger/testClass/tests/fastagi/control-stream-file/configs/ast1/extensions.conf
    asterisk/trunk/tests/fastagi/control-stream-file/configs/ast1/manager.general.conf.inc
      - copied unchanged from r1519, asterisk/team/pabelanger/testClass/tests/fastagi/control-stream-file/configs/ast1/manager.general.conf.inc
    asterisk/trunk/tests/fastagi/database/configs/
      - copied from r1519, asterisk/team/pabelanger/testClass/tests/fastagi/database/configs/
    asterisk/trunk/tests/fastagi/database/configs/ast1/
      - copied from r1519, asterisk/team/pabelanger/testClass/tests/fastagi/database/configs/ast1/
    asterisk/trunk/tests/fastagi/database/configs/ast1/extensions.conf
      - copied unchanged from r1519, asterisk/team/pabelanger/testClass/tests/fastagi/database/configs/ast1/extensions.conf
    asterisk/trunk/tests/fastagi/database/configs/ast1/manager.general.conf.inc
      - copied unchanged from r1519, asterisk/team/pabelanger/testClass/tests/fastagi/database/configs/ast1/manager.general.conf.inc
    asterisk/trunk/tests/manager/login/configs/ast1/manager.general.conf.inc
      - copied unchanged from r1519, asterisk/team/pabelanger/testClass/tests/manager/login/configs/ast1/manager.general.conf.inc
    asterisk/trunk/tests/regressions/
      - copied from r1519, asterisk/team/pabelanger/testClass/tests/regressions/
    asterisk/trunk/tests/regressions/M18882/
      - copied from r1519, asterisk/team/pabelanger/testClass/tests/regressions/M18882/
    asterisk/trunk/tests/regressions/M18882/configs/
      - copied from r1519, asterisk/team/pabelanger/testClass/tests/regressions/M18882/configs/
    asterisk/trunk/tests/regressions/M18882/configs/ast1/
      - copied from r1519, asterisk/team/pabelanger/testClass/tests/regressions/M18882/configs/ast1/
    asterisk/trunk/tests/regressions/M18882/configs/ast1/manager.general.conf.inc
      - copied unchanged from r1519, asterisk/team/pabelanger/testClass/tests/regressions/M18882/configs/ast1/manager.general.conf.inc
    asterisk/trunk/tests/regressions/M18882/configs/ast1/sip.conf
      - copied unchanged from r1519, asterisk/team/pabelanger/testClass/tests/regressions/M18882/configs/ast1/sip.conf
    asterisk/trunk/tests/regressions/M18882/run-test
      - copied unchanged from r1519, asterisk/team/pabelanger/testClass/tests/regressions/M18882/run-test
    asterisk/trunk/tests/regressions/M18882/test-config.yaml
      - copied unchanged from r1519, asterisk/team/pabelanger/testClass/tests/regressions/M18882/test-config.yaml
    asterisk/trunk/tests/regressions/tests.yaml
      - copied unchanged from r1519, asterisk/team/pabelanger/testClass/tests/regressions/tests.yaml
    asterisk/trunk/tests/udptl/configs/ast1/manager.general.conf.inc
      - copied unchanged from r1519, asterisk/team/pabelanger/testClass/tests/udptl/configs/ast1/manager.general.conf.inc
    asterisk/trunk/tests/udptl/configs/ast2/manager.general.conf.inc
      - copied unchanged from r1519, asterisk/team/pabelanger/testClass/tests/udptl/configs/ast2/manager.general.conf.inc
Removed:
    asterisk/trunk/tests/manager/login/configs/ast1/manager.conf
Modified:
    asterisk/trunk/   (props changed)
    asterisk/trunk/configs/asterisk.options.conf.inc
    asterisk/trunk/lib/python/asterisk/__init__.py
    asterisk/trunk/lib/python/asterisk/asterisk.py
    asterisk/trunk/runtests.py
    asterisk/trunk/tests/callparking/run-test
    asterisk/trunk/tests/fastagi/channel-status/run-test
    asterisk/trunk/tests/fastagi/connect/run-test
    asterisk/trunk/tests/fastagi/control-stream-file/run-test
    asterisk/trunk/tests/fastagi/database/run-test
    asterisk/trunk/tests/fastagi/execute/run-test
    asterisk/trunk/tests/fastagi/get-data/run-test
    asterisk/trunk/tests/fastagi/hangup/run-test
    asterisk/trunk/tests/fastagi/record-file/run-test
    asterisk/trunk/tests/fastagi/say-alpha/run-test
    asterisk/trunk/tests/fastagi/say-date/run-test
    asterisk/trunk/tests/fastagi/say-datetime/run-test
    asterisk/trunk/tests/fastagi/say-digits/run-test
    asterisk/trunk/tests/fastagi/say-number/run-test
    asterisk/trunk/tests/fastagi/say-phonetic/run-test
    asterisk/trunk/tests/fastagi/say-time/run-test
    asterisk/trunk/tests/fastagi/stream-file/run-test
    asterisk/trunk/tests/fastagi/wait-for-digit/run-test
    asterisk/trunk/tests/feature_attended_transfer/run-test
    asterisk/trunk/tests/feature_blonde_transfer/run-test
    asterisk/trunk/tests/manager/login/run-test
    asterisk/trunk/tests/mixmonitor/run-test
    asterisk/trunk/tests/one-step-parking/run-test
    asterisk/trunk/tests/pbx/call-files/run-test
    asterisk/trunk/tests/tests.yaml
    asterisk/trunk/tests/udptl/run-test
    asterisk/trunk/tests/udptl_v6/run-test

Propchange: asterisk/trunk/
------------------------------------------------------------------------------
    svn:mergeinfo = /asterisk/trunk:1112

Modified: asterisk/trunk/configs/asterisk.options.conf.inc
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/configs/asterisk.options.conf.inc?view=diff&rev=1520&r1=1519&r2=1520
==============================================================================
--- asterisk/trunk/configs/asterisk.options.conf.inc (original)
+++ asterisk/trunk/configs/asterisk.options.conf.inc Thu May 19 11:54:42 2011
@@ -4,3 +4,4 @@
 verbose = 15
 nocolor = yes
 dumpcore = yes
+execincludes = yes

Modified: asterisk/trunk/lib/python/asterisk/__init__.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/__init__.py?view=diff&rev=1520&r1=1519&r2=1520
==============================================================================
--- asterisk/trunk/lib/python/asterisk/__init__.py (original)
+++ asterisk/trunk/lib/python/asterisk/__init__.py Thu May 19 11:54:42 2011
@@ -1,1 +1,0 @@
-__all__ = [ "asterisk", "config", "version", "cdr", "utils" ]

Modified: asterisk/trunk/lib/python/asterisk/asterisk.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/asterisk.py?view=diff&rev=1520&r1=1519&r2=1520
==============================================================================
--- asterisk/trunk/lib/python/asterisk/asterisk.py (original)
+++ asterisk/trunk/lib/python/asterisk/asterisk.py Thu May 19 11:54:42 2011
@@ -43,24 +43,25 @@
     asterisk.conf.
     """
 
-    def __init__(self, base=None, ast_conf_options=None):
+    def __init__(self, base=None, ast_conf_options=None, host="127.0.0.1"):
         """Construct an Asterisk instance.
 
         Keyword Arguments:
         base -- This is the root of the files associated with this instance of
-        Asterisk.  By default, the base is "tmp/" within the current working
-        directory.  Given a base, a unique directory name will be generated to
-        hold all files.
-
-        Example Usage:
-        self.asterisk = Asterisk(base=os.path.join(os.getcwd(),
-                                                   "tests/ami-login/tmp"))
+        Asterisk.  By default, the base is "/tmp/asterisk-testsuite" directory.
+        Given a base, it will be appended to the default base directory.
+
+        Example Usage:
+        self.asterisk = Asterisk(base="manager/login")
         """
         self.directories = {}
         self.ast_version = AsteriskVersion()
 
+        self.base = "/tmp/asterisk-testsuite"
         self.astetcdir = "/etc/asterisk"
         self.ast_binary = utils.which("asterisk") or "/usr/sbin/asterisk"
+        self.host = host
+        self.valgrind = False
 
         # Find the system installed asterisk.conf
         ast_confs = [
@@ -76,10 +77,8 @@
             print "No asterisk.conf found on the system!"
             return
 
-        # Choose an install base
-        self.base = base
-        if self.base is None:
-            self.base = "%s/tmp" % os.getcwd()
+        if base is not None:
+            self.base = "%s/%s" % (self.base, base)
         i = 1
         while True:
             if not os.path.isdir("%s/ast%d" % (self.base, i)):
@@ -115,6 +114,8 @@
             "-f", "-g", "-q", "-m", "-n",
             "-C", "%s" % os.path.join(self.astetcdir, "asterisk.conf")
         ]
+        if self.valgrind:
+            cmd.insert(0, "valgrind")
         try:
             self.process = subprocess.Popen(cmd)
         except OSError:

Modified: asterisk/trunk/runtests.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/runtests.py?view=diff&rev=1520&r1=1519&r2=1520
==============================================================================
--- asterisk/trunk/runtests.py (original)
+++ asterisk/trunk/runtests.py Thu May 19 11:54:42 2011
@@ -109,7 +109,7 @@
             "res_fax_spandsp.so",
             "res_fax_digium.so",
         ]
-        ast = Asterisk(base="/tmp/asterisk-testsuite/runtests")
+        ast = Asterisk()
 
         if "astmoddir" not in ast.directories:
             return False
@@ -121,12 +121,13 @@
 
 
 class TestConfig:
-    def __init__(self, test_name, ast_version):
+    def __init__(self, test_name, ast_version, options):
         self.can_run = True
         self.did_run = False
         self.time = 0.0
         self.test_name = test_name
         self.ast_version = ast_version
+        self.options = options
         self.skip = None
         self.config = None
         self.summary = None
@@ -145,8 +146,11 @@
         start_time = time.time()
         cmd = [
             "%s/run-test" % self.test_name,
-            "-v", str(self.ast_version)
+            "-v", str(self.ast_version),
+            "-n", str(self.test_name)
         ]
+        if self.options.valgrind:
+            cmd.append("--valgrind")
         if os.path.exists(cmd[0]) and os.access(cmd[0], os.X_OK):
             print "Running %s ..." % cmd
             try:
@@ -281,7 +285,7 @@
             for val in t:
                 path = "%s/%s" % (test_dir, t[val])
                 if val == "test":
-                    tests.append(TestConfig(path, ast_version))
+                    tests.append(TestConfig(path, ast_version, self.options))
                 elif val == "dir":
                     tests += self._parse_test_yaml(path, ast_version)
 
@@ -401,6 +405,9 @@
     parser.add_option("-t", "--test",
             dest="test",
             help="Run a single specified test instead of all tests.")
+    parser.add_option("--valgrind", action="store_true",
+            dest="valgrind", default=False,
+            help="Run Asterisk under valgrind.")
     (options, args) = parser.parse_args(argv)
 
     # Check to see if this has been executed within a sub directory of an

Modified: asterisk/trunk/tests/callparking/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/callparking/run-test?view=diff&rev=1520&r1=1519&r2=1520
==============================================================================
--- asterisk/trunk/tests/callparking/run-test (original)
+++ asterisk/trunk/tests/callparking/run-test Thu May 19 11:54:42 2011
@@ -37,6 +37,9 @@
         parser = OptionParser()
         parser.add_option("-v", "--version", dest="ast_version",
          help="Asterisk version string")
+        parser.add_option("-n", dest="test_name",
+                help="Test name")
+
         (options, args) = parser.parse_args(argv)
         self.ast_version = AsteriskVersion(options.ast_version)
 

Modified: asterisk/trunk/tests/fastagi/channel-status/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/channel-status/run-test?view=diff&rev=1520&r1=1519&r2=1520
==============================================================================
--- asterisk/trunk/tests/fastagi/channel-status/run-test (original)
+++ asterisk/trunk/tests/fastagi/channel-status/run-test Thu May 19 11:54:42 2011
@@ -8,37 +8,21 @@
 '''
 
 import sys
-import os
-from optparse import OptionParser
 from twisted.internet import reactor
-from starpy import fastagi
 
 sys.path.append("lib/python")
 from asterisk.asterisk import Asterisk
-from asterisk.version import AsteriskVersion
+from asterisk.TestCase import TestCase
 
-workingdir = "/tmp/asterisk-testsuite/fastagi/channel-status"
-testdir = "tests/fastagi"
 
-class FastAGIChannelStatusTest:
+class FastAGIChannelStatusTest(TestCase):
     def __init__(self, argv):
+        TestCase.__init__(self, argv)
         self.passed = {'4': False, '6':False}
-        self.timeout = 30
         self.test = 4
 
-        parser = OptionParser()
-        parser.add_option("-v", "--version", dest="ast_version",
-                          help="Asterisk version string")
-        (options, args) = parser.parse_args(argv)
-        self.ast_version = AsteriskVersion(options.ast_version)
-
-        # Listen for results from dialplan
-        self.agi_factory = fastagi.FastAGIFactory(self.do_test)
-        reactor.listenTCP(4573, self.agi_factory, self.timeout, '127.0.0.1')
-        reactor.callWhenRunning(self.run)
-
-        self.ast1 = Asterisk(base=workingdir)
-        self.ast1.install_configs("%s/configs/ast1" % (testdir))
+        self.create_asterisk()
+        self.create_fastagi_factory()
 
     def on_answer_failure(self, reason):
         print 'Could not answer the call:', reason.getTraceback()
@@ -47,7 +31,7 @@
         print 'Could not run deferred:', reason.getTraceback()
 
     def on_answer(self, status):
-        self.do_test(self.agi)
+        self.fastagi_connect(self.agi)
 
     def get_deferred(self, agi):
         return agi.channelStatus(agi.variables['agi_channel'])
@@ -65,7 +49,7 @@
 
     # This gets invoked by the dialplan when the call is answered
     # Disconnect agi and set test result values
-    def do_test(self, agi):
+    def fastagi_connect(self, agi):
         self.agi = agi
         if self.test == 4:
             print "Connection established. Testing for channel status code 4."
@@ -84,22 +68,9 @@
         else:
             print "Failed"
 
-    def stop_reactor(self):
-        print "Stopping Reactor ..."
-        if reactor.running:
-            reactor.stop()
-
     def launch_test(self):
         print "Originating call to begin test."
-        self.ast1.cli_originate("Local/no_answer at agitest extension echo at agitest", blocking=False)
-
-    def start_asterisk(self):
-        print "Starting Asterisk"
-        self.ast1.start()
-
-    def stop_asterisk(self):
-        print "Stopping Asterisk"
-        self.ast1.stop()
+        self.ast[0].cli_originate("Local/no_answer at agitest extension echo at agitest", blocking=False)
 
     # Read result before timeout 
     def result_changed(self):
@@ -107,8 +78,8 @@
             self.read_result()
 
     def run(self):
+        TestCase.run(self)
         self.launch_test()
-        reactor.callLater(self.timeout, self.stop_reactor)
 
 def main(argv=None):
     if argv is None:

Modified: asterisk/trunk/tests/fastagi/connect/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/connect/run-test?view=diff&rev=1520&r1=1519&r2=1520
==============================================================================
--- asterisk/trunk/tests/fastagi/connect/run-test (original)
+++ asterisk/trunk/tests/fastagi/connect/run-test Thu May 19 11:54:42 2011
@@ -8,79 +8,37 @@
 '''
 
 import sys
-import os
-from optparse import OptionParser
 from twisted.internet import reactor
-from starpy import fastagi
 
 sys.path.append("lib/python")
 from asterisk.asterisk import Asterisk
-from asterisk.version import AsteriskVersion
-
-workingdir = "/tmp/asterisk-testsuite/fastagi/connect"
-testdir = "tests/fastagi"
+from asterisk.TestCase import TestCase
 
 
-class FastAGIConnectTest:
+class FastAGIConnectTest(TestCase):
     def __init__(self, argv):
-        self.passed = False
-        self.timeout = 30
+        TestCase.__init__(self, argv)
 
-        parser = OptionParser()
-        parser.add_option("-v", "--version", dest="ast_version",
-                          help="Asterisk version string")
-        (options, args) = parser.parse_args(argv)
-        self.ast_version = AsteriskVersion(options.ast_version)
+        self.create_asterisk()
+        self.create_fastagi_factory()
 
-        # Listen for results from dialplan
-        self.agi_factory = fastagi.FastAGIFactory(self.do_test)
-        reactor.listenTCP(4573, self.agi_factory, self.timeout, '127.0.0.1')
-        reactor.callWhenRunning(self.run)
-
-        self.ast1 = Asterisk(base=workingdir)
-        self.ast1.install_configs("%s/configs/ast1" % (testdir))
-
-    # This gets invoked by the dialplan when the call is answered
-    # Disconnect agi and set test result values
-    def do_test(self, agi):
+    def fastagi_connect(self, agi):
         print "Connection established."
         self.passed = True
         self.result_changed()
         return agi.finish()
 
-    def read_result(self):
-        self.stop_reactor()
-
-        if self.passed is True:
-            print "Success"
-        else:
-            print "Failed"
-
-    def stop_reactor(self):
-        print "Stopping Reactor ..."
-        if reactor.running:
-            reactor.stop()
-
     def launch_test(self):
         print "Originating call to begin test."
-        self.ast1.cli_originate("Local/501 at agitest extension echo at agitest")
+        self.ast[0].cli_originate("Local/501 at agitest extension echo at agitest")
 
-    def start_asterisk(self):
-        print "Starting Asterisk"
-        self.ast1.start()
-
-    def stop_asterisk(self):
-        print "Stopping Asterisk"
-        self.ast1.stop()
-
-    # Read result before timeout 
     def result_changed(self):
         if self.passed is True:
-            self.read_result()
+            self.stop_reactor()
 
     def run(self):
+        TestCase.run(self)
         self.launch_test()
-        reactor.callLater(self.timeout, self.stop_reactor)
 
 
 def main(argv=None):

Modified: asterisk/trunk/tests/fastagi/control-stream-file/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/control-stream-file/run-test?view=diff&rev=1520&r1=1519&r2=1520
==============================================================================
--- asterisk/trunk/tests/fastagi/control-stream-file/run-test (original)
+++ asterisk/trunk/tests/fastagi/control-stream-file/run-test Thu May 19 11:54:42 2011
@@ -8,37 +8,19 @@
 '''
 
 import sys
-import os
-from optparse import OptionParser
 from twisted.internet import reactor
-from starpy import fastagi
 
 sys.path.append("lib/python")
 from asterisk.asterisk import Asterisk
-from asterisk.version import AsteriskVersion
-
-workingdir = "/tmp/asterisk-testsuite/fastagi/control-stream-file"
-testdir = "tests/fastagi"
+from asterisk.TestCase import TestCase
 
 
-class FastAGIControlStreamFileTest:
+class FastAGIControlStreamFileTest(TestCase):
     def __init__(self, argv):
-        self.passed = False
-        self.timeout = 30
+        TestCase.__init__(self, argv)
 
-        parser = OptionParser()
-        parser.add_option("-v", "--version", dest="ast_version",
-                          help="Asterisk version string")
-        (options, args) = parser.parse_args(argv)
-        self.ast_version = AsteriskVersion(options.ast_version)
-
-        # Listen for results from dialplan
-        self.agi_factory = fastagi.FastAGIFactory(self.do_test)
-        reactor.listenTCP(4573, self.agi_factory, self.timeout, '127.0.0.1')
-        reactor.callWhenRunning(self.run)
-
-        self.ast1 = Asterisk(base=workingdir)
-        self.ast1.install_configs("%s/configs/ast1" % (testdir))
+        self.create_asterisk()
+        self.create_fastagi_factory()
 
     def on_failure(self, reason):
         print 'Could not run CONTROL STREAM FILE: ', reason.getTraceback()
@@ -51,46 +33,25 @@
 
         self.result_changed()
 
-    # This gets invoked by the dialplan when the call is answered
-    # send CONTROL STREAM FILE command and wait for results
-    def do_test(self, agi):
+    def fastagi_connect(self, agi):
         self.agi = agi
         print "Connection established."
         return agi.controlStreamFile("beep", "").addCallback(
-            self.finish_test).addErrback(self.on_failure)
-
-    def read_result(self):
-        self.stop_reactor()
-        if self.passed is True:
-            print "Success"
-        else:
-            print "Failed"
-
-    def stop_reactor(self):
-        print "Stopping Reactor ..."
-        if reactor.running:
-            reactor.stop()
+            self.finish_test)
 
     def launch_test(self):
         print "Originating call to begin test."
-        self.ast1.cli_originate("Local/504 at agitest extension echo at agitest")
-
-    def start_asterisk(self):
-        print "Starting Asterisk"
-        self.ast1.start()
-
-    def stop_asterisk(self):
-        print "Stopping Asterisk"
-        self.ast1.stop()
+        self.ast[0].cli_originate("Local/504 at agitest extension echo at agitest")
 
     # Read result before timeout
     def result_changed(self):
         if self.passed is True:
-            self.read_result()
+            self.stop_reactor()
 
     def run(self):
+        TestCase.run(self)
         self.launch_test()
-        reactor.callLater(self.timeout, self.stop_reactor)
+
 
 def main(argv=None):
     if argv is None:

Modified: asterisk/trunk/tests/fastagi/database/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/database/run-test?view=diff&rev=1520&r1=1519&r2=1520
==============================================================================
--- asterisk/trunk/tests/fastagi/database/run-test (original)
+++ asterisk/trunk/tests/fastagi/database/run-test Thu May 19 11:54:42 2011
@@ -8,40 +8,22 @@
 '''
 
 import sys
-import os
-from optparse import OptionParser
 from twisted.internet import reactor
-from starpy import fastagi
 
 sys.path.append("lib/python")
 from asterisk.asterisk import Asterisk
-from asterisk.version import AsteriskVersion
-
-workingdir = "/tmp/asterisk-testsuite/fastagi/database"
-testdir = "tests/fastagi"
+from asterisk.TestCase import TestCase
 
 
-class FastAGIDatabaseTest:
+class FastAGIDatabaseTest(TestCase):
     def __init__(self, argv):
+        TestCase.__init__(self, argv)
         self.passed = {}
-        self.timeout = 30
         self.key = "fastagitest"
         self.overall_result = True
-        self.agi = ""
 
-        parser = OptionParser()
-        parser.add_option("-v", "--version", dest="ast_version",
-                          help="Asterisk version string")
-        (options, args) = parser.parse_args(argv)
-        self.ast_version = AsteriskVersion(options.ast_version)
-
-        # Listen for results from dialplan
-        self.agi_factory = fastagi.FastAGIFactory(self.do_test)
-        reactor.listenTCP(4573, self.agi_factory, self.timeout, '127.0.0.1')
-        reactor.callWhenRunning(self.run)
-
-        self.ast1 = Asterisk(base=workingdir)
-        self.ast1.install_configs("%s/configs/ast1" % (testdir))
+        self.create_asterisk()
+        self.create_fastagi_factory()
 
     def on_del_failure(self, reason):
         print 'Could not delete the data from the database.'
@@ -158,53 +140,30 @@
     # 4. Test for new value
     # 5. Delete that key from the database
     # 6. Test that key was deleted.
-    def do_test(self, agi):
+    def fastagi_connect(self, agi):
         self.agi = agi
         print "Inserting key into database."
         return agi.databaseSet("secret", self.key, "juststarted").addCallback(
             self.get_result_from_put).addErrback(self.on_put_failure)
 
-	# Read test results and dialplan globals
-    def read_result(self):
-        self.agi.finish()
-        self.stop_reactor()
-
-        for test in self.passed:
-            if self.passed[test] is False:
-                self.overall_result = False
-
-        if self.overall_result is True:
-            print "Success"
-	else:
-            print "Failed"
-
-    def stop_reactor(self):
-        print "Stopping Reactor ..."
-        if reactor.running:
-            reactor.stop()
 
     def launch_test(self):
         print "Originating call to begin test."
-        self.ast1.cli_originate("Local/506 at agitest extension echo at agitest")
-
-    def start_asterisk(self):
-        print "Starting Asterisk"
-        self.ast1.start()
-
-    def stop_asterisk(self):
-        print "Stopping Asterisk"
-        self.ast1.stop()
+        self.ast[0].cli_originate("Local/506 at agitest extension echo at agitest")
 
     # Read result before timeout
     def result_changed(self):
         # if self.passed["Put"] is None, not one test has completed yet
         # and we should wait for the timeout.
         if self.passed["Put"] is not None:
-            self.read_result()
+            self.stop_reactor()
+            for test in self.passed:
+                if self.passed[test] is False:
+                    self.overall_result = False
 
     def run(self):
+        TestCase.run(self)
         self.launch_test()
-        reactor.callLater(self.timeout, self.stop_reactor)
 
 
 def main(argv=None):

Modified: asterisk/trunk/tests/fastagi/execute/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/execute/run-test?view=diff&rev=1520&r1=1519&r2=1520
==============================================================================
--- asterisk/trunk/tests/fastagi/execute/run-test (original)
+++ asterisk/trunk/tests/fastagi/execute/run-test Thu May 19 11:54:42 2011
@@ -36,6 +36,9 @@
         parser = OptionParser()
         parser.add_option("-v", "--version", dest="ast_version",
                           help="Asterisk version string")
+        parser.add_option("-n", dest="test_name",
+                help="Test name")
+
         (options, args) = parser.parse_args(argv)
         self.ast_version = AsteriskVersion(options.ast_version)
 

Modified: asterisk/trunk/tests/fastagi/get-data/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/get-data/run-test?view=diff&rev=1520&r1=1519&r2=1520
==============================================================================
--- asterisk/trunk/tests/fastagi/get-data/run-test (original)
+++ asterisk/trunk/tests/fastagi/get-data/run-test Thu May 19 11:54:42 2011
@@ -28,6 +28,9 @@
         parser = OptionParser()
         parser.add_option("-v", "--version", dest="ast_version",
                           help="Asterisk version string")
+        parser.add_option("-n", dest="test_name",
+                help="Test name")
+
         (options, args) = parser.parse_args(argv)
         self.ast_version = AsteriskVersion(options.ast_version)
 

Modified: asterisk/trunk/tests/fastagi/hangup/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/hangup/run-test?view=diff&rev=1520&r1=1519&r2=1520
==============================================================================
--- asterisk/trunk/tests/fastagi/hangup/run-test (original)
+++ asterisk/trunk/tests/fastagi/hangup/run-test Thu May 19 11:54:42 2011
@@ -30,6 +30,9 @@
         parser = OptionParser()
         parser.add_option("-v", "--version", dest="ast_version",
                           help="Asterisk version string")
+        parser.add_option("-n", dest="test_name",
+                help="Test name")
+
         (options, args) = parser.parse_args(argv)
         self.ast_version = AsteriskVersion(options.ast_version)
 

Modified: asterisk/trunk/tests/fastagi/record-file/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/record-file/run-test?view=diff&rev=1520&r1=1519&r2=1520
==============================================================================
--- asterisk/trunk/tests/fastagi/record-file/run-test (original)
+++ asterisk/trunk/tests/fastagi/record-file/run-test Thu May 19 11:54:42 2011
@@ -36,6 +36,9 @@
         parser = OptionParser()
         parser.add_option("-v", "--version", dest="ast_version",
                           help="Asterisk version string")
+        parser.add_option("-n", dest="test_name",
+                help="Test name")
+
         (options, args) = parser.parse_args(argv)
         self.ast_version = AsteriskVersion(options.ast_version)
 

Modified: asterisk/trunk/tests/fastagi/say-alpha/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/say-alpha/run-test?view=diff&rev=1520&r1=1519&r2=1520
==============================================================================
--- asterisk/trunk/tests/fastagi/say-alpha/run-test (original)
+++ asterisk/trunk/tests/fastagi/say-alpha/run-test Thu May 19 11:54:42 2011
@@ -30,6 +30,9 @@
         parser = OptionParser()
         parser.add_option("-v", "--version", dest="ast_version",
                           help="Asterisk version string")
+        parser.add_option("-n", dest="test_name",
+                help="Test name")
+
         (options, args) = parser.parse_args(argv)
         self.ast_version = AsteriskVersion(options.ast_version)
 

Modified: asterisk/trunk/tests/fastagi/say-date/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/say-date/run-test?view=diff&rev=1520&r1=1519&r2=1520
==============================================================================
--- asterisk/trunk/tests/fastagi/say-date/run-test (original)
+++ asterisk/trunk/tests/fastagi/say-date/run-test Thu May 19 11:54:42 2011
@@ -31,6 +31,9 @@
         parser = OptionParser()
         parser.add_option("-v", "--version", dest="ast_version",
                           help="Asterisk version string")
+        parser.add_option("-n", dest="test_name",
+                help="Test name")
+
         (options, args) = parser.parse_args(argv)
         self.ast_version = AsteriskVersion(options.ast_version)
 

Modified: asterisk/trunk/tests/fastagi/say-datetime/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/say-datetime/run-test?view=diff&rev=1520&r1=1519&r2=1520
==============================================================================
--- asterisk/trunk/tests/fastagi/say-datetime/run-test (original)
+++ asterisk/trunk/tests/fastagi/say-datetime/run-test Thu May 19 11:54:42 2011
@@ -29,6 +29,9 @@
         parser = OptionParser()
         parser.add_option("-v", "--version", dest="ast_version",
                           help="Asterisk version string")
+        parser.add_option("-n", dest="test_name",
+                help="Test name")
+
         (options, args) = parser.parse_args(argv)
         self.ast_version = AsteriskVersion(options.ast_version)
 

Modified: asterisk/trunk/tests/fastagi/say-digits/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/say-digits/run-test?view=diff&rev=1520&r1=1519&r2=1520
==============================================================================
--- asterisk/trunk/tests/fastagi/say-digits/run-test (original)
+++ asterisk/trunk/tests/fastagi/say-digits/run-test Thu May 19 11:54:42 2011
@@ -30,6 +30,9 @@
         parser = OptionParser()
         parser.add_option("-v", "--version", dest="ast_version",
                           help="Asterisk version string")
+        parser.add_option("-n", dest="test_name",
+                help="Test name")
+
         (options, args) = parser.parse_args(argv)
         self.ast_version = AsteriskVersion(options.ast_version)
 

Modified: asterisk/trunk/tests/fastagi/say-number/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/say-number/run-test?view=diff&rev=1520&r1=1519&r2=1520
==============================================================================
--- asterisk/trunk/tests/fastagi/say-number/run-test (original)
+++ asterisk/trunk/tests/fastagi/say-number/run-test Thu May 19 11:54:42 2011
@@ -30,6 +30,9 @@
         parser = OptionParser()
         parser.add_option("-v", "--version", dest="ast_version",
                           help="Asterisk version string")
+        parser.add_option("-n", dest="test_name",
+                help="Test name")
+
         (options, args) = parser.parse_args(argv)
         self.ast_version = AsteriskVersion(options.ast_version)
 

Modified: asterisk/trunk/tests/fastagi/say-phonetic/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/say-phonetic/run-test?view=diff&rev=1520&r1=1519&r2=1520
==============================================================================
--- asterisk/trunk/tests/fastagi/say-phonetic/run-test (original)
+++ asterisk/trunk/tests/fastagi/say-phonetic/run-test Thu May 19 11:54:42 2011
@@ -30,6 +30,9 @@
         parser = OptionParser()
         parser.add_option("-v", "--version", dest="ast_version",
                           help="Asterisk version string")
+        parser.add_option("-n", dest="test_name",
+                help="Test name")
+
         (options, args) = parser.parse_args(argv)
         self.ast_version = AsteriskVersion(options.ast_version)
 

Modified: asterisk/trunk/tests/fastagi/say-time/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/say-time/run-test?view=diff&rev=1520&r1=1519&r2=1520
==============================================================================
--- asterisk/trunk/tests/fastagi/say-time/run-test (original)
+++ asterisk/trunk/tests/fastagi/say-time/run-test Thu May 19 11:54:42 2011
@@ -31,6 +31,9 @@
         parser = OptionParser()
         parser.add_option("-v", "--version", dest="ast_version",
                           help="Asterisk version string")
+        parser.add_option("-n", dest="test_name",
+                help="Test name")
+
         (options, args) = parser.parse_args(argv)
         self.ast_version = AsteriskVersion(options.ast_version)
 

Modified: asterisk/trunk/tests/fastagi/stream-file/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/stream-file/run-test?view=diff&rev=1520&r1=1519&r2=1520
==============================================================================
--- asterisk/trunk/tests/fastagi/stream-file/run-test (original)
+++ asterisk/trunk/tests/fastagi/stream-file/run-test Thu May 19 11:54:42 2011
@@ -29,6 +29,9 @@
         parser = OptionParser()
         parser.add_option("-v", "--version", dest="ast_version",
                           help="Asterisk version string")
+        parser.add_option("-n", dest="test_name",
+                help="Test name")
+
         (options, args) = parser.parse_args(argv)
         self.ast_version = AsteriskVersion(options.ast_version)
 

Modified: asterisk/trunk/tests/fastagi/wait-for-digit/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/wait-for-digit/run-test?view=diff&rev=1520&r1=1519&r2=1520
==============================================================================
--- asterisk/trunk/tests/fastagi/wait-for-digit/run-test (original)
+++ asterisk/trunk/tests/fastagi/wait-for-digit/run-test Thu May 19 11:54:42 2011
@@ -29,6 +29,9 @@
         parser = OptionParser()
         parser.add_option("-v", "--version", dest="ast_version",
                           help="Asterisk version string")
+        parser.add_option("-n", dest="test_name",
+                help="Test name")
+
         (options, args) = parser.parse_args(argv)
         self.ast_version = AsteriskVersion(options.ast_version)
 

Modified: asterisk/trunk/tests/feature_attended_transfer/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/feature_attended_transfer/run-test?view=diff&rev=1520&r1=1519&r2=1520
==============================================================================
--- asterisk/trunk/tests/feature_attended_transfer/run-test (original)
+++ asterisk/trunk/tests/feature_attended_transfer/run-test Thu May 19 11:54:42 2011
@@ -37,6 +37,9 @@
         parser = OptionParser()
         parser.add_option("-v", "--version", dest="ast_version",
                           help="Asterisk version string")
+        parser.add_option("-n", dest="test_name",
+                help="Test name")
+
         (options, args) = parser.parse_args(argv)
         self.ast_version = AsteriskVersion(options.ast_version)
 

Modified: asterisk/trunk/tests/feature_blonde_transfer/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/feature_blonde_transfer/run-test?view=diff&rev=1520&r1=1519&r2=1520
==============================================================================
--- asterisk/trunk/tests/feature_blonde_transfer/run-test (original)
+++ asterisk/trunk/tests/feature_blonde_transfer/run-test Thu May 19 11:54:42 2011
@@ -36,6 +36,9 @@
         parser = OptionParser()
         parser.add_option("-v", "--version", dest="ast_version",
                           help="Asterisk version string")
+        parser.add_option("-n", dest="test_name",
+                help="Test name")
+
         (options, args) = parser.parse_args(argv)
         self.ast_version = AsteriskVersion(options.ast_version)
 

Modified: asterisk/trunk/tests/manager/login/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/manager/login/run-test?view=diff&rev=1520&r1=1519&r2=1520
==============================================================================
--- asterisk/trunk/tests/manager/login/run-test (original)

[... 297 lines stripped ...]



More information about the asterisk-commits mailing list