[asterisk-commits] kmoore: testsuite/asterisk/trunk r5020 - in /asterisk/trunk/tests/rest_api/br...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu May 8 09:39:56 CDT 2014


Author: kmoore
Date: Thu May  8 09:39:44 2014
New Revision: 5020

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=5020
Log:
Testsuite: Simplify REST Attended Transfer test

This simplifies the REST attended transfer test in preparation for a
partial rewrite. Functionality is unchanged other than removing the
creation of a channel that was not actually needed.

Modified:
    asterisk/trunk/tests/rest_api/bridges/attended_transfer/attended_transfer.py
    asterisk/trunk/tests/rest_api/bridges/attended_transfer/configs/ast1/pjsip.conf
    asterisk/trunk/tests/rest_api/bridges/attended_transfer/test-config.yaml

Modified: asterisk/trunk/tests/rest_api/bridges/attended_transfer/attended_transfer.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/bridges/attended_transfer/attended_transfer.py?view=diff&rev=5020&r1=5019&r2=5020
==============================================================================
--- asterisk/trunk/tests/rest_api/bridges/attended_transfer/attended_transfer.py (original)
+++ asterisk/trunk/tests/rest_api/bridges/attended_transfer/attended_transfer.py Thu May  8 09:39:44 2014
@@ -13,62 +13,55 @@
 LOGGER = logging.getLogger(__name__)
 
 class TestLogic(object):
-	def __init__(self):
-		self.channels = 0
-		self.bridge_id = None
-		self.pja = subprocess.Popen(['pjsua', '--local-port=5065', '--null-audio',
-			'--id=sip:bob at 127.0.0.1'],
-			stdin=subprocess.PIPE, stdout=subprocess.PIPE)
-		self.pjb = subprocess.Popen(['pjsua', '--local-port=5066', '--null-audio',
-			'--id=sip:alice at 127.0.0.1'],
-			stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+    def __init__(self):
+        self.channels = 0
+        self.originated_id = None
+        self.bridge_id = None
+        self.pja = subprocess.Popen(['pjsua', '--local-port=5065', '--null-audio',
+            '--id=sip:bob at 127.0.0.1'],
+            stdin=subprocess.PIPE, stdout=subprocess.PIPE)
 
 TEST = TestLogic()
 
 def a_call_stasis():
-	TEST.pja.stdin.write("m\n")
-	TEST.pja.stdin.write("sip:stasis at 127.0.0.1:5060\n")
-
-def b_call_stasis():
-	TEST.pjb.stdin.write("m\n")
-	TEST.pjb.stdin.write("sip:stasis at 127.0.0.1:5060\n")
+    TEST.pja.stdin.write("m\n")
+    TEST.pja.stdin.write("sip:stasis at 127.0.0.1:5060\n")
 
 def on_third_leg(ami, event):
-	TEST.pja.stdin.write("X\n")
-	TEST.pja.stdin.write("1\n")
-	return True
+    LOGGER.debug("Peforming transfer")
+    TEST.pja.stdin.write("X\n")
+    LOGGER.debug("Selecting transferee")
+    TEST.pja.stdin.write("1\n")
+    LOGGER.debug("DONE")
+    return True
 
 def a_call_app():
-	TEST.pja.stdin.write("H\n")
-	TEST.pja.stdin.write("m\n")
-	TEST.pja.stdin.write("sip:1000 at 127.0.0.1:5060\n")
+    TEST.pja.stdin.write("H\n")
+    TEST.pja.stdin.write("m\n")
+    TEST.pja.stdin.write("sip:1000 at 127.0.0.1:5060\n")
 
 def on_kickoff_start(ari, event, test_object):
     LOGGER.debug("on_kickoff_start(%r)" % event)
     TEST.bridge_id = ari.post('bridges').json()['id']
     a_call_stasis()
-    b_call_stasis()
-    ari.delete('channels', event['channel']['id'])
+    TEST.originated_id = event['channel']['id']
+    ari.post('bridges', TEST.bridge_id, 'addChannel', channel=event['channel']['id'])
     return True
 
 def on_test_start(ari, event, test_object):
     LOGGER.debug("on_test_start(%r)" % event)
     ari.post('bridges', TEST.bridge_id, 'addChannel', channel=event['channel']['id'])
-
-    TEST.channels += 1
-    if TEST.channels == 2:
-        a_call_app()
-
+    a_call_app()
     return True
 
 def on_attended_transfer(ari, event, test_object):
-	LOGGER.debug("on_attended_transfer(%r)" % event)
-	ari.delete('bridges', TEST.bridge_id)
-	TEST.pjb.stdin.write("h\n")
+    LOGGER.debug("on_attended_transfer(%r)" % event)
+    ari.delete('bridges', TEST.bridge_id)
+    ari.delete('channels', TEST.originated_id)
 
-	if not event['transferer_first_leg']['name'].startswith('PJSIP/bob-'):
-		return False
-	elif event['transferer_first_leg_bridge']['id'] != TEST.bridge_id:
-		return False
+    if not event['transferer_first_leg']['name'].startswith('PJSIP/bob-'):
+        return False
+    elif event['transferer_first_leg_bridge']['id'] != TEST.bridge_id:
+        return False
 
-	return True
+    return True

Modified: asterisk/trunk/tests/rest_api/bridges/attended_transfer/configs/ast1/pjsip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/bridges/attended_transfer/configs/ast1/pjsip.conf?view=diff&rev=5020&r1=5019&r2=5020
==============================================================================
--- asterisk/trunk/tests/rest_api/bridges/attended_transfer/configs/ast1/pjsip.conf (original)
+++ asterisk/trunk/tests/rest_api/bridges/attended_transfer/configs/ast1/pjsip.conf Thu May  8 09:39:44 2014
@@ -9,11 +9,3 @@
 disallow=all
 allow=ulaw
 direct_media=no
-
-[alice]
-type=endpoint
-context=default
-disallow=all
-allow=ulaw
-direct_media=no
-

Modified: asterisk/trunk/tests/rest_api/bridges/attended_transfer/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/bridges/attended_transfer/test-config.yaml?view=diff&rev=5020&r1=5019&r2=5020
==============================================================================
--- asterisk/trunk/tests/rest_api/bridges/attended_transfer/test-config.yaml (original)
+++ asterisk/trunk/tests/rest_api/bridges/attended_transfer/test-config.yaml Thu May  8 09:39:44 2014
@@ -6,7 +6,6 @@
 test-modules:
     add-test-to-search-path: True
     test-object:
-        config-section: test-object-config
         typename: ari.AriTestObject
     modules:
         -
@@ -33,7 +32,7 @@
                     type: StasisStart
                     application: testsuite
                     args: ['test']
-            count: 2
+            count: 1
             callback:
                 module: attended_transfer
                 method: on_test_start




More information about the asterisk-commits mailing list