[asterisk-commits] kmoore: testsuite/asterisk/trunk r3105 - in /asterisk/trunk: lib/python/aster...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Mar 20 12:07:52 CDT 2012


Author: kmoore
Date: Tue Mar 20 12:07:45 2012
New Revision: 3105

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=3105
Log:
Add tests for macro deprecation and a new testcase subclass

Added tests include tests for app_macro and app_stack (GoSub) callbacks for
redirecting and connected line interception as well as a test for CCSS
callbacks.

This also adds a new test case subclass (SimpleTestCase) that simplifies
creation of new tests for features that require only a single Asterisk instance
for testing and can be verified via user AMI events.

(closes issue SWP-4257)
Review: https://reviewboard.asterisk.org/r/1761/

Added:
    asterisk/trunk/lib/python/asterisk/SimpleTestCase.py   (with props)
    asterisk/trunk/tests/channels/SIP/generic_ccss/
    asterisk/trunk/tests/channels/SIP/generic_ccss/configs/
    asterisk/trunk/tests/channels/SIP/generic_ccss/configs/ast1/
    asterisk/trunk/tests/channels/SIP/generic_ccss/configs/ast1/extensions.conf   (with props)
    asterisk/trunk/tests/channels/SIP/generic_ccss/configs/ast1/sip.conf   (with props)
    asterisk/trunk/tests/channels/SIP/generic_ccss/configs/ast2/
    asterisk/trunk/tests/channels/SIP/generic_ccss/configs/ast2/extensions.conf   (with props)
    asterisk/trunk/tests/channels/SIP/generic_ccss/configs/ast2/sip.conf   (with props)
    asterisk/trunk/tests/channels/SIP/generic_ccss/run-test   (with props)
    asterisk/trunk/tests/channels/SIP/generic_ccss/test-config.yaml   (with props)
    asterisk/trunk/tests/connected_line/
    asterisk/trunk/tests/connected_line/macro/
    asterisk/trunk/tests/connected_line/macro/configs/
    asterisk/trunk/tests/connected_line/macro/configs/ast1/
    asterisk/trunk/tests/connected_line/macro/configs/ast1/extensions.conf   (with props)
    asterisk/trunk/tests/connected_line/macro/run-test   (with props)
    asterisk/trunk/tests/connected_line/macro/test-config.yaml   (with props)
    asterisk/trunk/tests/connected_line/subroutine/
    asterisk/trunk/tests/connected_line/subroutine/configs/
    asterisk/trunk/tests/connected_line/subroutine/configs/ast1/
    asterisk/trunk/tests/connected_line/subroutine/configs/ast1/extensions.conf   (with props)
    asterisk/trunk/tests/connected_line/subroutine/run-test   (with props)
    asterisk/trunk/tests/connected_line/subroutine/test-config.yaml   (with props)
    asterisk/trunk/tests/connected_line/tests.yaml   (with props)
    asterisk/trunk/tests/redirecting/
    asterisk/trunk/tests/redirecting/macro/
    asterisk/trunk/tests/redirecting/macro/configs/
    asterisk/trunk/tests/redirecting/macro/configs/ast1/
    asterisk/trunk/tests/redirecting/macro/configs/ast1/extensions.conf   (with props)
    asterisk/trunk/tests/redirecting/macro/run-test   (with props)
    asterisk/trunk/tests/redirecting/macro/test-config.yaml   (with props)
    asterisk/trunk/tests/redirecting/subroutine/
    asterisk/trunk/tests/redirecting/subroutine/configs/
    asterisk/trunk/tests/redirecting/subroutine/configs/ast1/
    asterisk/trunk/tests/redirecting/subroutine/configs/ast1/extensions.conf   (with props)
    asterisk/trunk/tests/redirecting/subroutine/run-test   (with props)
    asterisk/trunk/tests/redirecting/subroutine/test-config.yaml   (with props)
    asterisk/trunk/tests/redirecting/tests.yaml   (with props)

