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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Aug 13 16:36:03 CDT 2013


Author: dlee
Date: Tue Aug 13 16:36:01 2013
New Revision: 4012

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=4012
Log:
Happy path bridge test

Added:
    asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/
    asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/happy/
    asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/happy/bridge_simple.py   (with props)
    asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/happy/configs/
    asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/happy/configs/ast1/
    asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/happy/configs/ast1/extensions.conf   (with props)
    asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/happy/test-config.yaml   (with props)
    asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/tests.yaml   (with props)
Modified:
    asterisk/team/dlee/ari-bridge-tests/lib/python/asterisk/TestConfig.py
    asterisk/team/dlee/ari-bridge-tests/lib/python/asterisk/ari.py
    asterisk/team/dlee/ari-bridge-tests/tests/rest_api/tests.yaml

Modified: asterisk/team/dlee/ari-bridge-tests/lib/python/asterisk/TestConfig.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/dlee/ari-bridge-tests/lib/python/asterisk/TestConfig.py?view=diff&rev=4012&r1=4011&r2=4012
==============================================================================
--- asterisk/team/dlee/ari-bridge-tests/lib/python/asterisk/TestConfig.py (original)
+++ asterisk/team/dlee/ari-bridge-tests/lib/python/asterisk/TestConfig.py Tue Aug 13 16:36:01 2013
@@ -406,6 +406,9 @@
         if not self.config:
             return False
 
+        if not "properties" in self.config:
+            raise ValueError("%s: Missing properties section" % self.test_name)
+
         self.deps = [
             Dependency(d)
                 for d in self.config["properties"].get("dependencies") or []

Modified: asterisk/team/dlee/ari-bridge-tests/lib/python/asterisk/ari.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/dlee/ari-bridge-tests/lib/python/asterisk/ari.py?view=diff&rev=4012&r1=4011&r2=4012
==============================================================================
--- asterisk/team/dlee/ari-bridge-tests/lib/python/asterisk/ari.py (original)
+++ asterisk/team/dlee/ari-bridge-tests/lib/python/asterisk/ari.py Tue Aug 13 16:36:01 2013
@@ -335,7 +335,7 @@
         :returns: requests.models.Response
         :throws: requests.exceptions.HTTPError
         '''
-        url = self.build_url(*args, **kwargs)
+        url = self.build_url(*args)
         LOGGER.info("POST %s %r" % (url, kwargs))
         return raise_on_err(requests.post(url, params=kwargs,
                                           auth=self.userpass))
@@ -348,7 +348,7 @@
         :returns: requests.models.Response
         :throws: requests.exceptions.HTTPError
         '''
-        url = self.build_url(*args, **kwargs)
+        url = self.build_url(*args)
         LOGGER.info("DELETE %s %r" % (url, kwargs))
         return raise_on_err(requests.delete(url, params=kwargs,
                                             auth=self.userpass))
@@ -381,7 +381,7 @@
             self.callback = getattr(module, callback['method'])
         else:
             # No callback; just use a no-op
-            self.callback = lambda **kwargs: None
+            self.callback = lambda *args, **kwargs: True
 
         test_object.register_stop_observer(self.on_stop)
 

Added: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/happy/bridge_simple.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/happy/bridge_simple.py?view=auto&rev=4012
==============================================================================
--- asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/happy/bridge_simple.py (added)
+++ asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/happy/bridge_simple.py Tue Aug 13 16:36:01 2013
@@ -1,0 +1,47 @@
+'''
+Copyright (C) 2013, Digium, Inc.
+David M. Lee, II <dlee at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import logging
+
+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 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 = 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_leave(ari, event):
+    return TEST.on_leave(ari, event)

Propchange: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/happy/bridge_simple.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/happy/bridge_simple.py
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/happy/bridge_simple.py
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/happy/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/happy/configs/ast1/extensions.conf?view=auto&rev=4012
==============================================================================
--- asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/happy/configs/ast1/extensions.conf (added)
+++ asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/happy/configs/ast1/extensions.conf Tue Aug 13 16:36:01 2013
@@ -1,0 +1,6 @@
+[default]
+
+exten => s,1,NoOp()
+	same => n,Answer()
+	same => n,Stasis(testsuite)
+	same => n,Hangup()

Propchange: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/happy/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/happy/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/happy/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 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=auto&rev=4012
==============================================================================
--- asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/happy/test-config.yaml (added)
+++ asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/happy/test-config.yaml Tue Aug 13 16:36:01 2013
@@ -1,0 +1,62 @@
+testinfo:
+    summary: Test adding/removing a channel to/from a bridge.
+    description: |
+        This test waits for a channel, puts it in a bridge, and takes it back
+        out again. Simple, right?
+
+test-modules:
+    add-test-to-search-path: True
+    test-object:
+        config-section: test-object-config
+        typename: ari.AriTestObject
+    modules:
+        -   config-section: ari-config
+            typename: ari.WebSocketEventModule
+
+test-object-config:
+
+ari-config:
+    apps: testsuite
+    events:
+        -   conditions:
+                match:
+                    type: StasisStart
+                    application: testsuite
+                    args: []
+            count: 1
+            callback:
+                module: bridge_simple
+                method: on_start
+        -   conditions:
+                match:
+                    type: ChannelEnteredBridge
+                    application: testsuite
+            count: 1
+            callback:
+                module: bridge_simple
+                method: on_enter
+        -   conditions:
+                match:
+                    type: ChannelLeftBridge
+                    application: testsuite
+            count: 1
+            callback:
+                module: bridge_simple
+                method: on_leave
+        -   conditions:
+                match:
+                    type: StasisEnd
+                    application: testsuite
+            count: 1
+
+properties:
+    minversion: '12.0.0'
+    dependencies:
+        - python : autobahn.websocket
+        - python : requests
+        - python : twisted
+        - python : starpy
+        - asterisk : res_ari_channels
+        - asterisk : app_echo
+    tags:
+        - ARI

Propchange: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/happy/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/happy/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/happy/test-config.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/tests.yaml?view=auto&rev=4012
==============================================================================
--- asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/tests.yaml (added)
+++ asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/tests.yaml Tue Aug 13 16:36:01 2013
@@ -1,0 +1,2 @@
+tests:
+    - test: 'happy'

Propchange: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/tests.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/tests.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/tests.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/dlee/ari-bridge-tests/tests/rest_api/tests.yaml?view=diff&rev=4012&r1=4011&r2=4012
==============================================================================
--- asterisk/team/dlee/ari-bridge-tests/tests/rest_api/tests.yaml (original)
+++ asterisk/team/dlee/ari-bridge-tests/tests/rest_api/tests.yaml Tue Aug 13 16:36:01 2013
@@ -3,3 +3,4 @@
     - test: 'continue'
     - test: 'authentication'
     - test: 'CORS'
+    - dir:  'bridges'




More information about the asterisk-commits mailing list