[asterisk-commits] dlee: branch dlee/ASTERISK-22451-ari-subscribe-tests r4162 - in /asterisk/tea...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Sep 11 13:46:53 CDT 2013
Author: dlee
Date: Wed Sep 11 13:46:52 2013
New Revision: 4162
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=4162
Log:
Test error conditions
Added:
asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/errors/
asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/errors/configs/
asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/errors/configs/ast1/
asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/errors/configs/ast1/extensions.conf (with props)
asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/errors/errors.py (with props)
asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/errors/test-config.yaml (with props)
Modified:
asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/subscribe-channel/subscribe_channel.py
asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/tests.yaml
Added: asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/errors/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/errors/configs/ast1/extensions.conf?view=auto&rev=4162
==============================================================================
--- asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/errors/configs/ast1/extensions.conf (added)
+++ asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/errors/configs/ast1/extensions.conf Wed Sep 11 13:46:52 2013
@@ -1,0 +1,7 @@
+[default]
+
+exten => s,1,NoOp()
+ same => n,Answer()
+ same => n,Stasis(testsuite)
+ same => n,UserEvent(CanYouSeeMe)
+ same => n,Hangup()
Propchange: asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/errors/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/errors/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/errors/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/errors/errors.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/errors/errors.py?view=auto&rev=4162
==============================================================================
--- asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/errors/errors.py (added)
+++ asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/errors/errors.py Wed Sep 11 13:46:52 2013
@@ -1,0 +1,59 @@
+'''
+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__)
+
+
+def validate(expected, resp):
+ '''Validate a response against its expected code'''
+ expected_code = requests.codes[expected]
+ if expected_code != resp.status_code:
+ LOGGER.error("Expected %d (%s), got %s (%r)", expected_code,
+ expected, resp.status_code, resp.json())
+ raise ValueError('Test failed')
+
+
+def on_start(ari, event):
+ LOGGER.debug('on_start(%r)' % event)
+
+ app_list = ari.get('applications').json()
+ assert 1 == len(app_list)
+ assert 'testsuite' == app_list[0].get('name')
+
+
+ ari.set_allow_errors(True)
+
+ resp = ari.get('applications', 'notanapp')
+ validate('not_found', resp)
+
+ ari.post('applications', 'testsuite', 'subscription')
+ validate('bad_request', resp)
+
+ ari.delete('applications', 'testsuite', 'subscription')
+ validate('bad_request', resp)
+
+ ari.post('applications', 'testsuite', 'subscription',
+ eventSource='notascheme:foo')
+ validate('bad_request', resp)
+
+ ari.delete('applications', 'testsuite', 'subscription',
+ eventSource='notascheme:foo')
+ validate('bad_request', resp)
+
+ ari.post('applications', 'testsuite', 'subscription',
+ eventSource='channel:notachannel')
+ validate('unprocessable_entity', resp)
+
+ ari.delete('applications', 'testsuite', 'subscription',
+ eventSource='channel:notachannel')
+ validate('unprocessable_entity', resp)
+
+ ari.post('channels', test_data.channel_id, 'continue')
+ return True
Propchange: asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/errors/errors.py
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/errors/errors.py
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/errors/errors.py
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/errors/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/errors/test-config.yaml?view=auto&rev=4162
==============================================================================
--- asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/errors/test-config.yaml (added)
+++ asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/errors/test-config.yaml Wed Sep 11 13:46:52 2013
@@ -1,0 +1,50 @@
+testinfo:
+ summary: Test subscribing to a channel from an application.
+ description: |
+ Typical case of sending a channel to an application, application
+ subscribes to the channel, sends it back to the dialplan, continues
+ to receive events about the channel.
+
+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:
+ events:
+ - conditions:
+ match:
+ type: StasisStart
+ application: testsuite
+ args: []
+ count: 1
+ callback:
+ module: errors
+ method: on_start
+ - conditions:
+ match:
+ type: ChannelUserevent
+ eventname: CanYouSeeMe
+ count: 0
+
+properties:
+ minversion: '12.0.0'
+ dependencies:
+ - python : autobahn.websocket
+ - python : requests
+ - python : twisted
+ - python : starpy
+ - asterisk : res_ari_channels
+ - asterisk : app_echo
+ - asterisk : app_userevent
+ tags:
+ - ARI
+
+
Propchange: asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/errors/test-config.yaml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/errors/test-config.yaml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/errors/test-config.yaml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/subscribe-channel/subscribe_channel.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/subscribe-channel/subscribe_channel.py?view=diff&rev=4162&r1=4161&r2=4162
==============================================================================
--- asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/subscribe-channel/subscribe_channel.py (original)
+++ asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/subscribe-channel/subscribe_channel.py Wed Sep 11 13:46:52 2013
@@ -22,9 +22,6 @@
def on_start(ari, event):
LOGGER.debug("on_start(%r)" % event)
test_data.channel_id = event["channel"]["id"]
- res = ari.get("applications")
- LOGGER.error("Apps: %r", res.json())
-
ari.post("applications", "testsuite", "subscription",
eventSource="channel:%s" % test_data.channel_id)
ari.post("channels", test_data.channel_id, "continue")
Modified: asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/tests.yaml?view=diff&rev=4162&r1=4161&r2=4162
==============================================================================
--- asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/tests.yaml (original)
+++ asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/tests.yaml Wed Sep 11 13:46:52 2013
@@ -1,5 +1,6 @@
# Enter tests here in the order they should be considered for execution:
tests:
+ - test: 'errors'
- test: 'subscribe-channel'
# - test: 'subscribe-endpoint'
# - test: 'subscribe-bridge'
More information about the asterisk-commits
mailing list