[asterisk-commits] kharwell: testsuite/asterisk/trunk r4418 - in /asterisk/trunk: lib/python/ast...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Dec 9 13:37:05 CST 2013
Author: kharwell
Date: Mon Dec 9 13:37:02 2013
New Revision: 4418
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=4418
Log:
Testsuite: ARI device state
Tests to make sure a device state can be created, changed and deleted using ARI.
Also tests to make make sure an application can [un]subscribe to device state
and receive change events.
(issue ASTERISK-22838)
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/3032/
Added:
asterisk/trunk/tests/rest_api/applications/subscribe-device-state/
asterisk/trunk/tests/rest_api/applications/subscribe-device-state/configs/
asterisk/trunk/tests/rest_api/applications/subscribe-device-state/configs/ast1/
asterisk/trunk/tests/rest_api/applications/subscribe-device-state/configs/ast1/extensions.conf (with props)
asterisk/trunk/tests/rest_api/applications/subscribe-device-state/subscribe_device_state.py (with props)
asterisk/trunk/tests/rest_api/applications/subscribe-device-state/test-config.yaml (with props)
asterisk/trunk/tests/rest_api/device_state/
asterisk/trunk/tests/rest_api/device_state/add_invalid/
asterisk/trunk/tests/rest_api/device_state/add_invalid/configs/
asterisk/trunk/tests/rest_api/device_state/add_invalid/configs/ast1/
asterisk/trunk/tests/rest_api/device_state/add_invalid/configs/ast1/extensions.conf (with props)
asterisk/trunk/tests/rest_api/device_state/add_invalid/device_state.py (with props)
asterisk/trunk/tests/rest_api/device_state/add_invalid/test-config.yaml (with props)
asterisk/trunk/tests/rest_api/device_state/add_remove/
asterisk/trunk/tests/rest_api/device_state/add_remove/configs/
asterisk/trunk/tests/rest_api/device_state/add_remove/configs/ast1/
asterisk/trunk/tests/rest_api/device_state/add_remove/configs/ast1/extensions.conf (with props)
asterisk/trunk/tests/rest_api/device_state/add_remove/device_state.py (with props)
asterisk/trunk/tests/rest_api/device_state/add_remove/test-config.yaml (with props)
asterisk/trunk/tests/rest_api/device_state/change/
asterisk/trunk/tests/rest_api/device_state/change/configs/
asterisk/trunk/tests/rest_api/device_state/change/configs/ast1/
asterisk/trunk/tests/rest_api/device_state/change/configs/ast1/extensions.conf (with props)
asterisk/trunk/tests/rest_api/device_state/change/device_state.py (with props)
asterisk/trunk/tests/rest_api/device_state/change/test-config.yaml (with props)
asterisk/trunk/tests/rest_api/device_state/list/
asterisk/trunk/tests/rest_api/device_state/list/configs/
asterisk/trunk/tests/rest_api/device_state/list/configs/ast1/
asterisk/trunk/tests/rest_api/device_state/list/configs/ast1/extensions.conf (with props)
asterisk/trunk/tests/rest_api/device_state/list/device_state.py (with props)
asterisk/trunk/tests/rest_api/device_state/list/test-config.yaml (with props)
asterisk/trunk/tests/rest_api/device_state/tests.yaml (with props)
Modified:
asterisk/trunk/lib/python/asterisk/ari.py
asterisk/trunk/tests/channels/pjsip/message/tests.yaml
asterisk/trunk/tests/rest_api/applications/tests.yaml
asterisk/trunk/tests/rest_api/tests.yaml
Modified: asterisk/trunk/lib/python/asterisk/ari.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/ari.py?view=diff&rev=4418&r1=4417&r2=4418
==============================================================================
--- asterisk/trunk/lib/python/asterisk/ari.py (original)
+++ asterisk/trunk/lib/python/asterisk/ari.py Mon Dec 9 13:37:02 2013
@@ -341,6 +341,19 @@
LOGGER.info("GET %s %r" % (url, kwargs))
return self.raise_on_err(requests.get(url, params=kwargs,
auth=self.userpass))
+
+ def put(self, *args, **kwargs):
+ '''Send a PUT request to ARI.
+
+ :param args: Path segements.
+ :param kwargs: Query parameters.
+ :returns: requests.models.Response
+ :throws: requests.exceptions.HTTPError
+ '''
+ url = self.build_url(*args)
+ LOGGER.info("PUT %s %r" % (url, kwargs))
+ return self.raise_on_err(requests.put(url, params=kwargs,
+ auth=self.userpass))
def post(self, *args, **kwargs):
'''Send a POST request to ARI.
Modified: asterisk/trunk/tests/channels/pjsip/message/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/pjsip/message/tests.yaml?view=diff&rev=4418&r1=4417&r2=4418
==============================================================================
--- asterisk/trunk/tests/channels/pjsip/message/tests.yaml (original)
+++ asterisk/trunk/tests/channels/pjsip/message/tests.yaml Mon Dec 9 13:37:02 2013
@@ -1,6 +1,7 @@
# Enter tests here in the order they should be considered for execution:
tests:
- test: 'message_basic'
+ - test: 'message_to_uri'
- test: 'message_from'
- test: 'message_cust_hdr'
- test: 'message_in_dialog'
Added: asterisk/trunk/tests/rest_api/applications/subscribe-device-state/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/applications/subscribe-device-state/configs/ast1/extensions.conf?view=auto&rev=4418
==============================================================================
--- asterisk/trunk/tests/rest_api/applications/subscribe-device-state/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/rest_api/applications/subscribe-device-state/configs/ast1/extensions.conf Mon Dec 9 13:37:02 2013
@@ -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/subscribe-device-state/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/rest_api/applications/subscribe-device-state/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: asterisk/trunk/tests/rest_api/applications/subscribe-device-state/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/rest_api/applications/subscribe-device-state/subscribe_device_state.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/applications/subscribe-device-state/subscribe_device_state.py?view=auto&rev=4418
==============================================================================
--- asterisk/trunk/tests/rest_api/applications/subscribe-device-state/subscribe_device_state.py (added)
+++ asterisk/trunk/tests/rest_api/applications/subscribe-device-state/subscribe_device_state.py Mon Dec 9 13:37:02 2013
@@ -1,0 +1,38 @@
+"""
+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="device_state:%s" % DEVICE)
+
+ # change the device state
+ ari.put(URL, DEVICE, deviceState=CHANGED_STATE)
+
+ # unsubscribe from device
+ ari.delete("applications", "testsuite", "subscription",
+ eventSource="device_state:%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/subscribe-device-state/subscribe_device_state.py
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/rest_api/applications/subscribe-device-state/subscribe_device_state.py
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: asterisk/trunk/tests/rest_api/applications/subscribe-device-state/subscribe_device_state.py
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/rest_api/applications/subscribe-device-state/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/applications/subscribe-device-state/test-config.yaml?view=auto&rev=4418
==============================================================================
--- asterisk/trunk/tests/rest_api/applications/subscribe-device-state/test-config.yaml (added)
+++ asterisk/trunk/tests/rest_api/applications/subscribe-device-state/test-config.yaml Mon Dec 9 13:37:02 2013
@@ -1,0 +1,48 @@
+testinfo:
+ summary: Test subscribing to device state from an application.
+ description: |
+ Subscribe an application to a device state, 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/subscribe-device-state/test-config.yaml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/rest_api/applications/subscribe-device-state/test-config.yaml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: asterisk/trunk/tests/rest_api/applications/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=4418&r1=4417&r2=4418
==============================================================================
--- asterisk/trunk/tests/rest_api/applications/tests.yaml (original)
+++ asterisk/trunk/tests/rest_api/applications/tests.yaml Mon Dec 9 13:37:02 2013
@@ -5,3 +5,4 @@
# Endpoint test requires an actual SIP endpoint in an ARI test
# - test: 'subscribe-endpoint'
- test: 'subscribe-bridge'
+ - test: 'subscribe-device-state'
Added: asterisk/trunk/tests/rest_api/device_state/add_invalid/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/device_state/add_invalid/configs/ast1/extensions.conf?view=auto&rev=4418
==============================================================================
--- asterisk/trunk/tests/rest_api/device_state/add_invalid/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/rest_api/device_state/add_invalid/configs/ast1/extensions.conf Mon Dec 9 13:37:02 2013
@@ -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/device_state/add_invalid/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/rest_api/device_state/add_invalid/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: asterisk/trunk/tests/rest_api/device_state/add_invalid/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/rest_api/device_state/add_invalid/device_state.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/device_state/add_invalid/device_state.py?view=auto&rev=4418
==============================================================================
--- asterisk/trunk/tests/rest_api/device_state/add_invalid/device_state.py (added)
+++ asterisk/trunk/tests/rest_api/device_state/add_invalid/device_state.py Mon Dec 9 13:37:02 2013
@@ -1,0 +1,28 @@
+'''
+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.
+'''
+
+import requests
+
+URL = 'deviceStates'
+INVALID_DEVICE = 'Invalid:Test'
+MISSING_DEVICE = 'Stasis:'
+INITIAL_STATE = 'NOT_INUSE'
+
+def on_start(ari, event, obj):
+ try:
+ ari.put(URL, INVALID_DEVICE, deviceState=INITIAL_STATE)
+ except requests.HTTPError, e:
+ assert 409 == e.response.status_code
+
+ try:
+ ari.put(URL, MISSING_DEVICE, deviceState=INITIAL_STATE)
+ except requests.HTTPError, e:
+ assert 404 == e.response.status_code
+
+ ari.delete('channels', event['channel']['id'])
+ return True
Propchange: asterisk/trunk/tests/rest_api/device_state/add_invalid/device_state.py
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/rest_api/device_state/add_invalid/device_state.py
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: asterisk/trunk/tests/rest_api/device_state/add_invalid/device_state.py
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/rest_api/device_state/add_invalid/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/device_state/add_invalid/test-config.yaml?view=auto&rev=4418
==============================================================================
--- asterisk/trunk/tests/rest_api/device_state/add_invalid/test-config.yaml (added)
+++ asterisk/trunk/tests/rest_api/device_state/add_invalid/test-config.yaml Mon Dec 9 13:37:02 2013
@@ -1,0 +1,42 @@
+testinfo:
+ summary: Tests trying to add an invalid device.
+ description: |
+ Attempts to create a non 'Stasis:<device>' state resource.
+
+test-modules:
+ add-test-to-search-path: True
+ test-object:
+ typename: ari.AriTestObject
+ modules:
+ - config-section: ari-config
+ typename: ari.WebSocketEventModule
+
+ari-config:
+ apps: testsuite
+ events:
+ - conditions:
+ match:
+ type: StasisStart
+ application: testsuite
+ args: []
+ count: 1
+ callback:
+ module: device_state
+ method: on_start
+ - 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/trunk/tests/rest_api/device_state/add_invalid/test-config.yaml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/rest_api/device_state/add_invalid/test-config.yaml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: asterisk/trunk/tests/rest_api/device_state/add_invalid/test-config.yaml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/rest_api/device_state/add_remove/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/device_state/add_remove/configs/ast1/extensions.conf?view=auto&rev=4418
==============================================================================
--- asterisk/trunk/tests/rest_api/device_state/add_remove/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/rest_api/device_state/add_remove/configs/ast1/extensions.conf Mon Dec 9 13:37:02 2013
@@ -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/device_state/add_remove/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/rest_api/device_state/add_remove/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: asterisk/trunk/tests/rest_api/device_state/add_remove/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/rest_api/device_state/add_remove/device_state.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/device_state/add_remove/device_state.py?view=auto&rev=4418
==============================================================================
--- asterisk/trunk/tests/rest_api/device_state/add_remove/device_state.py (added)
+++ asterisk/trunk/tests/rest_api/device_state/add_remove/device_state.py Mon Dec 9 13:37:02 2013
@@ -1,0 +1,23 @@
+'''
+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.
+'''
+
+import requests
+
+URL = 'deviceStates'
+DEVICE = 'Stasis:Test'
+INITIAL_STATE = 'NOT_INUSE'
+
+def on_start(ari, event, obj):
+ ari.put(URL, DEVICE, deviceState=INITIAL_STATE)
+ assert ari.get(URL, DEVICE).json()['state'] == INITIAL_STATE
+
+ ari.delete(URL, DEVICE)
+ assert ari.get(URL, DEVICE).json()['state'] == 'UNKNOWN'
+
+ ari.delete('channels', event['channel']['id'])
+ return True
Propchange: asterisk/trunk/tests/rest_api/device_state/add_remove/device_state.py
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/rest_api/device_state/add_remove/device_state.py
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: asterisk/trunk/tests/rest_api/device_state/add_remove/device_state.py
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/rest_api/device_state/add_remove/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/device_state/add_remove/test-config.yaml?view=auto&rev=4418
==============================================================================
--- asterisk/trunk/tests/rest_api/device_state/add_remove/test-config.yaml (added)
+++ asterisk/trunk/tests/rest_api/device_state/add_remove/test-config.yaml Mon Dec 9 13:37:02 2013
@@ -1,0 +1,42 @@
+testinfo:
+ summary: Tests adding and removing of an ARI controlled device.
+ description: |
+ Create a 'Stasis:<device>' state resource and then remove it.
+
+test-modules:
+ add-test-to-search-path: True
+ test-object:
+ typename: ari.AriTestObject
+ modules:
+ - config-section: ari-config
+ typename: ari.WebSocketEventModule
+
+ari-config:
+ apps: testsuite
+ events:
+ - conditions:
+ match:
+ type: StasisStart
+ application: testsuite
+ args: []
+ count: 1
+ callback:
+ module: device_state
+ method: on_start
+ - 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/trunk/tests/rest_api/device_state/add_remove/test-config.yaml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/rest_api/device_state/add_remove/test-config.yaml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: asterisk/trunk/tests/rest_api/device_state/add_remove/test-config.yaml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/rest_api/device_state/change/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/device_state/change/configs/ast1/extensions.conf?view=auto&rev=4418
==============================================================================
--- asterisk/trunk/tests/rest_api/device_state/change/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/rest_api/device_state/change/configs/ast1/extensions.conf Mon Dec 9 13:37:02 2013
@@ -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/device_state/change/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/rest_api/device_state/change/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: asterisk/trunk/tests/rest_api/device_state/change/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/rest_api/device_state/change/device_state.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/device_state/change/device_state.py?view=auto&rev=4418
==============================================================================
--- asterisk/trunk/tests/rest_api/device_state/change/device_state.py (added)
+++ asterisk/trunk/tests/rest_api/device_state/change/device_state.py Mon Dec 9 13:37:02 2013
@@ -1,0 +1,25 @@
+'''
+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.
+'''
+
+import requests
+
+URL = 'deviceStates'
+DEVICE = 'Stasis:Test'
+INITIAL_STATE = 'NOT_INUSE'
+CHANGED_STATE = 'INUSE'
+
+def on_start(ari, event, obj):
+ ari.put(URL, DEVICE, deviceState=INITIAL_STATE)
+ assert ari.get(URL, DEVICE).json()['state'] == INITIAL_STATE
+
+ ari.put(URL, DEVICE, deviceState=CHANGED_STATE)
+ assert ari.get(URL, DEVICE).json()['state'] == CHANGED_STATE
+
+ ari.delete(URL, DEVICE)
+ ari.delete('channels', event['channel']['id'])
+ return True
Propchange: asterisk/trunk/tests/rest_api/device_state/change/device_state.py
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/rest_api/device_state/change/device_state.py
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: asterisk/trunk/tests/rest_api/device_state/change/device_state.py
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/rest_api/device_state/change/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/device_state/change/test-config.yaml?view=auto&rev=4418
==============================================================================
--- asterisk/trunk/tests/rest_api/device_state/change/test-config.yaml (added)
+++ asterisk/trunk/tests/rest_api/device_state/change/test-config.yaml Mon Dec 9 13:37:02 2013
@@ -1,0 +1,43 @@
+testinfo:
+ summary: Tests changing an ARI controlled device state.
+ description: |
+ Create a 'Stasis:<device>' state resource, change the state, make sure
+ the state changed and then remove the device.
+
+test-modules:
+ add-test-to-search-path: True
+ test-object:
+ typename: ari.AriTestObject
+ modules:
+ - config-section: ari-config
+ typename: ari.WebSocketEventModule
+
+ari-config:
+ apps: testsuite
+ events:
+ - conditions:
+ match:
+ type: StasisStart
+ application: testsuite
+ args: []
+ count: 1
+ callback:
+ module: device_state
+ method: on_start
+ - 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/trunk/tests/rest_api/device_state/change/test-config.yaml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/rest_api/device_state/change/test-config.yaml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: asterisk/trunk/tests/rest_api/device_state/change/test-config.yaml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/rest_api/device_state/list/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/device_state/list/configs/ast1/extensions.conf?view=auto&rev=4418
==============================================================================
--- asterisk/trunk/tests/rest_api/device_state/list/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/rest_api/device_state/list/configs/ast1/extensions.conf Mon Dec 9 13:37:02 2013
@@ -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/device_state/list/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/rest_api/device_state/list/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: asterisk/trunk/tests/rest_api/device_state/list/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/rest_api/device_state/list/device_state.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/device_state/list/device_state.py?view=auto&rev=4418
==============================================================================
--- asterisk/trunk/tests/rest_api/device_state/list/device_state.py (added)
+++ asterisk/trunk/tests/rest_api/device_state/list/device_state.py Mon Dec 9 13:37:02 2013
@@ -1,0 +1,31 @@
+'''
+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.
+'''
+
+import requests
+
+URL = 'deviceStates'
+DEVICE1 = 'Stasis:Test1'
+DEVICE2 = 'Stasis:Test2'
+INITIAL_STATE = 'NOT_INUSE'
+
+def on_start(ari, event, obj):
+ ari.put(URL, DEVICE1, deviceState=INITIAL_STATE)
+ ari.put(URL, DEVICE2, deviceState=INITIAL_STATE)
+
+ devices = ari.get(URL).json()
+
+ assert devices
+
+ for device in devices:
+ assert device['name'] == DEVICE1 or device['name'] == DEVICE2
+ assert device['state'] == INITIAL_STATE
+
+ ari.delete(URL, DEVICE1)
+ ari.delete(URL, DEVICE2)
+ ari.delete('channels', event['channel']['id'])
+ return True
Propchange: asterisk/trunk/tests/rest_api/device_state/list/device_state.py
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/rest_api/device_state/list/device_state.py
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: asterisk/trunk/tests/rest_api/device_state/list/device_state.py
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/rest_api/device_state/list/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/device_state/list/test-config.yaml?view=auto&rev=4418
==============================================================================
--- asterisk/trunk/tests/rest_api/device_state/list/test-config.yaml (added)
+++ asterisk/trunk/tests/rest_api/device_state/list/test-config.yaml Mon Dec 9 13:37:02 2013
@@ -1,0 +1,43 @@
+testinfo:
+ summary: Tests listing of ARI controlled devices.
+ description: |
+ Create a couple 'Stasis:<device>' state resources and thne check to
+ make sure they show up in a listing.
+
+test-modules:
+ add-test-to-search-path: True
+ test-object:
+ typename: ari.AriTestObject
+ modules:
+ - config-section: ari-config
+ typename: ari.WebSocketEventModule
+
+ari-config:
+ apps: testsuite
+ events:
+ - conditions:
+ match:
+ type: StasisStart
+ application: testsuite
+ args: []
+ count: 1
+ callback:
+ module: device_state
+ method: on_start
+ - 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/trunk/tests/rest_api/device_state/list/test-config.yaml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/rest_api/device_state/list/test-config.yaml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: asterisk/trunk/tests/rest_api/device_state/list/test-config.yaml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/rest_api/device_state/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/device_state/tests.yaml?view=auto&rev=4418
==============================================================================
--- asterisk/trunk/tests/rest_api/device_state/tests.yaml (added)
+++ asterisk/trunk/tests/rest_api/device_state/tests.yaml Mon Dec 9 13:37:02 2013
@@ -1,0 +1,6 @@
+# Enter tests here in the order they should be considered for execution:
+tests:
+ - test: 'add_remove'
+ - test: 'add_invalid'
+ - test: 'change'
+ - test: 'list'
Propchange: asterisk/trunk/tests/rest_api/device_state/tests.yaml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/rest_api/device_state/tests.yaml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: asterisk/trunk/tests/rest_api/device_state/tests.yaml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: asterisk/trunk/tests/rest_api/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/tests.yaml?view=diff&rev=4418&r1=4417&r2=4418
==============================================================================
--- asterisk/trunk/tests/rest_api/tests.yaml (original)
+++ asterisk/trunk/tests/rest_api/tests.yaml Mon Dec 9 13:37:02 2013
@@ -7,4 +7,5 @@
- dir: 'bridges'
- dir: 'channels'
- dir: 'recording'
+ - dir: 'device_state'
- test: 'request-bodies'
More information about the asterisk-commits
mailing list