[asterisk-commits] mmichelson: testsuite/asterisk/trunk r4945 - in /asterisk/trunk/tests/rest_ap...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Apr 10 15:10:12 CDT 2014


Author: mmichelson
Date: Thu Apr 10 15:10:05 2014
New Revision: 4945

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=4945
Log:
Add ARI test for playing back a file to a channel in a bridge.


Added:
    asterisk/trunk/tests/rest_api/playback/to_channel_in_bridge/
    asterisk/trunk/tests/rest_api/playback/to_channel_in_bridge/play_file.py   (with props)
    asterisk/trunk/tests/rest_api/playback/to_channel_in_bridge/test-config.yaml   (with props)
Modified:
    asterisk/trunk/tests/rest_api/playback/tests.yaml

Modified: asterisk/trunk/tests/rest_api/playback/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/playback/tests.yaml?view=diff&rev=4945&r1=4944&r2=4945
==============================================================================
--- asterisk/trunk/tests/rest_api/playback/tests.yaml (original)
+++ asterisk/trunk/tests/rest_api/playback/tests.yaml Thu Apr 10 15:10:05 2014
@@ -1,3 +1,4 @@
 # Enter tests here in the order they should be considered for execution:
 tests:
     - test: 'basic'
+    - test: 'to_channel_in_bridge'

