[svn-commits] espiceland: testsuite/asterisk/trunk r872 - in /asterisk/trunk/tests: ./ fast...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Nov 19 13:47:26 CST 2010


Author: espiceland
Date: Fri Nov 19 13:47:22 2010
New Revision: 872

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=872
Log:
Add new test for AGI command WAIT FOR DIGIT, but it is disabled until the
new functionality can be added to StarPy.

Added:
    asterisk/trunk/tests/fastagi/wait-for-digit/
    asterisk/trunk/tests/fastagi/wait-for-digit/run-test   (with props)
    asterisk/trunk/tests/fastagi/wait-for-digit/test-config.yaml   (with props)
Modified:
    asterisk/trunk/tests/tests.yaml

Added: 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=auto&rev=872
==============================================================================
--- asterisk/trunk/tests/fastagi/wait-for-digit/run-test (added)
+++ asterisk/trunk/tests/fastagi/wait-for-digit/run-test Fri Nov 19 13:47:22 2010
@@ -1,0 +1,126 @@
+#!/usr/bin/env python
+'''
+Copyright (C) 2010, Digium, Inc.
+Erin Spiceland <espiceland at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+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
+
+class FastAGIWaitForDigitTest:
+    def __init__(self, argv):
+        self.passed = False
+        self.timeout = 45
+
+        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)
+
+        print self.ast_version
+        self.asterisk = Asterisk(base="/tmp/asterisk-testsuite/fastagi/wait-for-digit")
+        self.asterisk.install_configs("tests/fastagi/configs")
+
+    def on_failure(self, reason):
+        print 'Could not run WAIT FOR DIGIT: ', reason.getTraceback()
+        self.agi.finish()
+
+    # result is (str digits, bool timeout)
+    def finish_test(self, result):
+        self.passed = True
+        if result == 3212:
+            print "Got the input we expected."
+        else:
+            print "Got '%s' which wasn't what we expected." % result
+            self.passed = False
+
+        self.result_changed()
+
+    # This gets invoked by the dialplan when the call is answered
+    # send WAIT FOR DIGIT command and wait for results
+    def do_test(self, agi):
+        self.agi = agi
+        print "Connection established."
+        return agi.waitForDigit(60, 'silence/10', '1234567890*#ABCD', 4, '#').addCallback(
+            self.finish_test
+        ).addErrback(self.on_failure)
+
+	# Read test results and dialplan globals
+    def read_result(self):
+
+        if self.passed is True:
+            print "PASS - FastAGI WAIT FOR DIGIT works as expected."
+        else:
+            self.asterisk.cli_exec("core show channels")
+
+            if self.ast_version < AsteriskVersion("1.6.1"):
+                self.asterisk.cli_exec("core show globals")
+            else:
+                self.asterisk.cli_exec("dialplan show globals")
+
+            print "FAIL - FastAGI WAIT FOR DIGIT test failed. View result",\
+                    "of 'core show globals' in log for more detailed",\
+                    "failure results."
+
+        self.stop_asterisk()
+
+        if reactor.running:
+            print "Stopping Reactor ..."
+            reactor.stop()
+
+    def launch_test(self):
+        self.asterisk.cli_exec("core set verbose 10")
+        self.asterisk.cli_exec("agi set debug on")
+
+        print "Originating call to begin test."
+        self.asterisk.cli_originate(
+            "Local/basic_agi at agitest extension play_dtmf at agitest"
+        )
+
+    def start_asterisk(self):
+        print "Starting Asterisk"
+        self.asterisk.start()
+
+    def stop_asterisk(self):
+        print "Stopping Asterisk"
+        self.asterisk.stop()
+
+    # Read result before timeout
+    def result_changed(self):
+        if self.passed is True:
+            reactor.callLater(2, self.read_result)
+
+    def run(self):
+        self.start_asterisk()
+        reactor.callLater(2, self.launch_test)
+        reactor.callLater(self.timeout, self.read_result)
+
+def main(argv=None):
+    if argv is None:
+        argv = sys.argv
+
+    agi_test = FastAGIWaitForDigitTest(argv)
+    reactor.run()
+    if agi_test.passed is not True:
+        return 1
+
+    return 0
+
+if __name__ == "__main__":
+    sys.exit(main() or 0)

Propchange: asterisk/trunk/tests/fastagi/wait-for-digit/run-test
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/fastagi/wait-for-digit/run-test
------------------------------------------------------------------------------
    svn:executable = *

Propchange: asterisk/trunk/tests/fastagi/wait-for-digit/run-test
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/fastagi/wait-for-digit/run-test
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/fastagi/wait-for-digit/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/wait-for-digit/test-config.yaml?view=auto&rev=872
==============================================================================
--- asterisk/trunk/tests/fastagi/wait-for-digit/test-config.yaml (added)
+++ asterisk/trunk/tests/fastagi/wait-for-digit/test-config.yaml Fri Nov 19 13:47:22 2010
@@ -1,0 +1,11 @@
+testinfo:
+    summary:     'Test AGI WAIT FOR DIGIT command using FastAGI.'
+    description: |
+        'Test AGI WAIT FOR DIGIT command using FastAGI.'
+
+properties:
+    minversion: '1.4'
+    dependencies:
+        - app : 'python'
+        - python : 'twisted'
+        - python : 'starpy'

Propchange: asterisk/trunk/tests/fastagi/wait-for-digit/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/fastagi/wait-for-digit/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/fastagi/wait-for-digit/test-config.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: asterisk/trunk/tests/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/tests.yaml?view=diff&rev=872&r1=871&r2=872
==============================================================================
--- asterisk/trunk/tests/tests.yaml (original)
+++ asterisk/trunk/tests/tests.yaml Fri Nov 19 13:47:22 2010
@@ -67,6 +67,8 @@
     - test: 'fastagi/say-digits'
     - test: 'fastagi/say-number'
     - test: 'fastagi/say-phonetic'
+    # Requires patch to StarPy.
+    #- test: 'fastagi/wait-for-digit'
     - test: 'pbx/call-files'
     - test: 'pbx/call-files2'
     - test: 'fax/local_channel_t38_queryoption'




More information about the svn-commits mailing list