Added: asterisk/trunk/lib/python/asterisk/SimpleTestCase.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/SimpleTestCase.py?view=auto&rev=3105
==============================================================================
--- asterisk/trunk/lib/python/asterisk/SimpleTestCase.py (added)
+++ asterisk/trunk/lib/python/asterisk/SimpleTestCase.py Tue Mar 20 12:07:45 2012
@@ -1,0 +1,58 @@
+#!/usr/bin/env python
+'''
+Copyright (C) 2012, Digium, Inc.
+Kinsey Moore <kmoore at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import sys
+import logging
+
+sys.path.append("lib/python")
+from TestCase import TestCase
+
+LOGGER = logging.getLogger(__name__)
+
+class SimpleTestCase(TestCase):
+    '''The base class for extremely simple tests requiring only a spawned call
+    into the dialplan where success can be reported via a user-defined AMI
+    event.'''
+    event_count = 0
+    expected_events = 1
+
+    def __init__(self):
+        TestCase.__init__(self)
+        self.create_asterisk()
+
+    def ami_connect(self, ami):
+        LOGGER.info("Initiating call to local/100 at test on Echo() for simple test")
+
+        ami.registerEvent('UserEvent', self.__event_cb)
+        df = ami.originate("local/100 at test", application="Echo")
+
+        def handle_failure(reason):
+            LOGGER.info("error sending originate:")
+            LOGGER.info(reason.getTraceback())
+            self.stop_reactor()
+            return reason
+
+        df.addErrback(handle_failure)
+
+    def __event_cb(self, ami, event):
+        if self.verify_event(event):
+            self.event_count += 1
+            if self.event_count == self.expected_events:
+                self.passed = True
+                self.stop_reactor()
+
+    def verify_event(self, event):
+        """
+        Hook method used to verify values in the event.
+        """
+        return True
+
+    def run(self):
+        TestCase.run(self)
+        self.create_ami_factory()

Propchange: asterisk/trunk/lib/python/asterisk/SimpleTestCase.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/lib/python/asterisk/SimpleTestCase.py
------------------------------------------------------------------------------
    svn:executable = *

Propchange: asterisk/trunk/lib/python/asterisk/SimpleTestCase.py
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/lib/python/asterisk/SimpleTestCase.py
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/channels/SIP/generic_ccss/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/SIP/generic_ccss/configs/ast1/extensions.conf?view=auto&rev=3105
==============================================================================
--- asterisk/trunk/tests/channels/SIP/generic_ccss/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/channels/SIP/generic_ccss/configs/ast1/extensions.conf Tue Mar 20 12:07:45 2012
@@ -1,0 +1,31 @@
+[globals]
+BOBUSED=0
+[alice-incoming]
+exten => s,1,answer
+exten => s,n,echo()
+
+[dpwait]
+exten => 1234,1,noop
+exten => 1234,n,answer
+exten => 1234,n,echo()
+
+[bob-incoming]
+exten => s,1,noop
+exten => s,n,gotoif($[${BOBUSED}] = 1?1000,1)
+exten => s,n,answer
+exten => s,n,set(GLOBAL(BOBUSED)=1)
+exten => s,n,UserEvent(CCSSStatus,status: BOB)
+exten => s,n,echo()
+
+exten => 1000,1,BUSY()
+
+
+exten => s,1,answer
+exten => s,n,echo()
+[dial-alice]
+exten => _X.,1,answer
+exten => _X.,n,dial(sip/alice/${EXTEN})
+
+[dial-bob]
+exten => _X.,1,answer
+exten => _X.,n,dial(sip/bob/${EXTEN})

Propchange: asterisk/trunk/tests/channels/SIP/generic_ccss/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/channels/SIP/generic_ccss/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/channels/SIP/generic_ccss/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/channels/SIP/generic_ccss/configs/ast1/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/SIP/generic_ccss/configs/ast1/sip.conf?view=auto&rev=3105
==============================================================================
--- asterisk/trunk/tests/channels/SIP/generic_ccss/configs/ast1/sip.conf (added)
+++ asterisk/trunk/tests/channels/SIP/generic_ccss/configs/ast1/sip.conf Tue Mar 20 12:07:45 2012
@@ -1,0 +1,19 @@
+[general]
+udpbindaddr = 127.0.0.1
+
+[alice]
+type = friend
+fromuser = alice
+host = 127.0.0.2
+context=alice-incoming
+qualify = no
+insecure = invite
+
+[bob]
+type = friend
+fromuser = bob
+context = bob-incoming
+host = 127.0.0.2
+qualify = no
+insecure = invite
+

Propchange: asterisk/trunk/tests/channels/SIP/generic_ccss/configs/ast1/sip.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/channels/SIP/generic_ccss/configs/ast1/sip.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/channels/SIP/generic_ccss/configs/ast1/sip.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/channels/SIP/generic_ccss/configs/ast2/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/SIP/generic_ccss/configs/ast2/extensions.conf?view=auto&rev=3105
==============================================================================
--- asterisk/trunk/tests/channels/SIP/generic_ccss/configs/ast2/extensions.conf (added)
+++ asterisk/trunk/tests/channels/SIP/generic_ccss/configs/ast2/extensions.conf Tue Mar 20 12:07:45 2012
@@ -1,0 +1,22 @@
+[to-bob]
+exten => 1234,1,noop
+exten => 1234,n,set(EVENT=call-failed)
+exten => 1234,n,dial(SIP/bob)
+
+exten => 1235,1,answer
+exten => 1235,n,set(EVENT=ccbs-requested)
+exten => 1235,n,CallCompletionRequest
+
+exten => h,1,UserEvent(CCSSStatus,status: ${EVENT})
+
+[macro-cc_test]
+exten => s,1,UserEvent(CCSSStatus,status: macro)
+exten => s,n,MacroExit
+
+[cc_test]
+exten => s,1,UserEvent(CCSSStatus,status: sub)
+exten => s,n,Return
+
+[dpwait]
+exten => 1234,1,answer
+exten => 1234,n,echo()

Propchange: asterisk/trunk/tests/channels/SIP/generic_ccss/configs/ast2/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/channels/SIP/generic_ccss/configs/ast2/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/channels/SIP/generic_ccss/configs/ast2/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/channels/SIP/generic_ccss/configs/ast2/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/SIP/generic_ccss/configs/ast2/sip.conf?view=auto&rev=3105
==============================================================================
--- asterisk/trunk/tests/channels/SIP/generic_ccss/configs/ast2/sip.conf (added)
+++ asterisk/trunk/tests/channels/SIP/generic_ccss/configs/ast2/sip.conf Tue Mar 20 12:07:45 2012
@@ -1,0 +1,28 @@
+[general]
+limitonpeers=yes
+udpbindaddr = 127.0.0.2
+
+[alice]
+type = friend
+context = to-bob
+host = 127.0.0.1
+qualify = no
+insecure = invite
+cc_agent_policy=generic
+cc_monitor_policy=generic
+cc_callback_macro=cc_test
+cc_callback_sub=cc_test,s,1
+callcounter=yes
+
+[bob]
+type = friend
+fromuser = bob
+context = bob-in
+host = 127.0.0.1
+qualify = no
+insecure = invite
+cc_agent_policy=generic
+cc_monitor_policy=generic
+cc_callback_macro=cc_test
+cc_callback_sub=cc_test,s,1
+callcounter=yes

Propchange: asterisk/trunk/tests/channels/SIP/generic_ccss/configs/ast2/sip.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/channels/SIP/generic_ccss/configs/ast2/sip.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/channels/SIP/generic_ccss/configs/ast2/sip.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/channels/SIP/generic_ccss/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/SIP/generic_ccss/run-test?view=auto&rev=3105
==============================================================================
--- asterisk/trunk/tests/channels/SIP/generic_ccss/run-test (added)
+++ asterisk/trunk/tests/channels/SIP/generic_ccss/run-test Tue Mar 20 12:07:45 2012
@@ -1,0 +1,108 @@
+#!/usr/bin/env python
+'''
+Copyright (C) 2012, Digium, Inc.
+Kinsey Moore <kmoore at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import sys
+import logging
+
+from twisted.internet import reactor
+
+sys.path.append("lib/python")
+from asterisk.asterisk import Asterisk
+from asterisk.TestCase import TestCase
+
+LOGGER = logging.getLogger(__name__)
+
+class GenericCCSSTest(TestCase):
+    event_count = 0
+    success_count = 0
+
+    def __init__(self):
+        TestCase.__init__(self)
+        self.reactor_timeout = 50
+        self.create_asterisk(2)
+
+    def handle_failure(self, reason):
+        LOGGER.warn("error sending originate:")
+        LOGGER.warn(reason.getTraceback())
+        self.stop_reactor()
+
+        return reason
+
+    def ami_connect(self, ami):
+        if ami.id == 0:
+            self.ami[0].registerEvent('UserEvent', self.ccss_callback)
+        else:
+            LOGGER.info("Initiating the blocking call from dialplan to bob")
+            df = self.ami[1].originate("sip/bob", "dpwait", "1234", 1)
+            df.addErrback(self.handle_failure)
+            self.ami[1].registerEvent('UserEvent', self.ccss_callback)
+
+    def ccss_callback(self, ami, event):
+        if event['userevent'] != 'CCSSStatus':
+            return
+
+        self.event_count += 1
+
+        if event['status'] == "sub":
+            LOGGER.info("subroutine executed as expected")
+            self.success_count += 1
+        elif event ['status'] == "macro":
+            LOGGER.info("macro executed as expected")
+            self.success_count += 1
+        elif event ['status'] == "BOB":
+            LOGGER.info("Bouncing a call off the ccss test instance (ast2) now that bob is occupied")
+            df = self.ami[0].originate("local/1234 at dial-alice", "dpwait", "1234", 1)
+            df.addErrback(self.handle_failure)
+        elif event ['status'] == "call-failed":
+            # since we now have a failed call, run the call completion request
+            LOGGER.info("Requesting CCBS")
+            df = self.ami[0].originate("local/1235 at dial-alice", "dpwait", "1234", 1)
+            df.addErrback(self.handle_failure)
+        elif event ['status'] == "ccbs-requested":
+            # CCBS requested, request channel list
+            LOGGER.info("CCBS requested, getting channel list")
+            df = self.ami[0].status().addCallbacks(self.status_callback, self.status_failed)
+
+        self.are_we_there_yet()
+
+    def are_we_there_yet(self):
+        if self.event_count == 5:
+            if self.success_count == 2:
+                self.passed = True
+            self.stop_reactor()
+
+    def status_callback(self, result):
+        # hangup all channels listed on the second instance
+        def hangupchan(status_result):
+            if status_result['context'] == 'bob-incoming':
+                self.ami[1].hangup(status_result['channel'])
+        [hangupchan(i) for i in result]
+
+    def status_failed(self, reason):
+        pass
+
+    def run(self):
+        TestCase.run(self)
+        self.create_ami_factory(2)
+
+
+def main():
+    test = GenericCCSSTest()
+    test.start_asterisk()
+    reactor.run()
+    test.stop_asterisk()
+
+    if not test.passed:
+        return 1
+
+    return 0
+
+if __name__ == "__main__":
+    sys.exit(main() or 0)
+

