[asterisk-commits] kmoore: testsuite/asterisk/trunk r4611 - in /asterisk/trunk/tests/rest_api/ap...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Jan 28 13:21:25 CST 2014
Author: kmoore
Date: Tue Jan 28 13:21:22 2014
New Revision: 4611
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=4611
Log:
TestSuite: Add ARI test for double subscription
This adds a test to verify that a second subscription attempt to a
device state does not cause an error response.
(closes issue ASTERISK-23143)
Reported by: Matt Jordan
Added:
asterisk/trunk/tests/rest_api/applications/double-subscribe-device-state/
asterisk/trunk/tests/rest_api/applications/double-subscribe-device-state/configs/
asterisk/trunk/tests/rest_api/applications/double-subscribe-device-state/configs/ast1/
asterisk/trunk/tests/rest_api/applications/double-subscribe-device-state/configs/ast1/extensions.conf (with props)
asterisk/trunk/tests/rest_api/applications/double-subscribe-device-state/subscribe_device_state.py (with props)
asterisk/trunk/tests/rest_api/applications/double-subscribe-device-state/test-config.yaml (with props)
Modified:
asterisk/trunk/tests/rest_api/applications/tests.yaml
Added: asterisk/trunk/tests/rest_api/applications/double-subscribe-device-state/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/applications/double-subscribe-device-state/configs/ast1/extensions.conf?view=auto&rev=4611
==============================================================================
--- asterisk/trunk/tests/rest_api/applications/double-subscribe-device-state/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/rest_api/applications/double-subscribe-device-state/configs/ast1/extensions.conf Tue Jan 28 13:21:22 2014
@@ -1,0 +1,6 @@
+[default]
+
+exten => s,1,NoOp()
+ same => n,Answer()
+ same => n,Stasis(testsuite)
+ same => n,Hangup()
Propchange: asterisk/trunk/tests/rest_api/applications/double-subscribe-device-state/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/rest_api/applications/double-subscribe-device-state/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/rest_api/applications/double-subscribe-device-state/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/rest_api/applications/double-subscribe-device-state/subscribe_device_state.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/applications/double-subscribe-device-state/subscribe_device_state.py?view=auto&rev=4611
==============================================================================
--- asterisk/trunk/tests/rest_api/applications/double-subscribe-device-state/subscribe_device_state.py (added)
+++ asterisk/trunk/tests/rest_api/applications/double-subscribe-device-state/subscribe_device_state.py Tue Jan 28 13:21:22 2014
@@ -1,0 +1,42 @@
+"""
+Copyright (C) 2013, Digium, Inc.
+Kevin Harwell <kharwell at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+"""
+
+URL = 'deviceStates'
+DEVICE = 'Stasis:Test'
+INITIAL_STATE = 'NOT_INUSE'
+CHANGED_STATE = 'INUSE'
+
+def on_start(ari, event, obj):
+ # add a device state
+ ari.put(URL, DEVICE, deviceState=INITIAL_STATE)
+
+ # subscribe to device
+ ari.post("applications", "testsuite", "subscription",
+ eventSource="deviceState:%s" % DEVICE)
+
+ # subscribe to device
+ ari.post("applications", "testsuite", "subscription",
+ eventSource="deviceState:%s" % DEVICE)
+
+ # change the device state
+ ari.put(URL, DEVICE, deviceState=CHANGED_STATE)
+
+ # unsubscribe from device
+ ari.delete("applications", "testsuite", "subscription",
+ eventSource="deviceState:%s" % DEVICE)
+
+ # remove device
+ ari.delete(URL, DEVICE)
+
+ ari.delete('channels', event['channel']['id'])
+ return True
+
+def on_state_change(ari, event, obj):
+ assert event['device_state']['name'] == DEVICE
+ assert event['device_state']['state'] == CHANGED_STATE
+ return True
Propchange: asterisk/trunk/tests/rest_api/applications/double-subscribe-device-state/subscribe_device_state.py
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/rest_api/applications/double-subscribe-device-state/subscribe_device_state.py
------------------------------------------------------------------------------
svn:executable = *
Propchange: asterisk/trunk/tests/rest_api/applications/double-subscribe-device-state/subscribe_device_state.py
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/rest_api/applications/double-subscribe-device-state/subscribe_device_state.py
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/rest_api/applications/double-subscribe-device-state/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/applications/double-subscribe-device-state/test-config.yaml?view=auto&rev=4611
==============================================================================
--- asterisk/trunk/tests/rest_api/applications/double-subscribe-device-state/test-config.yaml (added)
+++ asterisk/trunk/tests/rest_api/applications/double-subscribe-device-state/test-config.yaml Tue Jan 28 13:21:22 2014
@@ -1,0 +1,48 @@
+testinfo:
+ summary: Test subscribing to device state twice from an application.
+ description: |
+ Subscribe an application to a device state, subscribe to the same
+ device state again, watch for a change in state, and then unsubscribe.
+
+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
+
+ari-config:
+ events:
+ - conditions:
+ match:
+ type: StasisStart
+ application: testsuite
+ args: []
+ count: 1
+ callback:
+ module: subscribe_device_state
+ method: on_start
+ - conditions:
+ match:
+ type: DeviceStateChanged
+ application: testsuite
+ count: 1
+ callback:
+ module: subscribe_device_state
+ method: on_state_change
+
+properties:
+ minversion: '12.0.0'
+ dependencies:
+ - python : autobahn.websocket
+ - python : requests
+ - python : twisted
+ - python : starpy
+ - asterisk : res_ari_device_states
+ - asterisk : app_echo
+ tags:
+ - ARI
+
+
Propchange: asterisk/trunk/tests/rest_api/applications/double-subscribe-device-state/test-config.yaml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/rest_api/applications/double-subscribe-device-state/test-config.yaml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/rest_api/applications/double-subscribe-device-state/test-config.yaml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: asterisk/trunk/tests/rest_api/applications/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/applications/tests.yaml?view=diff&rev=4611&r1=4610&r2=4611
==============================================================================
--- asterisk/trunk/tests/rest_api/applications/tests.yaml (original)
+++ asterisk/trunk/tests/rest_api/applications/tests.yaml Tue Jan 28 13:21:22 2014
@@ -6,3 +6,4 @@
# - test: 'subscribe-endpoint'
- test: 'subscribe-bridge'
- test: 'subscribe-device-state'
+ - test: 'double-subscribe-device-state'
More information about the asterisk-commits
mailing list