[asterisk-commits] mjordan: testsuite/asterisk/trunk r3712 - /asterisk/trunk/tests/channels/SIP/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Apr 16 09:39:12 CDT 2013


Author: mjordan
Date: Tue Apr 16 09:39:09 2013
New Revision: 3712

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=3712
Log:
Update test to use DTMFEnd event where appropriate

And a bit of general cleanup as well.

Modified:
    asterisk/trunk/tests/channels/SIP/sip_tls_call/run-test

Modified: asterisk/trunk/tests/channels/SIP/sip_tls_call/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/SIP/sip_tls_call/run-test?view=diff&rev=3712&r1=3711&r2=3712
==============================================================================
--- asterisk/trunk/tests/channels/SIP/sip_tls_call/run-test (original)
+++ asterisk/trunk/tests/channels/SIP/sip_tls_call/run-test Tue Apr 16 09:39:09 2013
@@ -1,4 +1,11 @@
 #!/usr/bin/env python
+'''
+Copyright (C) 2011, Digium, Inc.
+Jonathan Rose <jrose at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
 
 import fileinput
 import sys
@@ -13,6 +20,8 @@
 from asterisk.TestCase import TestCase
 from asterisk.cdr import AsteriskCSVCDR, AsteriskCSVCDRLine
 from starpy import manager
+
+LOGGER = logging.getLogger(__name__)
 
 # Quick little function for doing search and replace in a file used below.
 def file_replace_string(file, search, replace):
@@ -36,7 +45,7 @@
         testdir = "tests/%s" % workingdir
 
         # Additional setup for config files and keys
-        print "Building test resources ..."
+        LOGGER.info("Building test resources ...")
         if os.path.exists('%s/configs/ast1/sip_helper.inc' % (testdir)):
             os.remove('%s/configs/ast1/sip_helper.inc' % (testdir))
         shutil.copy('%s/configs/helper1' % (testdir), '%s/configs/ast1/sip_helper.inc' % (testdir))
@@ -47,7 +56,6 @@
         file_replace_string('%s/configs/ast1/sip_helper.inc' % (testdir), '<<path>>', '%s' % (workingdir))
         file_replace_string('%s/configs/ast2/sip_helper.inc' % (testdir), '<<path>>', '%s' % (workingdir))
 
-        print "Creating Asterisk instances ..."
         self.create_asterisk(2)
 
         #Now that we've created the Asterisk instances, let's go ahead and remove the sip_helper.inc files
@@ -69,48 +77,43 @@
         shutil.copytree('%s/configs/keys' % (testdir), '%s/keys' % (workingdir))
         # End of additional setup for config files and keys
 
-    # Once the AMI Factory connects to the AMI, this function fires.
     def ami_connect(self, ami):
-        print "AMI %d - connected, registering DTMF event..." % (ami.id + 1)
-
-        # This will make the manager listen for DTMF and callback ami_test when it sees some.
-        ami.registerEvent('DTMF', self.ami_test)
+        if (AsteriskVersion() > AsteriskVersion('11')):
+            ami.registerEvent('DTMFEnd', self.ami_test)
+        else:
+            ami.registerEvent('DTMF', self.ami_test)
 
         # We only want to originate the call on the ast[0]'s manager.
         if ami.id == 0:
-            print "AMI - originating call from SIP/testast1 to extension 1000 using extension 1000 at priority 1"
-            ami.originate(channel = "SIP/testast1/1000", context = "default", exten = "1000", priority = "1")
+            LOGGER.info("Originating from SIP/testast1/1000 to 1000 at default")
+            ami.originate(channel="SIP/testast1/1000",
+                          context="default",
+                          exten="1000",
+                          priority="1").addErrback(self.handleOriginateFailure)
 
-    # This test is initiated whenever a DTMF event occurs.
     def ami_test(self, ami, event):
-
-        print "Received DTMF event from AMI %d..." % (ami.id + 1)
-        print "Value of DTMF[digit] = %s" % (event['digit'])
+        LOGGER.debug("Received DTMF event from AMI %d..." % (ami.id + 1))
+        LOGGER.debug("Value of DTMF[digit] = %s" % (event['digit']))
         if event['digit'] == "5" and ami.id == 0:
             self.tone1 = True
-            print "It's a match for ast[0] receiving DTMF from ast[1]"
+            LOGGER.debug("It's a match for ast[0] receiving DTMF from ast[1]")
         elif event['digit'] == "6" and ami.id == 1:
             self.tone2 = True
-            print "It's a match for ast[1] receiving DTMF from ast[0]"
+            LOGGER.debug("It's a match for ast[1] receiving DTMF from ast[0]")
 
         if self.tone1 and self.tone2:
-            print "Both tones have been matched at least once.  Test PASSED."
+            LOGGER.info("Both tones have matched at least once. Test PASSED.")
             self.passed = True
             self.stop_reactor()
 
-    # Sets up reactor and AMI connection
     def run(self):
         TestCase.run(self)
-        # will link up to ami_connect() once the connection is established
         self.create_ami_factory(count = 2)
 
 
 def main():
     test = SIPTLSCallTest()
-    test.start_asterisk()
     reactor.run()
-
-    test.stop_asterisk()
 
     if test.passed:
         return 0




More information about the asterisk-commits mailing list