Propchange: asterisk/trunk/tests/channels/SIP/generic_ccss/run-test
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/channels/SIP/generic_ccss/run-test
------------------------------------------------------------------------------
    svn:executable = *

Propchange: asterisk/trunk/tests/channels/SIP/generic_ccss/run-test
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/channels/SIP/generic_ccss/run-test
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/channels/SIP/generic_ccss/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/SIP/generic_ccss/test-config.yaml?view=auto&rev=3105
==============================================================================
--- asterisk/trunk/tests/channels/SIP/generic_ccss/test-config.yaml (added)
+++ asterisk/trunk/tests/channels/SIP/generic_ccss/test-config.yaml Tue Mar 20 12:07:45 2012
@@ -1,0 +1,15 @@
+testinfo:
+    summary: 'Test SIP CCSS.'
+    description: 'Test generic SIP CCSS and usage of macro and subroutine callbacks.'
+
+properties:
+    minversion: '11'
+    dependencies:
+        - python : 'twisted'
+        - python : 'starpy'
+    tags:
+        - sip
+        - ccss
+        - macro
+        - gosub
+        - subroutine

Propchange: asterisk/trunk/tests/channels/SIP/generic_ccss/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/channels/SIP/generic_ccss/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/channels/SIP/generic_ccss/test-config.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/connected_line/macro/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/connected_line/macro/configs/ast1/extensions.conf?view=auto&rev=3105
==============================================================================
--- asterisk/trunk/tests/connected_line/macro/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/connected_line/macro/configs/ast1/extensions.conf Tue Mar 20 12:07:45 2012
@@ -1,0 +1,26 @@
+[test]
+exten => 100,1,NoOp
+exten => 100,n,Set(__CONNECTED_LINE_CALLER_SEND_MACRO=caller)
+exten => 100,n,Set(__CONNECTED_LINE_CALLER_SEND_MACRO_ARGS=45,4)
+exten => 100,n,Dial(local/101 at test)
+exten => 100,n,Hangup
+
+exten => 101,1,NoOp
+exten => 101,n,Set(CONNECTEDLINE(name,i)="Company Name")
+exten => 101,n,Set(CONNECTEDLINE(name-pres,i)=allowed)
+exten => 101,n,Set(CONNECTEDLINE(num,i)=5551212)
+exten => 101,n,Set(CONNECTEDLINE(num-pres)=allowed)
+exten => 101,n,Answer
+exten => 101,n,Echo()
+
+[macro-caller]
+; ARG1 is the prefix to add.
+; ARG2 is the number of digits at the end to add the prefix to.
+; When the macro ends the CONNECTEDLINE data is passed to the
+; channel driver.
+exten => s,1,NoOp(Add prefix to connected line, macro edition)
+exten => s,n,GotoIf($[${CONNECTEDLINE(number)} != 5551212]?end)
+exten => s,n,UserEvent(CLStatus,status: caller connected line macro,arg1: ${ARG1},arg2: ${ARG2})
+exten => s,n,Set(NOPREFIX=${CONNECTEDLINE(number):-${ARG2}})
+exten => s,n,Set(CONNECTEDLINE(num,i)=${ARG1}${NOPREFIX})
+exten => s,(end),MacroExit

