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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Aug 18 11:04:34 CDT 2010


Author: espiceland
Date: Wed Aug 18 11:04:30 2010
New Revision: 755

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=755
Log:
Adding 7 new tests for SAY XXX; renamed extensions more appropriately; small
amount of code cleanup.

Added:
    asterisk/trunk/tests/fastagi/say-alpha/
    asterisk/trunk/tests/fastagi/say-alpha/run-test   (with props)
    asterisk/trunk/tests/fastagi/say-alpha/test-config.yaml   (with props)
    asterisk/trunk/tests/fastagi/say-date/
    asterisk/trunk/tests/fastagi/say-date/run-test   (with props)
    asterisk/trunk/tests/fastagi/say-date/test-config.yaml   (with props)
    asterisk/trunk/tests/fastagi/say-datetime/
    asterisk/trunk/tests/fastagi/say-datetime/run-test   (with props)
    asterisk/trunk/tests/fastagi/say-datetime/test-config.yaml   (with props)
    asterisk/trunk/tests/fastagi/say-digits/
    asterisk/trunk/tests/fastagi/say-digits/run-test   (with props)
    asterisk/trunk/tests/fastagi/say-digits/test-config.yaml   (with props)
    asterisk/trunk/tests/fastagi/say-number/
    asterisk/trunk/tests/fastagi/say-number/run-test   (with props)
    asterisk/trunk/tests/fastagi/say-number/test-config.yaml   (with props)
    asterisk/trunk/tests/fastagi/say-phonetic/
    asterisk/trunk/tests/fastagi/say-phonetic/run-test   (with props)
    asterisk/trunk/tests/fastagi/say-phonetic/test-config.yaml   (with props)
    asterisk/trunk/tests/fastagi/say-time/
    asterisk/trunk/tests/fastagi/say-time/run-test   (with props)
    asterisk/trunk/tests/fastagi/say-time/test-config.yaml   (with props)
Modified:
    asterisk/trunk/tests/fastagi/channel-status/run-test
    asterisk/trunk/tests/fastagi/configs/extensions.conf
    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/stream-file/run-test
    asterisk/trunk/tests/tests.yaml

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=755&r1=754&r2=755
==============================================================================
--- asterisk/trunk/tests/fastagi/channel-status/run-test (original)
+++ asterisk/trunk/tests/fastagi/channel-status/run-test Wed Aug 18 11:04:30 2010
@@ -110,7 +110,7 @@
         # status before call is answered.
         print "Originating call to begin test."
         self.asterisk.cli_originate(
-            "Local/c_exten at agitest extension echo at agitest", blocking=False
+            "Local/no_answer at agitest extension echo at agitest", blocking=False
         )
 
 

Modified: asterisk/trunk/tests/fastagi/configs/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/configs/extensions.conf?view=diff&rev=755&r1=754&r2=755
==============================================================================
--- asterisk/trunk/tests/fastagi/configs/extensions.conf (original)
+++ asterisk/trunk/tests/fastagi/configs/extensions.conf Wed Aug 18 11:04:30 2010
@@ -7,39 +7,59 @@
 exten => echo,1,Answer()
 exten => echo,n,Echo()
 
