[asterisk-commits] bbryant: testsuite/asterisk/trunk r787 - in /asterisk/trunk/tests: ./ pbx/ pb...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Sep 8 17:30:13 CDT 2010


Author: bbryant
Date: Wed Sep  8 17:30:09 2010
New Revision: 787

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=787
Log:
Add an new unit test that checks that call files connectiong users to both applications and extensions are working properly.

Added:
    asterisk/trunk/tests/pbx/
    asterisk/trunk/tests/pbx/call-files/
    asterisk/trunk/tests/pbx/call-files/configs/
    asterisk/trunk/tests/pbx/call-files/configs/extensions.conf   (with props)
    asterisk/trunk/tests/pbx/call-files/run-test   (with props)
    asterisk/trunk/tests/pbx/call-files/sample.call   (with props)
    asterisk/trunk/tests/pbx/call-files/sample2.call   (with props)
    asterisk/trunk/tests/pbx/call-files/test-config.yaml   (with props)
Modified:
    asterisk/trunk/tests/tests.yaml

Added: asterisk/trunk/tests/pbx/call-files/configs/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/pbx/call-files/configs/extensions.conf?view=auto&rev=787
==============================================================================
--- asterisk/trunk/tests/pbx/call-files/configs/extensions.conf (added)
+++ asterisk/trunk/tests/pbx/call-files/configs/extensions.conf Wed Sep  8 17:30:09 2010
@@ -1,0 +1,12 @@
+[test]
+exten => agi1,1,Answer
+exten => agi1,n,AGI(agi://127.0.0.1:4601)
+exten => agi1,n,Hangup
+
+exten => agi2,1,Answer
+exten => agi2,n,AGI(agi://127.0.0.1:4602)
+exten => agi2,n,Hangup
+
+exten => wait,1,Answer
+exten => wait,n,Wait(1)
+exten => wait,n,Hangup

Propchange: asterisk/trunk/tests/pbx/call-files/configs/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/pbx/call-files/configs/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/pbx/call-files/configs/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/pbx/call-files/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/pbx/call-files/run-test?view=auto&rev=787
==============================================================================
--- asterisk/trunk/tests/pbx/call-files/run-test (added)
+++ asterisk/trunk/tests/pbx/call-files/run-test Wed Sep  8 17:30:09 2010
@@ -1,0 +1,124 @@
+#!/usr/bin/env python
+'''
+Copyright (C) 2010, Digium, Inc.
+Brett Bryant <bbryant at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import sys
+import os
+import time
+from optparse import OptionParser
+from twisted.internet import reactor
+from starpy import fastagi
+from shutil import move, copy
+
+sys.path.append("lib/python")
+from asterisk.asterisk import Asterisk
+from asterisk.version import AsteriskVersion
+
+WORKINGDIR = "/tmp/asterisk-testsuite/call-files"
+TESTDIR = "tests/pbx/call-files"
+
+class CallFilesTest:
+    def __init__(self, argv):
+        self.passed = False
+        self.results = [ False, False ]
+        self.stopping = False
+
+        # Test timeout in seconds
+        self.timeout = 30
+
+        # get version info
+        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.asterisk1 = Asterisk(base=WORKINGDIR)
+        self.asterisk1.install_config("%s/configs/extensions.conf" %
+			              (TESTDIR))
+
+        self.agi_factory1 = fastagi.FastAGIFactory(self.get_result1)
+        self.agi_factory2 = fastagi.FastAGIFactory(self.get_result2)
+        reactor.listenTCP(4601, self.agi_factory1,
+                          self.timeout, '127.0.0.1')
+        reactor.listenTCP(4602, self.agi_factory2,
+                          self.timeout, '127.0.0.1')
+        reactor.callWhenRunning(self.run)
+
+    def get_result(self, testIndex, agi):
+        print "Got AGI connection from dialplan: Success."
+        self.results[testIndex-1] = True
+        if not (False in self.results):
+            self.passed = True
+            reactor.callLater(2, self.end)
+        return agi.finish()
+
+    def get_result1(self, agi):
+        self.get_result(1, agi)
+
+    def get_result2(self, agi):
+        self.get_result(2, agi)
+
+    def start_asterisk(self):
+        print "Starting Asterisk"
+        self.asterisk1.start()
+
+    def stop_asterisk(self):
+        self.asterisk1.stop()
+
+    def launch_test(self):
+        for i in [ "", "2" ]:
+            print "Moving the sample%s.call file to the spool dir..." % (i)
+
+            copy("%s/sample%s.call" % (TESTDIR, i),
+                 "%s/etc/sample%s.call" % (self.asterisk1.base, i))
+
+            move("%s/etc/sample%s.call" % (self.asterisk1.base, i),
+                 "%s%s/outgoing/" %
+                 (self.asterisk1.base,
+                  self.asterisk1.directories["astspooldir"]))
+
+    def run(self):
+        self.start_asterisk()
+
+        reactor.callLater(5, self.launch_test)
+        reactor.callLater(self.timeout, self.abort)
+
+    def abort(self):
+        if self.stopping: return
+        print "Aborting..."
+        self.end()
+
+    def end(self):
+        self.stopping = True
+
+        if reactor.running:
+            reactor.stop()
+
+        self.stop_asterisk()
+
+        print "Test 1 (Call File w/ Application) ... ",
+        print "Passed" if self.results[0] else "Failed"
+        print "Test 2 (Call File w/ Extension)   ... ",
+        print "Passed" if self.results[1] else "Failed"
+
+
+def main(argv=None):
+    if argv is None:
+        argv = sys.argv
+
+    # Run call-files test
+    call_files_test = CallFilesTest(argv)
+    reactor.run()
+
+    if call_files_test.passed != True:
+        return 1
+    return 0
+
+if __name__ == "__main__":
+    sys.exit(main() or 0)

Propchange: asterisk/trunk/tests/pbx/call-files/run-test
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/pbx/call-files/run-test
------------------------------------------------------------------------------
    svn:executable = *

Propchange: asterisk/trunk/tests/pbx/call-files/run-test
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/pbx/call-files/run-test
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/pbx/call-files/sample.call
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/pbx/call-files/sample.call?view=auto&rev=787
==============================================================================
--- asterisk/trunk/tests/pbx/call-files/sample.call (added)
+++ asterisk/trunk/tests/pbx/call-files/sample.call Wed Sep  8 17:30:09 2010
@@ -1,0 +1,8 @@
+Channel: Local/agi1 at test
+Codecs: alaw
+MaxRetries: 2
+RetryTime: 60
+WaitTime: 30
+
+Application: Wait
+Data: 1

Propchange: asterisk/trunk/tests/pbx/call-files/sample.call
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/pbx/call-files/sample.call
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/pbx/call-files/sample.call
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/pbx/call-files/sample2.call
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/pbx/call-files/sample2.call?view=auto&rev=787
==============================================================================
--- asterisk/trunk/tests/pbx/call-files/sample2.call (added)
+++ asterisk/trunk/tests/pbx/call-files/sample2.call Wed Sep  8 17:30:09 2010
@@ -1,0 +1,9 @@
+Channel: Local/agi2 at test
+Codecs: alaw
+MaxRetries: 2
+RetryTime: 60
+WaitTime: 30
+
+Context: test
+Extension: wait
+Priority: 1

Propchange: asterisk/trunk/tests/pbx/call-files/sample2.call
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/pbx/call-files/sample2.call
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/pbx/call-files/sample2.call
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/pbx/call-files/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/pbx/call-files/test-config.yaml?view=auto&rev=787
==============================================================================
--- asterisk/trunk/tests/pbx/call-files/test-config.yaml (added)
+++ asterisk/trunk/tests/pbx/call-files/test-config.yaml Wed Sep  8 17:30:09 2010
@@ -1,0 +1,9 @@
+testinfo:
+    summary:     'Tests that call files do not fail to load.'
+    description: 'Runs two call file tests to ensure that pbx_spool is working.'
+
+properties:
+    minversion: '1.4'
+    dependencies:
+        - python: 'twisted'
+        - python: 'starpy'

Propchange: asterisk/trunk/tests/pbx/call-files/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/pbx/call-files/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/pbx/call-files/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=787&r1=786&r2=787
==============================================================================
--- asterisk/trunk/tests/tests.yaml (original)
+++ asterisk/trunk/tests/tests.yaml Wed Sep  8 17:30:09 2010
@@ -60,5 +60,6 @@
     - test: 'fastagi/say-digits'
     - test: 'fastagi/say-number'
     - test: 'fastagi/say-phonetic'
+    - test: 'pbx/call-files'
 
 




More information about the asterisk-commits mailing list