Added: asterisk/trunk/tests/rest_api/playback/to_channel_in_bridge/play_file.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/playback/to_channel_in_bridge/play_file.py?view=auto&rev=4945
==============================================================================
--- asterisk/trunk/tests/rest_api/playback/to_channel_in_bridge/play_file.py (added)
+++ asterisk/trunk/tests/rest_api/playback/to_channel_in_bridge/play_file.py Thu Apr 10 15:10:05 2014
@@ -1,0 +1,93 @@
+'''
+Copyright (C) 2014, Digium, Inc.
+Mark Michelson <mmichelson 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 PlayFile(object):
+    def __init__(self):
+        self.channel_id = None
+        self.bridge_id = None
+        self.first_playback_started = False
+        self.first_playback_finished = False
+        self.second_playback_started = False
+        self.second_playback_finished = False
+
+
+TEST = PlayFile()
+
+
+def ari_debug(func):
+    def print_debug(ari, event, test_object):
+        LOGGER.debug("%s(%r)" % (func.__name__, event))
+        return func(ari, event, test_object)
+    return print_debug
+
+
+ at ari_debug
+def on_start(ari, event, test_object):
+    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
+
+
+ at ari_debug
+def on_playback_started1(ari, event, test_object):
+    assert not TEST.first_playback_started
+    assert not TEST.first_playback_finished
+    assert not TEST.second_playback_started
+    assert not TEST.second_playback_finished
+    TEST.first_playback_started = True
+    return True
+
+
+ at ari_debug
+def on_playback_finished1(ari, event, test_object):
+    assert TEST.first_playback_started
+    assert not TEST.first_playback_finished
+    assert not TEST.second_playback_started
+    assert not TEST.second_playback_finished
+    TEST.first_playback_finished = True
+    return True
+
+
+ at ari_debug
+def on_playback_started2(ari, event, test_object):
+    assert TEST.first_playback_started
+    assert TEST.first_playback_finished
+    assert not TEST.second_playback_started
+    assert not TEST.second_playback_finished
+    TEST.second_playback_started = True
+    return True
+
+
+ at ari_debug
+def on_playback_finished2(ari, event, test_object):
+    assert TEST.first_playback_started
+    assert TEST.first_playback_finished
+    assert TEST.second_playback_started
+    assert not TEST.second_playback_finished
+    TEST.second_playback_finished = True
+    ari.post('bridges', TEST.bridge_id, 'removeChannel',
+             channel=TEST.channel_id)
+    return True
+
+
+ at ari_debug
+def on_leave(ari, event, test_object):
+    assert TEST.first_playback_started
+    assert TEST.first_playback_finished
+    assert TEST.second_playback_started
+    assert TEST.second_playback_finished
+    ari.delete('bridges', TEST.bridge_id)
+    ari.delete('channels', TEST.channel_id)
+    return True

Propchange: asterisk/trunk/tests/rest_api/playback/to_channel_in_bridge/play_file.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/rest_api/playback/to_channel_in_bridge/play_file.py
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/rest_api/playback/to_channel_in_bridge/play_file.py
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/rest_api/playback/to_channel_in_bridge/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/playback/to_channel_in_bridge/test-config.yaml?view=auto&rev=4945
==============================================================================
--- asterisk/trunk/tests/rest_api/playback/to_channel_in_bridge/test-config.yaml (added)
+++ asterisk/trunk/tests/rest_api/playback/to_channel_in_bridge/test-config.yaml Thu Apr 10 15:10:05 2014
@@ -1,0 +1,146 @@
+testinfo:
+    summary: 'Test playback start and manipulation using IDs'
+    description: |
+        * Originate a channel
+        * Create a bridge
+        * Add the channel to the bridge
+        * Playback two audio files to the channel (not the bridge)
+        * Wait for both to complete
+        * Remove the channel from the bridge
+        * Delete the bridge
+        * Validate all the events
+
+properties:
+    minversion: '12.2.0'
+    dependencies:
+        - python : autobahn.websocket
+        - python : requests
+        - python : twisted
+        - python : starpy
+        - asterisk : res_ari_channels
+        - asterisk : app_echo
+    tags:
+        - ARI
+
+test-modules:
+    add-test-to-search-path: True
+    test-object:
+        config-section: test-object-config
+        typename: ari.AriOriginateTestObject
+    modules:
+        -   config-section: ari-config
+            typename: ari.WebSocketEventModule
+
+test-object-config:
+
+ari-config:
+    apps: testsuite
+    events:
+        -
+            conditions:
+                match:
+                    type: StasisStart
+                    application: testsuite
+                    channel:
+                        id: 'testsuite-default-id$'
+            count: 1
+            callback:
+                module: play_file
+                method: on_start
+        -
+            conditions:
+                match:
+                    type: ChannelEnteredBridge
+                    application: testsuite
+            count: 1
+            requests:
+                -
+                    instance: 1
+                    delay: 1
+                    method: 'post'
+                    uri: 'channels/testsuite-default-id/play/MyPlaybackId1'
+                    params:
+                        media: 'sound:silence/5'
+                -
+                    instance: 1
+                    delay: 2
+                    method: 'post'
+                    uri: 'channels/testsuite-default-id/play/MyPlaybackId2'
+                    params:
+                        media: 'sound:silence/5'
+        -
+            conditions:
+                match:
+                    type: PlaybackStarted
+                    application: testsuite
+                    playback:
+                        id: 'MyPlaybackId1'
+                        target_uri: 'channel:testsuite-default-id$'
+            count: 1
+            callback:
+                module: play_file
+                method: on_playback_started1
+        -
+            conditions:
+                match:
+                    type: PlaybackFinished
+                    application: testsuite
+                    playback:
+                        id: 'MyPlaybackId1'
+                        target_uri: 'channel:testsuite-default-id$'
+            count: 1
+            callback:
+                module: play_file
+                method: on_playback_finished1
+        -
+            conditions:
+                match:
+                    type: PlaybackStarted
+                    application: testsuite
+                    playback:
+                        id: 'MyPlaybackId2'
+                        target_uri: 'channel:testsuite-default-id$'
+            count: 1
+            callback:
+                module: play_file
+                method: on_playback_started2
+        -
+            conditions:
+                match:
+                    type: PlaybackFinished
+                    application: testsuite
+                    playback:
+                        id: 'MyPlaybackId2'
+                        target_uri: 'channel:testsuite-default-id$'
+            count: 1
+            callback:
+                module: play_file
+                method: on_playback_finished2
+        -
+            conditions:
+                match:
+                    type: ChannelLeftBridge
+                    application: testsuite
+            count: 1
+            callback:
+                module: play_file
+                method: on_leave
+        -
+            conditions:
+                match:
+                    type: StasisEnd
+                    application: testsuite
+            count: 1
+
+properties:
+    minversion: '12.2.0'
+    dependencies:
+        - python : autobahn.websocket
+        - python : requests
+        - python : twisted
+        - python : starpy
+        - asterisk : res_ari_channels
+        - asterisk : res_stasis_playback
+        - asterisk : app_echo
+    tags:
+        - ARI

Propchange: asterisk/trunk/tests/rest_api/playback/to_channel_in_bridge/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/rest_api/playback/to_channel_in_bridge/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/rest_api/playback/to_channel_in_bridge/test-config.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain




More information about the asterisk-commits mailing list