[asterisk-commits] pabelanger: branch pabelanger/testClass r1511 - in /asterisk/team/pabelanger/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue May 17 18:23:05 CDT 2011


Author: pabelanger
Date: Tue May 17 18:23:01 2011
New Revision: 1511

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=1511
Log:
Convert another test

Added:
    asterisk/team/pabelanger/testClass/tests/fastagi/channel-status/configs/
      - copied from r1509, asterisk/team/pabelanger/testClass/tests/fastagi/connect/configs/
    asterisk/team/pabelanger/testClass/tests/fastagi/channel-status/configs/ast1/manager.general.conf.inc
      - copied unchanged from r1510, asterisk/team/pabelanger/testClass/tests/fastagi/connect/configs/ast1/manager.general.conf.inc
Removed:
    asterisk/team/pabelanger/testClass/tests/fastagi/channel-status/configs/ast1/manager.conf
    asterisk/team/pabelanger/testClass/tests/fastagi/configs/
Modified:
    asterisk/team/pabelanger/testClass/tests/fastagi/channel-status/run-test

Modified: asterisk/team/pabelanger/testClass/tests/fastagi/channel-status/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/testClass/tests/fastagi/channel-status/run-test?view=diff&rev=1511&r1=1510&r2=1511
==============================================================================
--- asterisk/team/pabelanger/testClass/tests/fastagi/channel-status/run-test (original)
+++ asterisk/team/pabelanger/testClass/tests/fastagi/channel-status/run-test Tue May 17 18:23:01 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:




More information about the asterisk-commits mailing list