[asterisk-commits] dlee: branch dlee/ari-bridge-tests r4166 - in /asterisk/team/dlee/ari-bridge-...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Sep 12 11:47:25 CDT 2013


Author: dlee
Date: Thu Sep 12 11:47:22 2013
New Revision: 4166

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=4166
Log:
Addressed review feedback; removed silly forwarding functions

Modified:
    asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/hangup/bridge_hangup.py
    asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/hangup/test-config.yaml
    asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/happy/bridge_happy.py
    asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/happy/test-config.yaml
    asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/bridge_move.py
    asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/test-config.yaml
    asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/unhappy/bridge_unhappy.py
    asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/unhappy/test-config.yaml

Modified: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/hangup/bridge_hangup.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/hangup/bridge_hangup.py?view=diff&rev=4166&r1=4165&r2=4166
==============================================================================
--- asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/hangup/bridge_hangup.py (original)
+++ asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/hangup/bridge_hangup.py Thu Sep 12 11:47:22 2013
@@ -10,27 +10,29 @@
 
 LOGGER = logging.getLogger(__name__)
 
+
 class BridgeSimple(object):
-    def on_start(self, ari, event):
-        LOGGER.debug("on_start(%r)" % event)
-        self.channel_id = event['channel']['id']
-        self.bridge_id = ari.post('bridges').json()['id']
-        ari.post('channels', self.channel_id, 'answer')
-        ari.post('bridges', self.bridge_id, 'addChannel', channel=self.channel_id)
-        return True
+    def __init__(self):
+        self.channel_id = None
+        self.bridge_id = None
 
-    def on_enter(self, ari, event):
-        channel_id = event['channel']['id']
-        bridge_id = event['bridge']['id']
-        assert self.channel_id == channel_id
-        assert self.bridge_id == bridge_id
-        ari.delete('channels', channel_id)
-        return True
 
 TEST = BridgeSimple()
 
-def on_start(ari, event):
-    return TEST.on_start(ari, event)
 
-def on_enter(ari, event):
-    return TEST.on_enter(ari, event)
+def on_start(self, ari, event):
+    LOGGER.debug("on_start(%r)" % event)
+    TEST.channel_id = event['channel']['id']
+    TEST.bridge_id = ari.post('bridges').json()['id']
+    ari.post('channels', TEST.channel_id, 'answer')
+    ari.post('bridges', TEST.bridge_id, 'addChannel', channel=TEST.channel_id)
+    return True
+
+
+def on_enter(self, ari, event):
+    channel_id = event['channel']['id']
+    bridge_id = event['bridge']['id']
+    assert TEST.channel_id == channel_id
+    assert TEST.bridge_id == bridge_id
+    ari.delete('channels', channel_id)
+    return True

Modified: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/hangup/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/hangup/test-config.yaml?view=diff&rev=4166&r1=4165&r2=4166
==============================================================================
--- asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/hangup/test-config.yaml (original)
+++ asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/hangup/test-config.yaml Thu Sep 12 11:47:22 2013
@@ -11,8 +11,6 @@
     modules:
         -   config-section: ari-config
             typename: ari.WebSocketEventModule
-
-test-object-config:
 
 ari-config:
     apps: testsuite

Modified: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/happy/bridge_happy.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/happy/bridge_happy.py?view=diff&rev=4166&r1=4165&r2=4166
==============================================================================
--- asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/happy/bridge_happy.py (original)
+++ asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/happy/bridge_happy.py Thu Sep 12 11:47:22 2013
@@ -10,38 +10,38 @@
 
 LOGGER = logging.getLogger(__name__)
 
+
 class BridgeHappy(object):
-    def on_start(self, ari, event):
-        LOGGER.debug("on_start(%r)" % event)
-        self.channel_id = event['channel']['id']
-        self.bridge_id = ari.post('bridges').json()['id']
-        ari.post('channels', self.channel_id, 'answer')
-        ari.post('bridges', self.bridge_id, 'addChannel', channel=self.channel_id)
-        return True
+    def __init__(self):
+        self.channel_id = None
+        self.bridge_id = None
 