Propchange: asterisk/trunk/tests/connected_line/macro/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/connected_line/macro/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/connected_line/macro/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/connected_line/macro/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/connected_line/macro/run-test?view=auto&rev=3105
==============================================================================
--- asterisk/trunk/tests/connected_line/macro/run-test (added)
+++ asterisk/trunk/tests/connected_line/macro/run-test Tue Mar 20 12:07:45 2012
@@ -1,0 +1,46 @@
+#!/usr/bin/env python
+'''
+Copyright (C) 2012, Digium, Inc.
+Kinsey Moore <kmoore at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import sys
+import logging
+
+sys.path.append("lib/python")
+from asterisk.SimpleTestCase import SimpleTestCase
+from twisted.internet import reactor
+
+LOGGER = logging.getLogger(__name__)
+
+class ConnectedLineTest(SimpleTestCase):
+    def verify_event(self, event):
+        if event['userevent'] != 'CLStatus':
+            return False
+
+        if event['arg1'] != '45':
+            return False
+
+        if event['arg2'] != '4':
+            return False
+
+        LOGGER.info("Got connected line event")
+        return True
+
+def main():
+    test = ConnectedLineTest()
+    test.start_asterisk()
+    reactor.run()
+    test.stop_asterisk()
+
+    if not test.passed:
+        return 1
+
+    return 0
+
+if __name__ == "__main__":
+    sys.exit(main() or 0)
+

Propchange: asterisk/trunk/tests/connected_line/macro/run-test
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/connected_line/macro/run-test
------------------------------------------------------------------------------
    svn:executable = *

Propchange: asterisk/trunk/tests/connected_line/macro/run-test
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/connected_line/macro/run-test
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/connected_line/macro/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/connected_line/macro/test-config.yaml?view=auto&rev=3105
==============================================================================
--- asterisk/trunk/tests/connected_line/macro/test-config.yaml (added)
+++ asterisk/trunk/tests/connected_line/macro/test-config.yaml Tue Mar 20 12:07:45 2012
@@ -1,0 +1,12 @@
+testinfo:
+    summary: 'Test connected line macro execution.'
+    description: 'Ensures that the macro execution for connected line executes as expected and receives its arguments properly.  This verifies functional usage of the following variables: CONNECTED_LINE_CALLEE_SEND_MACRO, CONNECTED_LINE_CALLEE_SEND_MACRO_ARGS, CONNECTED_LINE_CALLER_SEND_MACRO, CONNECTED_LINE_CALLER_SEND_MACRO_ARGS'
+
+properties:
+    minversion: '1.8'
+    dependencies:
+        - python : 'twisted'
+        - python : 'starpy'
+    tags:
+        - connected_line
+        - macro

Propchange: asterisk/trunk/tests/connected_line/macro/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/connected_line/macro/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/connected_line/macro/test-config.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/connected_line/subroutine/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/connected_line/subroutine/configs/ast1/extensions.conf?view=auto&rev=3105
==============================================================================
--- asterisk/trunk/tests/connected_line/subroutine/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/connected_line/subroutine/configs/ast1/extensions.conf Tue Mar 20 12:07:45 2012
@@ -1,0 +1,26 @@
+[test]
+exten => 100,1,NoOp
+exten => 100,n,Set(__CONNECTED_LINE_SEND_SUB=caller,s,1)
+exten => 100,n,Set(__CONNECTED_LINE_SEND_SUB_ARGS=45,4)
+exten => 100,n,Dial(local/101 at test)
+exten => 100,n,Hangup
+
+exten => 101,1,NoOp
+exten => 101,n,Set(CONNECTEDLINE(name,i)="Company Name")
+exten => 101,n,Set(CONNECTEDLINE(name-pres,i)=allowed)
+exten => 101,n,Set(CONNECTEDLINE(num,i)=5551212)
+exten => 101,n,Set(CONNECTEDLINE(num-pres)=allowed)
+exten => 101,n,Answer
+exten => 101,n,Echo()
+
+[caller]
+; ARG1 is the prefix to add.
+; ARG2 is the number of digits at the end to add the prefix to.
+; When the subroutine ends the CONNECTEDLINE data is passed to the
+; channel driver.
+exten => s,1,NoOp(Add prefix to connected line, subroutine edition)
+exten => s,n,GotoIf($[${CONNECTEDLINE(number)} != 5551212]?end)
+exten => s,n,UserEvent(CLStatus,status: connected line subroutine,arg1: ${ARG1},arg2: ${ARG2})
+exten => s,n,Set(NOPREFIX=${CONNECTEDLINE(number):-${ARG2}})
+exten => s,n,Set(CONNECTEDLINE(num,i)=${ARG1}${NOPREFIX})
+exten => s,(end),Return

Propchange: asterisk/trunk/tests/connected_line/subroutine/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/connected_line/subroutine/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/connected_line/subroutine/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/connected_line/subroutine/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/connected_line/subroutine/run-test?view=auto&rev=3105
==============================================================================
--- asterisk/trunk/tests/connected_line/subroutine/run-test (added)
+++ asterisk/trunk/tests/connected_line/subroutine/run-test Tue Mar 20 12:07:45 2012
@@ -1,0 +1,46 @@
+#!/usr/bin/env python
+'''
+Copyright (C) 2012, Digium, Inc.
+Kinsey Moore <kmoore at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import sys
+import logging
+
+sys.path.append("lib/python")
+from asterisk.SimpleTestCase import SimpleTestCase
+from twisted.internet import reactor
+
+LOGGER = logging.getLogger(__name__)
+
+class ConnectedLineTest(SimpleTestCase):
+    def verify_event(self, event):
+        if event['userevent'] != 'CLStatus':
+            return False
+
+        if event['arg1'] != '45':
+            return False
+
+        if event['arg2'] != '4':
+            return False
+
+        LOGGER.info("Got connected line event")
+        return True
+
+def main():
+    test = ConnectedLineTest()
+    test.start_asterisk()
+    reactor.run()
+    test.stop_asterisk()
+
+    if not test.passed:
+        return 1
+
+    return 0
+
+if __name__ == "__main__":
+    sys.exit(main() or 0)
+