-; Used in connect, hangup, control-stream-file, stream-file, database, execute, get-data, record-file
-exten => b_exten,1,Answer()
-exten => b_exten,n,Set(GLOBAL(DEBUG)=FAIL - before agi)
-exten => b_exten,n,AGI(agi://127.0.0.1:4573)
-exten => b_exten,n,Set(GLOBAL(DEBUG)=${AGISTATUS})
-exten => b_exten,n,HangUp()
+; Used in connect, hangup, control-stream-file, stream-file, database,
+; execute, get-data, record-file, say-alpha, say-date, say-datetime,
+; say-time, say-digits, say-number, say-phonetic
+exten => basic_agi,1,Answer()
+exten => basic_agi,n,Set(GLOBAL(DEBUG)=FAIL - before agi)
+exten => basic_agi,n,AGI(agi://127.0.0.1:4573)
+exten => basic_agi,n,Set(GLOBAL(DEBUG)=${AGISTATUS})
+exten => basic_agi,n,HangUp()
 
 ; Used in channel-status
-exten => c_exten,1,Set(GLOBAL(DEBUG)=FAIL - before agi)
-exten => c_exten,n,AGI(agi://127.0.0.1:4573)
-exten => c_exten,n,Set(GLOBAL(DEBUG)=${AGISTATUS})
-exten => c_exten,n,HangUp()
+exten => no_answer,1,Set(GLOBAL(DEBUG)=FAIL - before agi)
+exten => no_answer,n,AGI(agi://127.0.0.1:4573)
+exten => no_answer,n,Set(GLOBAL(DEBUG)=${AGISTATUS})
+exten => no_answer,n,HangUp()
 
 ; Used in get-data
-exten => d_exten,1,Answer()
-exten => d_exten,n,Set(GLOBAL(DEBUG)=FAIL - d_exten answered)
-exten => d_exten,n,SendDTMF(w3w2w1w2w3w3w3w#)
-exten => d_exten,n,Set(GLOBAL(DEBUG)=FAIL - d_exten sent DTMF)
-exten => d_exten,n,HangUp()
+exten => play_dtmf,1,Answer()
+exten => play_dtmf,n,Set(GLOBAL(DEBUG)=FAIL - play_dtmf answered)
+exten => play_dtmf,n,SendDTMF(w3w2w1w2w3w3w3w#)
+exten => play_dtmf,n,Set(GLOBAL(DEBUG)=FAIL - play_dtmf sent DTMF)
+exten => play_dtmf,n,HangUp()
 
 ; Used in record-file
-exten => e_exten,1,Answer()
-exten => e_exten,n,Set(GLOBAL(DEBUG)=FAIL - e_exten answered)
-exten => e_exten,n,Wait(1)
-exten => e_exten,n,Playback(beep)
-exten => e_exten,n,SendDTMF(#)
-exten => e_exten,n,Set(GLOBAL(DEBUG)=FAIL - e_exten sent sounds and exit digit)
-exten => e_exten,n,HangUp()
+exten => play_snd_and_term,1,Answer()
+exten => play_snd_and_term,n,Set(GLOBAL(DEBUG)=FAIL - play_snd_and_term answered)
+exten => play_snd_and_term,n,Wait(1)
+exten => play_snd_and_term,n,Playback(beep)
+exten => play_snd_and_term,n,SendDTMF(#)
+exten => play_snd_and_term,n,Set(GLOBAL(DEBUG)=FAIL - play_snd_and_term sent sounds and exit digit)
+exten => play_snd_and_term,n,HangUp()
 
 ; Used in record-file
-exten => f_exten,1,Answer()
-exten => f_exten,n,Set(GLOBAL(DEBUG)=FAIL - f_exten answered)
-exten => f_exten,n,Wait(1)
-exten => f_exten,n,Playback(beep)
-exten => f_exten,n,Set(GLOBAL(DEBUG)=FAIL - f_exten sent sounds)
-exten => f_exten,n,HangUp()
+exten => play_snd_and_hangup,1,Answer()
+exten => play_snd_and_hangup,n,Set(GLOBAL(DEBUG)=FAIL - play_snd_and_hangup answered)
+exten => play_snd_and_hangup,n,Wait(1)
+exten => play_snd_and_hangup,n,Playback(beep)
+exten => play_snd_and_hangup,n,Set(GLOBAL(DEBUG)=FAIL - play_snd_and_hangup sent sounds)
+exten => play_snd_and_hangup,n,HangUp()
+
+; Used in say-alpha, say-date, say-datetime, say-time, say-digits, say-number, say-phonetic
+; listen for the AGI script to talk
+; check to see if we detected any talking
+; notify AGI script over a second port if talkdetect succeeds.
+exten => td_and_agi_notify,1,Answer()
+exten => td_and_agi_notify,n,Set(GLOBAL(DEBUG)=FAIL - td_and_agi_notify answered)
+exten => td_and_agi_notify,n,Set(TALK_DETECTED=0)
+exten => td_and_agi_notify,n,BackgroundDetect(silence/10,1,5000,20000)
+;exten => td_and_agi_notify,n,Wait(15)
+exten => td_and_agi_notify,n,Set(GLOBAL(DEBUG)=FAIL - td_and_agi_notify listening for sounds)
+exten => td_and_agi_notify,n,GoToIf($[${TALK_DETECTED}=0]?fail:pass)
+exten => td_and_agi_notify,n(fail),Set(GLOBAL(DEBUG)=FAIL - talk detect failed with result ${TALK_DETECTED})
+exten => td_and_agi_notify,n,HangUp()
+exten => td_and_agi_notify,n(pass),Set(GLOBAL(DEBUG)=PASS)
+exten => td_and_agi_notify,n,AGI(agi://127.0.0.1:4574)
+exten => td_and_agi_notify,n,HangUp()
+

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=755&r1=754&r2=755
==============================================================================
--- asterisk/trunk/tests/fastagi/connect/run-test (original)
+++ asterisk/trunk/tests/fastagi/connect/run-test Wed Aug 18 11:04:30 2010
@@ -37,26 +37,13 @@
         self.asterisk = Asterisk(base="/tmp/asterisk-testsuite/fastagi/connect")
         self.asterisk.install_configs("tests/fastagi/configs")
 
-    def on_failure(self, reason):
-        print 'Could not run sequence to close connection.'
-        print reason.getTraceback()
-
-    def get_deferred(self, agi):
-        sequence = fastagi.InSequence()
-        sequence.append(agi.finish)
-        return sequence()
-
-    def finish_test(self, agi):
-        self.passed = True
-        self.result_changed()
-
     # This gets invoked by the dialplan when the call is answered
     # Disconnect agi and set test result values
     def do_test(self, agi):
         print "Connection established."
-        return self.get_deferred(agi).addCallback(
-            self.finish_test
-        ).addErrback(self.on_failure)
+        self.passed = True
+        self.result_changed()
+        return agi.finish()
 
 	# Read test results and dialplan globals
     def read_result(self):
@@ -70,7 +57,8 @@
                 self.asterisk.cli_exec("core show globals")
             else:
                 self.asterisk.cli_exec("dialplan show globals")
-                print "FAIL - FastAGI Connection test failed. View result of\
+
+            print "FAIL - FastAGI Connection test failed. View result of\
                     'core show globals' in log for more detailed failure\
                     results."
 
@@ -85,7 +73,7 @@
 
         print "Originating call to begin test."
         self.asterisk.cli_originate(
-            "Local/b_exten at agitest extension echo at agitest"
+            "Local/basic_agi at agitest extension echo at agitest"
         )
 
     def start_asterisk(self):

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=755&r1=754&r2=755
==============================================================================
--- asterisk/trunk/tests/fastagi/control-stream-file/run-test (original)
+++ asterisk/trunk/tests/fastagi/control-stream-file/run-test Wed Aug 18 11:04:30 2010
@@ -86,7 +86,7 @@
 
         print "Originating call to begin test."
         self.asterisk.cli_originate(
-            "Local/b_exten at agitest extension echo at agitest"
+            "Local/basic_agi at agitest extension echo at agitest"
         )
 
     def start_asterisk(self):

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=755&r1=754&r2=755
==============================================================================
--- asterisk/trunk/tests/fastagi/database/run-test (original)
+++ asterisk/trunk/tests/fastagi/database/run-test Wed Aug 18 11:04:30 2010
@@ -189,7 +189,7 @@
 
         print "Originating call to begin test."
         self.asterisk.cli_originate(
-            "Local/b_exten at agitest extension echo at agitest"
+            "Local/basic_agi at agitest extension echo at agitest"
         )
 
     def start_asterisk(self):

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=755&r1=754&r2=755
==============================================================================
--- asterisk/trunk/tests/fastagi/execute/run-test (original)
+++ asterisk/trunk/tests/fastagi/execute/run-test Wed Aug 18 11:04:30 2010
@@ -174,7 +174,7 @@
         self.asterisk.cli_exec("agi set debug on")
         print "Originating call to begin test."
         self.asterisk.cli_originate(
-            "Local/b_exten at agitest extension echo at agitest"
+            "Local/basic_agi at agitest extension echo at agitest"
         )
 
     def start_asterisk(self):

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=755&r1=754&r2=755
==============================================================================
--- asterisk/trunk/tests/fastagi/get-data/run-test (original)
+++ asterisk/trunk/tests/fastagi/get-data/run-test Wed Aug 18 11:04:30 2010
@@ -77,7 +77,8 @@
                 self.asterisk.cli_exec("core show globals")
             else:
                 self.asterisk.cli_exec("dialplan show globals")
-                print "FAIL - FastAGI GET DATA test failed. View result",\
+
+            print "FAIL - FastAGI GET DATA test failed. View result",\
                     "of 'core show globals' in log for more detailed",\
                     "failure results."
 
@@ -93,7 +94,7 @@
 
         print "Originating call to begin test."
         self.asterisk.cli_originate(
-            "Local/b_exten at agitest extension d_exten at agitest"
+            "Local/basic_agi at agitest extension play_dtmf at agitest"
         )
 
     def start_asterisk(self):

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=755&r1=754&r2=755
==============================================================================
--- asterisk/trunk/tests/fastagi/hangup/run-test (original)
+++ asterisk/trunk/tests/fastagi/hangup/run-test Wed Aug 18 11:04:30 2010
@@ -113,7 +113,7 @@
 
         print "Originating call to begin test."
         self.asterisk.cli_originate(
-            "Local/b_exten at agitest extension echo at agitest"
+            "Local/basic_agi at agitest extension echo at agitest"
         )
 
     def start_asterisk(self):

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=755&r1=754&r2=755
==============================================================================
--- asterisk/trunk/tests/fastagi/record-file/run-test (original)
+++ asterisk/trunk/tests/fastagi/record-file/run-test Wed Aug 18 11:04:30 2010
@@ -110,6 +110,18 @@
                     "terminated with", t
                 self.overall_result = False
 
+        if self.overall_result is False:
+            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 RECORD FILE test failed. View result",\
+                    "of 'core show globals' in log for more detailed",\
+                    "failure results."
+
         self.stop_asterisk()
         if reactor.running:
             print "Stopping Reactor ..."
@@ -122,11 +134,11 @@
             "with", self.test
         if self.test is "DTMF":
             self.asterisk.cli_originate(
-                "Local/b_exten at agitest extension e_exten at agitest"
+                "Local/basic_agi at agitest extension play_snd_and_term at agitest"
             )
         elif self.test is "HANGUP":
             self.asterisk.cli_originate(
-                "Local/b_exten at agitest extension f_exten at agitest"
+                "Local/basic_agi at agitest extension play_snd_and_hangup at agitest"
             )
         else:
             self.result_changed()

Added: asterisk/trunk/tests/fastagi/say-alpha/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/say-alpha/run-test?view=auto&rev=755
==============================================================================
--- asterisk/trunk/tests/fastagi/say-alpha/run-test (added)
+++ asterisk/trunk/tests/fastagi/say-alpha/run-test Wed Aug 18 11:04:30 2010
@@ -1,0 +1,131 @@
+#!/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 FastAGISayAlphaTest:
+    def __init__(self, argv):
+        self.passed = False
+        self.notified = 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')
+
+        # Listen for success or failure of talkdetect
+        self.agi_factory2 = fastagi.FastAGIFactory(self.listen_result)
+        reactor.listenTCP(4574, self.agi_factory2, self.timeout, '127.0.0.1')
+        reactor.callWhenRunning(self.run)
+
+        print self.ast_version
+        self.asterisk = Asterisk(base="/tmp/asterisk-testsuite/fastagi/say-alpha")
+        self.asterisk.install_configs("tests/fastagi/configs")
+
+    def listen_result(self, agi):
+        print "Got test success confirmation from dialplan."
+        self.notified = True
+        agi.finish()
+        self.result_changed()
+
+    def on_failure(self, reason):
+        print 'SAY ALPHA failed: ', reason.getTraceback()
+        self.passed = False
+
+    def finish_test(self, result):
+        print "AGI command reports success."
+        self.passed = True
+
+    # This gets invoked by the dialplan when the call is answered
+    # send SAY ALPHA command and wait for results
+    def do_test(self, agi):
+        self.agi = agi
+        print "Connection established."
+        return agi.sayAlpha("respect").addCallback(
+            self.finish_test
+        ).addErrback(self.on_failure)
+
+	# Read test results and dialplan globals
+    def read_result(self):
+        self.agi.finish()
+        if self.passed is True and self.notified is True:
+            print "PASS - FastAGI SAY ALPHA 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 "AGI reports success: ", self.passed
+                print "Diaplan reports success: ", self.notified
+                print "FAIL - FastAGI SAY ALPHA 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 td_and_agi_notify 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 = FastAGISayAlphaTest(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/say-alpha/run-test
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/fastagi/say-alpha/run-test
------------------------------------------------------------------------------
    svn:executable = *

Propchange: asterisk/trunk/tests/fastagi/say-alpha/run-test
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/fastagi/say-alpha/run-test
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/fastagi/say-alpha/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/say-alpha/test-config.yaml?view=auto&rev=755
==============================================================================
--- asterisk/trunk/tests/fastagi/say-alpha/test-config.yaml (added)
+++ asterisk/trunk/tests/fastagi/say-alpha/test-config.yaml Wed Aug 18 11:04:30 2010
@@ -1,0 +1,11 @@
+testinfo:
+    summary:     'Test AGI SAY ALPHA command using FastAGI.'
+    description: |
+        'Test AGI SAY ALPHA command using FastAGI.'
+
+properties:
+    minversion: '1.4'
+    dependencies:
+        - app : 'python'
+        - python : 'twisted'
+        - python : 'starpy'

Propchange: asterisk/trunk/tests/fastagi/say-alpha/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/fastagi/say-alpha/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/fastagi/say-alpha/test-config.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/fastagi/say-date/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/say-date/run-test?view=auto&rev=755
==============================================================================
--- asterisk/trunk/tests/fastagi/say-date/run-test (added)
+++ asterisk/trunk/tests/fastagi/say-date/run-test Wed Aug 18 11:04:30 2010
@@ -1,0 +1,132 @@
+#!/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 FastAGISayDateTest:
+    def __init__(self, argv):
+        self.passed = False
+        self.notified = False
+        self.test = "COMPLETE"
+        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')
+
+        # Listen for success or failure of talkdetect
+        self.agi_factory2 = fastagi.FastAGIFactory(self.listen_result)
+        reactor.listenTCP(4574, self.agi_factory2, self.timeout, '127.0.0.1')
+        reactor.callWhenRunning(self.run)
+
+        print self.ast_version
+        self.asterisk = Asterisk(base="/tmp/asterisk-testsuite/fastagi/say-date")
+        self.asterisk.install_configs("tests/fastagi/configs")
+
+    def listen_result(self, agi):
+        print "Got test success confirmation from dialplan."
+        self.notified = True
+        agi.finish()
+        self.result_changed()
+
+    def on_failure(self, reason):
+        print 'SAY DATE failed: ', reason.getTraceback()
+        self.passed = False
+
+    def finish_test(self, result):
+        print "AGI command reports success."
+        self.passed = True
+
+    # This gets invoked by the dialplan when the call is answered
+    # send SAY DATE command and wait for results
+    def do_test(self, agi):
+        self.agi = agi
+        print "Connection established."
+        return agi.sayDate("1210498014").addCallback(
+            self.finish_test
+        ).addErrback(self.on_failure)
+
+	# Read test results and dialplan globals
+    def read_result(self):
+        self.agi.finish()
+        if self.passed is True and self.notified is True:
+            print "PASS - FastAGI SAY DATE 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 "AGI reports success: ", self.passed
+                print "Diaplan reports success: ", self.notified
+                print "FAIL - FastAGI SAY DATE 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 talkdetect_and_agi_notify 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 = FastAGISayDateTest(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/say-date/run-test
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/fastagi/say-date/run-test
------------------------------------------------------------------------------
    svn:executable = *

Propchange: asterisk/trunk/tests/fastagi/say-date/run-test
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/fastagi/say-date/run-test
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/fastagi/say-date/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/say-date/test-config.yaml?view=auto&rev=755
==============================================================================
--- asterisk/trunk/tests/fastagi/say-date/test-config.yaml (added)
+++ asterisk/trunk/tests/fastagi/say-date/test-config.yaml Wed Aug 18 11:04:30 2010
@@ -1,0 +1,11 @@
+testinfo:
+    summary:     'Test AGI SAY DATE command using FastAGI.'
+    description: |
+        'Test AGI SAY DATE command using FastAGI.'
+
+properties:
+    minversion: '1.4'
+    dependencies:
+        - app : 'python'
+        - python : 'twisted'
+        - python : 'starpy'

Propchange: asterisk/trunk/tests/fastagi/say-date/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/fastagi/say-date/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/fastagi/say-date/test-config.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/fastagi/say-datetime/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/say-datetime/run-test?view=auto&rev=755
==============================================================================
--- asterisk/trunk/tests/fastagi/say-datetime/run-test (added)
+++ asterisk/trunk/tests/fastagi/say-datetime/run-test Wed Aug 18 11:04:30 2010
@@ -1,0 +1,131 @@
+#!/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 FastAGISayDateTimeTest:
+    def __init__(self, argv):
+        self.passed = False
+        self.notified = 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')
+
+        # Listen for success or failure of talkdetect
+        self.agi_factory2 = fastagi.FastAGIFactory(self.listen_result)
+        reactor.listenTCP(4574, self.agi_factory2, self.timeout, '127.0.0.1')
+        reactor.callWhenRunning(self.run)
+
+        print self.ast_version
+        self.asterisk = Asterisk(base="/tmp/asterisk-testsuite/fastagi/say-datetime")
+        self.asterisk.install_configs("tests/fastagi/configs")
+
+    def listen_result(self, agi):
+        print "Got test success confirmation from dialplan."
+        self.notified = True
+        agi.finish()
+        self.result_changed()
+
+    def on_failure(self, reason):
+        print 'SAY DATETIME failed: ', reason.getTraceback()
+        self.passed = False
+
+    def finish_test(self, result):
+        print "AGI command reports success."
+        self.passed = True
+
+    # This gets invoked by the dialplan when the call is answered
+    # send SAY DATETIME command and wait for results
+    def do_test(self, agi):
+        self.agi = agi
+        print "Connection established."
+        return agi.sayDateTime("1210498014").addCallback(
+            self.finish_test
+        ).addErrback(self.on_failure)
+
+	# Read test results and dialplan globals
+    def read_result(self):
+        self.agi.finish()
+        if self.passed is True and self.notified is True:
+            print "PASS - FastAGI SAY DATETIME 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 "AGI reports success: ", self.passed
+                print "Diaplan reports success: ", self.notified
+                print "FAIL - FastAGI SAY DATETIME 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 talkdetect_and_agi_notify 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 = FastAGISayDateTimeTest(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/say-datetime/run-test
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/fastagi/say-datetime/run-test
------------------------------------------------------------------------------
    svn:executable = *

Propchange: asterisk/trunk/tests/fastagi/say-datetime/run-test
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/fastagi/say-datetime/run-test
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/fastagi/say-datetime/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/say-datetime/test-config.yaml?view=auto&rev=755
==============================================================================
--- asterisk/trunk/tests/fastagi/say-datetime/test-config.yaml (added)
+++ asterisk/trunk/tests/fastagi/say-datetime/test-config.yaml Wed Aug 18 11:04:30 2010
@@ -1,0 +1,11 @@
+testinfo:
+    summary:     'Test AGI SAY DATETIME command using FastAGI.'
+    description: |
+        'Test AGI SAY DATETIME command using FastAGI.'
+
+properties:
+    minversion: '1.4'
+    dependencies:
+        - app : 'python'
+        - python : 'twisted'
+        - python : 'starpy'

Propchange: asterisk/trunk/tests/fastagi/say-datetime/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/fastagi/say-datetime/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/fastagi/say-datetime/test-config.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/fastagi/say-digits/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/say-digits/run-test?view=auto&rev=755
==============================================================================
--- asterisk/trunk/tests/fastagi/say-digits/run-test (added)
+++ asterisk/trunk/tests/fastagi/say-digits/run-test Wed Aug 18 11:04:30 2010
@@ -1,0 +1,131 @@
+#!/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 FastAGISayDigitsTest:
+    def __init__(self, argv):
+        self.passed = False
+        self.notified = 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')
+
+        # Listen for success or failure of talkdetect
+        self.agi_factory2 = fastagi.FastAGIFactory(self.listen_result)
+        reactor.listenTCP(4574, self.agi_factory2, self.timeout, '127.0.0.1')
+        reactor.callWhenRunning(self.run)
+
+        print self.ast_version
+        self.asterisk = Asterisk(base="/tmp/asterisk-testsuite/fastagi/say-digits")
+        self.asterisk.install_configs("tests/fastagi/configs")
+
+    def listen_result(self, agi):
+        print "Got test success confirmation from dialplan."
+        self.notified = True
+        agi.finish()
+        self.result_changed()
+
+    def on_failure(self, reason):
+        print 'SAY DIGITS failed: ', reason.getTraceback()
+        self.passed = False
+
+    def finish_test(self, result):
+        print "AGI command reports success."
+        self.passed = True
+
+    # This gets invoked by the dialplan when the call is answered
+    # send SAY DIGITS command and wait for results
+    def do_test(self, agi):
+        self.agi = agi
+        print "Connection established."
+        return agi.sayDigits("31337").addCallback(
+            self.finish_test
+        ).addErrback(self.on_failure)
+
+	# Read test results and dialplan globals
+    def read_result(self):
+        self.agi.finish()
+        if self.passed is True and self.notified is True:
+            print "PASS - FastAGI SAY DIGITS 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 "AGI reports success: ", self.passed
+                print "Diaplan reports success: ", self.notified
+                print "FAIL - FastAGI SAY DIGITS 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 talkdetect_and_agi_notify 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 = FastAGISayDigitsTest(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/say-digits/run-test
------------------------------------------------------------------------------
    svn:eol-style = native


[... 629 lines stripped ...]



More information about the asterisk-commits mailing list