-    def on_enter(self, ari, event):
-        channel_id = event['channel']['id']
-        bridge_id = event['bridge']['id']
-        assert self.channel_id == channel_id
-        assert self.bridge_id == bridge_id
-        ari.post('bridges', bridge_id, 'removeChannel', channel=channel_id)
-        return True
-
-    def on_leave(self, ari, event):
-        channel_id = event['channel']['id']
-        bridge_id = event['bridge']['id']
-        assert self.channel_id == channel_id
-        assert self.bridge_id == bridge_id
-        ari.delete('channels', channel_id)
-        return True
 
 TEST = BridgeHappy()
 
-def on_start(ari, event):
-    return TEST.on_start(ari, event)
 
-def on_enter(ari, event):
-    return TEST.on_enter(ari, event)
+def on_start(self, ari, event):
+    LOGGER.debug("on_start(%r)" % event)
+    TEST.channel_id = event['channel']['id']
+    TEST.bridge_id = ari.post('bridges').json()['id']
+    ari.post('channels', TEST.channel_id, 'answer')
+    ari.post('bridges', TEST.bridge_id, 'addChannel', channel=TEST.channel_id)
+    return True
 
-def on_leave(ari, event):
-    return TEST.on_leave(ari, event)
+
+def on_enter(self, ari, event):
+    channel_id = event['channel']['id']
+    bridge_id = event['bridge']['id']
+    assert TEST.channel_id == channel_id
+    assert TEST.bridge_id == bridge_id
+    ari.post('bridges', bridge_id, 'removeChannel', channel=channel_id)
+    return True
+
+
+def on_leave(self, ari, event):
+    channel_id = event['channel']['id']
+    bridge_id = event['bridge']['id']
+    assert TEST.channel_id == channel_id
+    assert TEST.bridge_id == bridge_id
+    ari.delete('channels', channel_id)
+    return True

Modified: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/happy/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/happy/test-config.yaml?view=diff&rev=4166&r1=4165&r2=4166
==============================================================================
--- asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/happy/test-config.yaml (original)
+++ asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/happy/test-config.yaml Thu Sep 12 11:47:22 2013
@@ -12,8 +12,6 @@
     modules:
         -   config-section: ari-config
             typename: ari.WebSocketEventModule
-
-test-object-config:
 
 ari-config:
     apps: testsuite

Modified: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/bridge_move.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/bridge_move.py?view=diff&rev=4166&r1=4165&r2=4166
==============================================================================
--- asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/bridge_move.py (original)
+++ asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/bridge_move.py Thu Sep 12 11:47:22 2013
@@ -10,44 +10,46 @@
 
 LOGGER = logging.getLogger(__name__)
 
+
 class TestLogic(object):
-    def on_start(self, ari, event):
-        LOGGER.debug("on_start(%r)" % event)
-        self.channel_id = event['channel']['id']
-        self.bridge1_id = ari.post('bridges').json()['id']
-        self.bridge2_id = ari.post('bridges').json()['id']
-        ari.post('channels', self.channel_id, 'answer')
-        ari.post('bridges', self.bridge1_id, 'addChannel', channel=self.channel_id)
-        return True
+    def __init__(self):
+        self.channel_id = None
+        self.bridge1_id = None
+        self.bridge2_id = None
 
-    def on_enter(self, ari, event):
-        channel_id = event['channel']['id']
-        bridge_id = event['bridge']['id']
-        assert self.channel_id == channel_id
-        if self.bridge1_id == bridge_id:
-            # Move to the next bridge
-            ari.post('bridges', self.bridge2_id, 'addChannel', channel=self.channel_id)
-        elif self.bridge2_id == bridge_id:
-            # Hangup
-            ari.delete('channels', channel_id)
-        else:
-            assert False, "Unexpected bridge id %s" % bridge_id
-        return True
-
-    def on_leave(self, ari, event):
-        channel_id = event['channel']['id']
-        bridge_id = event['bridge']['id']
-        assert self.channel_id == channel_id
-        assert self.bridge1_id == bridge_id or self.bridge2_id == bridge_id
-        return True
 
 TEST = TestLogic()
 