Propchange: asterisk/trunk/tests/connected_line/subroutine/run-test
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/connected_line/subroutine/run-test
------------------------------------------------------------------------------
    svn:executable = *

Propchange: asterisk/trunk/tests/connected_line/subroutine/run-test
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/connected_line/subroutine/run-test
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/connected_line/subroutine/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/connected_line/subroutine/test-config.yaml?view=auto&rev=3105
==============================================================================
--- asterisk/trunk/tests/connected_line/subroutine/test-config.yaml (added)
+++ asterisk/trunk/tests/connected_line/subroutine/test-config.yaml Tue Mar 20 12:07:45 2012
@@ -1,0 +1,13 @@
+testinfo:
+    summary: 'Test connected line subroutine execution.'
+    description: 'Ensures that the subroutine execution for connected line executes as expected and receives its arguments properly.  This verifies functional usage of the following variables: CONNECTED_LINE_SEND_SUB, CONNECTED_LINE_SEND_SUB_ARGS'
+
+properties:
+    minversion: '11'
+    dependencies:
+        - python : 'twisted'
+        - python : 'starpy'
+    tags:
+        - connected_line
+        - gosub
+        - subroutine

Propchange: asterisk/trunk/tests/connected_line/subroutine/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/connected_line/subroutine/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/connected_line/subroutine/test-config.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/connected_line/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/connected_line/tests.yaml?view=auto&rev=3105
==============================================================================
--- asterisk/trunk/tests/connected_line/tests.yaml (added)
+++ asterisk/trunk/tests/connected_line/tests.yaml Tue Mar 20 12:07:45 2012
@@ -1,0 +1,5 @@
+# Enter tests here in the order they should be considered for execution:
+tests:
+    - test: 'macro'
+    - test: 'subroutine'
+

