[asterisk-commits] mmichelson: branch mmichelson/bridge-tests r3363 - in /asterisk/team/mmichels...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Jul 25 16:45:13 CDT 2012
Author: mmichelson
Date: Wed Jul 25 16:45:09 2012
New Revision: 3363
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=3363
Log:
I now can run simple features once a bridge is set up.
This does no real error checking, but I have confirmed the features
work properly.
Modified:
asterisk/team/mmichelson/bridge-tests/lib/python/asterisk/BridgeTestCase.py
asterisk/team/mmichelson/bridge-tests/tests/bridge/simple_bridge/configs/ast1/extensions.conf
asterisk/team/mmichelson/bridge-tests/tests/bridge/simple_bridge/test-config.yaml
Modified: asterisk/team/mmichelson/bridge-tests/lib/python/asterisk/BridgeTestCase.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mmichelson/bridge-tests/lib/python/asterisk/BridgeTestCase.py?view=diff&rev=3363&r1=3362&r2=3363
==============================================================================
--- asterisk/team/mmichelson/bridge-tests/lib/python/asterisk/BridgeTestCase.py (original)
+++ asterisk/team/mmichelson/bridge-tests/lib/python/asterisk/BridgeTestCase.py Wed Jul 25 16:45:09 2012
@@ -20,6 +20,15 @@
ALICE_CONNECTED = '"Bob" <4321>'
BOB_CONNECTED = '"Alice" <1234>'
+
+ FEATURE_MAP = {
+ 'blindxfer' : 1,
+ 'atxfer' : 2,
+ 'disconnect' : 3,
+ 'automon' : 4,
+ 'automixmon' : 5,
+ 'parkcall' : 6
+ }
'''
Class that handles tests involving two-party bridges.
@@ -61,6 +70,7 @@
if (ami.id == 0):
self.ami_uut = ami
self.ami_uut.registerEvent('Bridge', self.uut_bridge_callback)
+ self.ami_uut.registerEvent('TestEvent', self.test_callback)
self.ast[ami.id].cli_exec("sip set debug on")
LOGGER.info("UUT AMI connected")
elif (ami.id == 1):
@@ -94,6 +104,7 @@
def start_test(self, test_run):
# Step 0: Set up event handlers and initialize values for this test run
self.hangup = test_run['hangup'] if 'hangup' in test_run else None
+ self.features = test_run['features'] if 'features' in test_run else []
self.alice_channel = None
self.bob_channel = None
self.uut_alice_channel = None
@@ -104,7 +115,8 @@
self.bob_dtmf = False
self.alice_hungup = False
self.bob_hungup = False
-
+ self.current_feature = 0
+ self.infeatures = False
# Step 1: Initiate a call from Alice to Bob
LOGGER.info("Originating call")
@@ -186,7 +198,7 @@
LOGGER.warning("Unexpected BRIDGEPEER value for Bob: %s" %
value)
self.set_passed(False)
- self.send_hangup()
+ self.execute_features()
self.ami_uut.getVar(self.uut_alice_channel,
'CONNECTEDLINE(all)').addCallback(alice_connected)
@@ -197,6 +209,50 @@
bob_bridgepeer = self.ami_uut.getVar(self.uut_bob_channel,
'BRIDGEPEER').addCallback(bob_bridgepeer)
+ def execute_features(self):
+ if self.current_feature < len(self.features):
+ self.infeatures = True
+ LOGGER.info("Going to execute a feature")
+ self.execute_feature(self.features[self.current_feature])
+ else:
+ LOGGER.info("All features executed")
+ self.send_hangup()
+
+ def execute_feature(self, feature):
+ if not 'who' in feature or not 'what' in feature or not 'success' in feature:
+ LOGGER.warning("Missing necessary feature information")
+ self.set_passed(False)
+ if feature['who'] == 'alice':
+ ami = self.ami_alice
+ channel = self.alice_channel
+ elif feature['who'] == 'bob':
+ ami = self.ami_bob
+ channel = self.bob_channel
+ else:
+ LOGGER.warning("Feature target must be 'alice' or 'bob'")
+ self.set_passed(False)
+
+ LOGGER.info("Sending feature %s to %s" % (feature['what'],
+ feature['who']))
+ ami.playDTMF(channel, BridgeTestCase.FEATURE_MAP[feature['what']])
+
+ def test_callback(self, ami, event):
+ if event.get('state') != 'FEATURE_DETECTION':
+ return
+
+ if not self.infeatures:
+ # We don't care about features yet, so
+ # just return
+ return
+ if event.get('result') == 'pass':
+ LOGGER.info("Feature detected was %s" % event.get('feature'))
+ else:
+ LOGGER.info("No feature detected")
+ LOGGER.info("Got FEATURE_DETECTION event")
+ # Move onto the next feature!
+ self.current_feature += 1
+ self.execute_features()
+
def send_hangup(self):
if not self.hangup:
LOGGER.info("No hangup set. Hang up will happen elsewhere")
Modified: asterisk/team/mmichelson/bridge-tests/tests/bridge/simple_bridge/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mmichelson/bridge-tests/tests/bridge/simple_bridge/configs/ast1/extensions.conf?view=diff&rev=3363&r1=3362&r2=3363
==============================================================================
--- asterisk/team/mmichelson/bridge-tests/tests/bridge/simple_bridge/configs/ast1/extensions.conf (original)
+++ asterisk/team/mmichelson/bridge-tests/tests/bridge/simple_bridge/configs/ast1/extensions.conf Wed Jul 25 16:45:09 2012
@@ -1,4 +1,4 @@
[default]
-exten => test_call,1,Dial(SIP/test_call at bob)
+exten => test_call,1,Dial(SIP/test_call at bob,,wW)
same => n,Hangup()
Modified: asterisk/team/mmichelson/bridge-tests/tests/bridge/simple_bridge/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mmichelson/bridge-tests/tests/bridge/simple_bridge/test-config.yaml?view=diff&rev=3363&r1=3362&r2=3363
==============================================================================
--- asterisk/team/mmichelson/bridge-tests/tests/bridge/simple_bridge/test-config.yaml (original)
+++ asterisk/team/mmichelson/bridge-tests/tests/bridge/simple_bridge/test-config.yaml Wed Jul 25 16:45:09 2012
@@ -13,6 +13,11 @@
-
extension: 'test_call'
hangup: 'alice'
+ features:
+ -
+ who: 'alice'
+ what: 'atxfer'
+ success: 'true'
-
extension: 'test_call'
hangup: 'bob'
More information about the asterisk-commits
mailing list