-def on_start(ari, event):
-    return TEST.on_start(ari, event)
 
-def on_enter(ari, event):
-    return TEST.on_enter(ari, event)
+def on_start(self, ari, event):
+    LOGGER.debug("on_start(%r)" % event)
+    TEST.channel_id = event['channel']['id']
+    TEST.bridge1_id = ari.post('bridges').json()['id']
+    TEST.bridge2_id = ari.post('bridges').json()['id']
+    ari.post('channels', TEST.channel_id, 'answer')
+    ari.post('bridges', TEST.bridge1_id, 'addChannel', channel=TEST.channel_id)
+    return True
 
-def on_leave(ari, event):
-    return TEST.on_leave(ari, event)
+
+def on_enter(self, ari, event):
+    channel_id = event['channel']['id']
+    bridge_id = event['bridge']['id']
+    assert TEST.channel_id == channel_id
+    if TEST.bridge1_id == bridge_id:
+        # Move to the next bridge
+        ari.post('bridges', TEST.bridge2_id, 'addChannel',
+                 channel=TEST.channel_id)
+    elif TEST.bridge2_id == bridge_id:
+        # Hangup
+        ari.delete('channels', channel_id)
+    else:
+        assert False, "Unexpected bridge id %s" % bridge_id
+    return True
+
+
+def on_leave(self, ari, event):
+    channel_id = event['channel']['id']
+    bridge_id = event['bridge']['id']
+    assert TEST.channel_id == channel_id
+    assert TEST.bridge1_id == bridge_id or TEST.bridge2_id == bridge_id
+    return True

Modified: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/test-config.yaml?view=diff&rev=4166&r1=4165&r2=4166
==============================================================================
--- asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/test-config.yaml (original)
+++ asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/test-config.yaml Thu Sep 12 11:47:22 2013
@@ -11,8 +11,6 @@
     modules:
         -   config-section: ari-config
             typename: ari.WebSocketEventModule
-
-test-object-config:
 
 ari-config:
     apps: testsuite

Modified: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/unhappy/bridge_unhappy.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/unhappy/bridge_unhappy.py?view=diff&rev=4166&r1=4165&r2=4166
==============================================================================
--- asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/unhappy/bridge_unhappy.py (original)
+++ asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/unhappy/bridge_unhappy.py Thu Sep 12 11:47:22 2013
@@ -23,6 +23,7 @@
         self.ami_ready = False
         self.stasis_ready = False
         self.has_run = False
+        self.passing = False
 
     def on_start(self, ari, event):
         if not self.ami_channel_id:
@@ -41,11 +42,10 @@
     def on_end(self, ari, event):
         if event['channel']['id'] == self.ami_channel_id:
             self.ami_ready = True
-        elif event['channel']['id'] == self.stasis_channel_id:
-            pass
-        else:
+        elif event['channel']['id'] != self.stasis_channel_id:
             assert False, "Unexpected channel %s leaving Stasis" % \
                 event['channel']['id']
+
         return True
 
     def run_test(self, ari):
@@ -92,7 +92,7 @@
         validate('not_found', resp)
 
         #
-        # Add to a nonexistent bridge
+        # Remove from a nonexistent bridge
         #
         resp = ari.post('bridges', 'i-am-not-a-bridge', 'removeChannel',
                         channel=self.stasis_channel_id)

Modified: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/unhappy/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/unhappy/test-config.yaml?view=diff&rev=4166&r1=4165&r2=4166
==============================================================================
--- asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/unhappy/test-config.yaml (original)
+++ asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/unhappy/test-config.yaml Thu Sep 12 11:47:22 2013
@@ -1,7 +1,7 @@
 testinfo:
     summary: Test failure codes for bridge operations.
     description: |
-        Create a couple of channels, and try to put then into bridges...
+        Create a couple of channels, and try to put them into bridges...
         wrongly.
 
 test-modules:




More information about the asterisk-commits mailing list