Propchange: asterisk/trunk/tests/connected_line/tests.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/connected_line/tests.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/connected_line/tests.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/redirecting/macro/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/redirecting/macro/configs/ast1/extensions.conf?view=auto&rev=3105
==============================================================================
--- asterisk/trunk/tests/redirecting/macro/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/redirecting/macro/configs/ast1/extensions.conf Tue Mar 20 12:07:45 2012
@@ -1,0 +1,28 @@
+[test]
+exten => 100,1,NoOp
+exten => 100,n,Set(__REDIRECTING_CALLER_SEND_MACRO=caller)
+exten => 100,n,Set(__REDIRECTING_CALLER_SEND_MACRO_ARGS=45,4)
+exten => 100,n,Dial(local/101 at test)
+exten => 100,n,Hangup
+
+exten => 101,1,NoOp
+exten => 101,n,Set(REDIRECTING(to-num,i)=2000)
+exten => 101,n,Set(REDIRECTING(to-num-pres)=allowed)
+exten => 101,n,Set(REDIRECTING(from-num,i)=1000)
+exten => 101,n,Set(REDIRECTING(from-num-pres,i)=allowed)
+exten => 101,n,Set(REDIRECTING(count,i)=$[${REDIRECTING(count)} + 1])
+exten => 101,n,Set(REDIRECTING(reason,i)=cfu)
+exten => 101,n,Answer
+exten => 101,n,Echo()
+
+[macro-caller]
+; ARG1 is the prefix to add.
+; ARG2 is the number of digits at the end to add the prefix to.
+; When the macro ends the REDIRECTING data is passed to the
+; channel driver.
+exten => s,1,NoOp(Add prefix to redirecting to-num, macro edition)
+exten => s,n,GotoIf($[${REDIRECTING(to-num)} != 2000]?end)
+exten => s,n,UserEvent(RStatus,status: caller redirecting macro,arg1: ${ARG1},arg2: ${ARG2})
+exten => s,n,Set(NOPREFIX=${REDIRECTING(to-num):-${ARG2}})
+exten => s,n,Set(REDIRECTING(to-num,i)=${ARG1}${NOPREFIX})
+exten => s,(end),MacroExit

