[asterisk-commits] rest api/recording/stored: Add a test for downloading a stor... (testsuite[master])
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue May 24 05:18:27 CDT 2016
Anonymous Coward #1000019 has submitted this change and it was merged.
Change subject: rest_api/recording/stored: Add a test for downloading a stored recording file
......................................................................
rest_api/recording/stored: Add a test for downloading a stored recording file
This patch adds a test that covers downloading the media associated with
a stored recording. The test:
- Spawn a Local channel and places both ends into the Stasis app
- One end of the channel has tt-monkeys played back on it
- The other end records the file
- When the playback is completed, the recording is finished
- A custom callback then attempts to download the media in the stored
recording. We verify that the file is downloaded, has some bytes in
it, and pass if that is the case.
ASTERISK-26042
Change-Id: I494d3c329cb00e8b20a5435da6a542a923b92ef6
---
A tests/rest_api/recording/stored/configs/extensions.conf
A tests/rest_api/recording/stored/file/recording.py
A tests/rest_api/recording/stored/file/test-config.yaml
M tests/rest_api/recording/stored/tests.yaml
4 files changed, 155 insertions(+), 0 deletions(-)
Approvals:
Anonymous Coward #1000019: Verified
Joshua Colp: Looks good to me, approved
diff --git a/tests/rest_api/recording/stored/configs/extensions.conf b/tests/rest_api/recording/stored/configs/extensions.conf
new file mode 100644
index 0000000..aa88cf3
--- /dev/null
+++ b/tests/rest_api/recording/stored/configs/extensions.conf
@@ -0,0 +1,6 @@
+[default]
+
+exten => s,1,NoOp()
+ same => n,Answer()
+ same => n,Stasis(testsuite)
+ same => n,Hangup()
diff --git a/tests/rest_api/recording/stored/file/recording.py b/tests/rest_api/recording/stored/file/recording.py
new file mode 100644
index 0000000..bc0365b
--- /dev/null
+++ b/tests/rest_api/recording/stored/file/recording.py
@@ -0,0 +1,47 @@
+"""Check that we can retrieve the raw sound in a file
+
+Copyright (C) 2016, Digium, Inc.
+Matt Jordan <mjordan at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+"""
+
+import logging
+import requests
+import os
+
+from twisted.internet import reactor
+
+LOGGER = logging.getLogger(__name__)
+
+FILEPATH = '/tmp/superfly.wav'
+
+
+def on_recording_finished(ari, event, test_object):
+ LOGGER.info('Recording finished')
+
+ url = ari.build_url('recordings/stored', 'superfly', 'file')
+ resp = requests.get(url, stream=True, auth=ari.userpass)
+
+ if resp.status_code != 200:
+ LOGGER.error('Failed to download superfly: {0}'.format(
+ resp.status_code))
+ return False
+
+ with open(FILEPATH, 'wb') as f:
+ for chunk in resp:
+ f.write(chunk)
+
+ if (os.path.getsize(FILEPATH) == 0):
+ LOGGER.error('Sound file superfly is 0 bytes')
+ return False
+
+ LOGGER.info('Superfly downloaded successfully')
+ os.remove(FILEPATH)
+
+ ari.delete('channels', 'testsuite-default-id')
+
+ test_object.stop_reactor()
+
+ return True
diff --git a/tests/rest_api/recording/stored/file/test-config.yaml b/tests/rest_api/recording/stored/file/test-config.yaml
new file mode 100644
index 0000000..f498ee9
--- /dev/null
+++ b/tests/rest_api/recording/stored/file/test-config.yaml
@@ -0,0 +1,101 @@
+testinfo:
+ summary: Test downloading a stored recording
+ description: |
+ This test does the following:
+ - Makes a recording
+ - Retrieves the recording
+ - Verifies that the recording was downloaded successfully
+
+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
+ -
+ config-section: asterisk-config
+ typename: pluggable_modules.AsteriskConfigModule
+
+test-object-config:
+ stop-on-end: False
+ test-iterations:
+ -
+ endpoint: 'Local/s at default'
+ channelId: 'testsuite-default-id'
+ otherChannelId: 'testsuite-default-other-id'
+ extension: 's'
+ context: 'default'
+ priority: 1
+
+asterisk-config:
+ -
+ src: 'tests/rest_api/recording/stored/configs/extensions.conf'
+ dst: 'extensions.conf'
+
+ari-config:
+ apps: testsuite
+ events:
+ -
+ conditions:
+ match:
+ type: StasisStart
+ application: testsuite
+ channel:
+ id: 'testsuite-default-id$'
+ count: 1
+ requests:
+ method: 'post'
+ uri: 'channels/testsuite-default-id/record'
+ params:
+ name: 'superfly'
+ format: 'wav'
+ -
+ conditions:
+ match:
+ type: StasisStart
+ application: testsuite
+ channel:
+ id: 'testsuite-default-other-id'
+ count: 1
+ requests:
+ method: 'post'
+ uri: 'channels/testsuite-default-other-id/play/MyPlaybackId'
+ params:
+ media: 'sound:tt-monkeys'
+ -
+ conditions:
+ match:
+ type: PlaybackFinished
+ application: testsuite
+ playback:
+ id: MyPlaybackId
+ count: 1
+ requests:
+ method: 'post'
+ uri: 'recordings/live/superfly/stop'
+ -
+ conditions:
+ match:
+ type: RecordingFinished
+ recording:
+ name: superfly
+ count: 1
+ callback:
+ module: recording
+ method: on_recording_finished
+
+
+properties:
+ minversion: '14.0.0'
+ dependencies:
+ - python : autobahn.websocket
+ - python : requests
+ - python : twisted
+ - python : starpy
+ - asterisk : res_ari_channels
+ - asterisk : res_ari_recordings
+ - asterisk : app_echo
+ tags:
+ - ARI
diff --git a/tests/rest_api/recording/stored/tests.yaml b/tests/rest_api/recording/stored/tests.yaml
index b85272b..e3176f2 100644
--- a/tests/rest_api/recording/stored/tests.yaml
+++ b/tests/rest_api/recording/stored/tests.yaml
@@ -1,2 +1,3 @@
tests:
- dir: 'copy'
+ - test: 'file'
--
To view, visit https://gerrit.asterisk.org/2877
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I494d3c329cb00e8b20a5435da6a542a923b92ef6
Gerrit-PatchSet: 1
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Matt Jordan <mjordan at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
More information about the asterisk-commits
mailing list