Propchange: asterisk/trunk/tests/redirecting/macro/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/redirecting/macro/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/redirecting/macro/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/redirecting/macro/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/redirecting/macro/run-test?view=auto&rev=3105
==============================================================================
--- asterisk/trunk/tests/redirecting/macro/run-test (added)
+++ asterisk/trunk/tests/redirecting/macro/run-test Tue Mar 20 12:07:45 2012
@@ -1,0 +1,46 @@
+#!/usr/bin/env python
+'''
+Copyright (C) 2012, Digium, Inc.
+Kinsey Moore <kmoore at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import sys
+import logging
+
+sys.path.append("lib/python")
+from asterisk.SimpleTestCase import SimpleTestCase
+from twisted.internet import reactor
+
+LOGGER = logging.getLogger(__name__)
+
+class RedirectingTest(SimpleTestCase):
+    def verify_event(self, event):
+        if event['userevent'] != 'RStatus':
+            return False
+
+        if event['arg1'] != '45':
+            return False
+
+        if event['arg2'] != '4':
+            return False
+
+        LOGGER.info("Got redirecting event")
+        return True
+
+def main():
+    test = RedirectingTest()
+    test.start_asterisk()
+    reactor.run()
+    test.stop_asterisk()
+
+    if not test.passed:
+        return 1
+
+    return 0
+
+if __name__ == "__main__":
+    sys.exit(main() or 0)
+

Propchange: asterisk/trunk/tests/redirecting/macro/run-test
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/redirecting/macro/run-test
------------------------------------------------------------------------------
    svn:executable = *

Propchange: asterisk/trunk/tests/redirecting/macro/run-test
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/redirecting/macro/run-test
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/redirecting/macro/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/redirecting/macro/test-config.yaml?view=auto&rev=3105
==============================================================================
--- asterisk/trunk/tests/redirecting/macro/test-config.yaml (added)
+++ asterisk/trunk/tests/redirecting/macro/test-config.yaml Tue Mar 20 12:07:45 2012
@@ -1,0 +1,12 @@
+testinfo:
+    summary: 'Test redirecting macro execution.'
+    description: 'Ensures that the macro execution for redirecting executes as expected and receives its arguments properly.  This verifies functional usage of the following variables: REDIRECTING_CALLER_SEND_MACRO, REDIRECTING_CALLER_SEND_MACRO_ARGS'
+
+properties:
+    minversion: '1.8'
+    dependencies:
+        - python : 'twisted'
+        - python : 'starpy'
+    tags:
+        - redirecting
+        - macro

Propchange: asterisk/trunk/tests/redirecting/macro/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/redirecting/macro/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/redirecting/macro/test-config.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/redirecting/subroutine/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/redirecting/subroutine/configs/ast1/extensions.conf?view=auto&rev=3105
==============================================================================
--- asterisk/trunk/tests/redirecting/subroutine/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/redirecting/subroutine/configs/ast1/extensions.conf Tue Mar 20 12:07:45 2012
@@ -1,0 +1,28 @@
+[test]
+exten => 100,1,NoOp
+exten => 100,n,Set(__REDIRECTING_SEND_SUB=caller,s,1)
+exten => 100,n,Set(__REDIRECTING_SEND_SUB_ARGS=45,4)
+exten => 100,n,Dial(local/101 at test)
+exten => 100,n,Hangup
+
+exten => 101,1,NoOp
+exten => 101,n,Set(REDIRECTING(to-num,i)=2000)
+exten => 101,n,Set(REDIRECTING(to-num-pres)=allowed)
+exten => 101,n,Set(REDIRECTING(from-num,i)=1000)
+exten => 101,n,Set(REDIRECTING(from-num-pres,i)=allowed)
+exten => 101,n,Set(REDIRECTING(count,i)=$[${REDIRECTING(count)} + 1])
+exten => 101,n,Set(REDIRECTING(reason,i)=cfu)
+exten => 101,n,Answer
+exten => 101,n,Echo()
+
+[caller]
+; ARG1 is the prefix to add.
+; ARG2 is the number of digits at the end to add the prefix to.
+; When the subroutine ends the REDIRECTING data is passed to the
+; channel driver.
+exten => s,1,NoOp(Add prefix to redirecting to-num, subroutine edition)
+exten => s,n,GotoIf($[${REDIRECTING(to-num)} != 2000]?end)
+exten => s,n,UserEvent(RStatus,status: caller redirecting subroutine,arg1: ${ARG1},arg2: ${ARG2})
+exten => s,n,Set(NOPREFIX=${REDIRECTING(to-num):-${ARG2}})
+exten => s,n,Set(REDIRECTING(to-num,i)=${ARG1}${NOPREFIX})
+exten => s,(end),Return

Propchange: asterisk/trunk/tests/redirecting/subroutine/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/redirecting/subroutine/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/redirecting/subroutine/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/redirecting/subroutine/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/redirecting/subroutine/run-test?view=auto&rev=3105
==============================================================================
--- asterisk/trunk/tests/redirecting/subroutine/run-test (added)
+++ asterisk/trunk/tests/redirecting/subroutine/run-test Tue Mar 20 12:07:45 2012
@@ -1,0 +1,46 @@
+#!/usr/bin/env python
+'''
+Copyright (C) 2012, Digium, Inc.
+Kinsey Moore <kmoore at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import sys
+import logging
+
+sys.path.append("lib/python")
+from asterisk.SimpleTestCase import SimpleTestCase
+from twisted.internet import reactor
+
+LOGGER = logging.getLogger(__name__)
+
+class RedirectingTest(SimpleTestCase):
+    def verify_event(self, event):
+        if event['userevent'] != 'RStatus':
+            return False
+

[... 96 lines stripped ...]



More information about the asterisk-commits mailing list