[asterisk-commits] jrose: testsuite/asterisk/trunk r4592 - in /asterisk/trunk/tests/rest_api: ./...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jan 20 12:25:17 CST 2014


Author: jrose
Date: Mon Jan 20 12:25:14 2014
New Revision: 4592

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=4592
Log:
Testsuite: Add ARI tests for external MWI

Note that I still need to add some kind of script to get Bamboo running
these tests since they depend on modules that aren't enabled by default.

Review: https://reviewboard.asterisk.org/r/3118/

Added:
    asterisk/trunk/tests/rest_api/mailbox/
    asterisk/trunk/tests/rest_api/mailbox/baseline/
    asterisk/trunk/tests/rest_api/mailbox/baseline/configs/
    asterisk/trunk/tests/rest_api/mailbox/baseline/configs/ast1/
    asterisk/trunk/tests/rest_api/mailbox/baseline/configs/ast1/extensions.conf   (with props)
    asterisk/trunk/tests/rest_api/mailbox/baseline/mailbox_baseline.py   (with props)
    asterisk/trunk/tests/rest_api/mailbox/baseline/test-config.yaml   (with props)
    asterisk/trunk/tests/rest_api/mailbox/tests.yaml   (with props)
Modified:
    asterisk/trunk/tests/rest_api/tests.yaml

Added: asterisk/trunk/tests/rest_api/mailbox/baseline/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/mailbox/baseline/configs/ast1/extensions.conf?view=auto&rev=4592
==============================================================================
--- asterisk/trunk/tests/rest_api/mailbox/baseline/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/rest_api/mailbox/baseline/configs/ast1/extensions.conf Mon Jan 20 12:25:14 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/mailbox/baseline/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/rest_api/mailbox/baseline/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/rest_api/mailbox/baseline/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/rest_api/mailbox/baseline/mailbox_baseline.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/mailbox/baseline/mailbox_baseline.py?view=auto&rev=4592
==============================================================================
--- asterisk/trunk/tests/rest_api/mailbox/baseline/mailbox_baseline.py (added)
+++ asterisk/trunk/tests/rest_api/mailbox/baseline/mailbox_baseline.py Mon Jan 20 12:25:14 2014
@@ -1,0 +1,74 @@
+'''
+Copyright (C) 2014, Digium, Inc.
+Jonathan Rose <jrose at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import requests
+import logging
+import operator
+
+LOGGER = logging.getLogger(__name__)
+
+def on_start(ari, event, obj):
+    mailboxes = ari.get('mailboxes').json()
+    assert len(mailboxes) == 0
+
+    LOGGER.info("Confirmed mailboxes started empty.")
+
+    ari.put('mailboxes', 'alice_mailbox', oldMessages='3', newMessages='4')
+    ari.put('mailboxes', 'bob_mailbox', oldMessages='5', newMessages='6')
+
+    LOGGER.info("Successfully added mailboxes");
+
+    # Get a specific mailbox
+    mailbox = ari.get('mailboxes', 'alice_mailbox').json()
+    assert mailbox
+    assert mailbox['name'] == 'alice_mailbox'
+    assert mailbox['old_messages'] == 3
+    assert mailbox['new_messages'] == 4
+
+    LOGGER.info("Successfully retrieved single mailbox and confirmed contents"
+                " matched expectations")
+
+    # Get the list of mailboxes
+    mailboxes = ari.get('mailboxes').json()
+    assert mailboxes
+
+    mailboxes = sorted(mailboxes, key=operator.itemgetter('name'))
+    expected = [
+        {"name": "bob_mailbox", "old_messages": 5, "new_messages": 6},
+        {"name": "alice_mailbox", "old_messages": 3, "new_messages": 4}
+    ]
+    expected = sorted(expected, key=operator.itemgetter('name'))
+
+    assert(mailboxes == expected)
+
+    LOGGER.info("Successfully listed mailboxes and checked contents for expectations")
+
+    # Change a mailbox
+    ari.put('mailboxes', 'alice_mailbox', oldMessages='11', newMessages='3')
+
+    # Delete a mailbox
+    ari.delete('mailboxes', 'bob_mailbox')
+
+    mailboxes = ari.get('mailboxes').json()
+    assert mailboxes
+    assert len(mailboxes) == 1
+
+    expected = [
+        {"name": "alice_mailbox", "old_messages": 11, "new_messages": 3}
+    ]
+
+    assert mailboxes == expected
+
+    LOGGER.info("Changed alice_mailbox. Confirmed new values.")
+    LOGGER.info("Deleted bob_mailbox. Confirmed removal from list.")
+
+    # While this test doesn't actually use the channel for any of the ARI
+    # operations that it does, its presence is necessary for triggering
+    # the test and removing it is necessary for completing the test.
+    ari.delete('channels', event['channel']['id'])
+    return True

Propchange: asterisk/trunk/tests/rest_api/mailbox/baseline/mailbox_baseline.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/rest_api/mailbox/baseline/mailbox_baseline.py
------------------------------------------------------------------------------
    svn:executable = *

Propchange: asterisk/trunk/tests/rest_api/mailbox/baseline/mailbox_baseline.py
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/rest_api/mailbox/baseline/mailbox_baseline.py
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/rest_api/mailbox/baseline/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/mailbox/baseline/test-config.yaml?view=auto&rev=4592
==============================================================================
--- asterisk/trunk/tests/rest_api/mailbox/baseline/test-config.yaml (added)
+++ asterisk/trunk/tests/rest_api/mailbox/baseline/test-config.yaml Mon Jan 20 12:25:14 2014
@@ -1,0 +1,50 @@
+testinfo:
+    summary: Tests basic mailbox modification and retrieval in ARI.
+    description: |
+        Create a couple mailboxes through ARI and confirm they can
+        be retrieved individually as well as within a list with the
+        expected values. Modify one and delete the other and confirm
+        that when the list is generated again that the deleted
+        mailbox is not in the list and that the modified mailbox has
+        the new expected values in 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: mailbox_baseline
+                method: on_start
+        -   conditions:
+                match:
+                    type: StasisEnd
+                    application: testsuite
+            count: 1
+
+properties:
+    minversion: '12.1.0'
+    dependencies:
+        - python : autobahn.websocket
+        - python : requests
+        - python : twisted
+        - python : starpy
+        - asterisk : res_ari_channels
+        - asterisk : res_ari_mailboxes
+        - asterisk : res_stasis_mailbox
+        - asterisk : res_mwi_external
+        - asterisk : app_echo
+    tags:
+        - ARI

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

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

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

Added: asterisk/trunk/tests/rest_api/mailbox/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/mailbox/tests.yaml?view=auto&rev=4592
==============================================================================
--- asterisk/trunk/tests/rest_api/mailbox/tests.yaml (added)
+++ asterisk/trunk/tests/rest_api/mailbox/tests.yaml Mon Jan 20 12:25:14 2014
@@ -1,0 +1,3 @@
+# Enter tests here in the order they should be considered for execution:
+tests:
+    - test: 'baseline'

Propchange: asterisk/trunk/tests/rest_api/mailbox/tests.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/rest_api/mailbox/tests.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/rest_api/mailbox/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=4592&r1=4591&r2=4592
==============================================================================
--- asterisk/trunk/tests/rest_api/tests.yaml (original)
+++ asterisk/trunk/tests/rest_api/tests.yaml Mon Jan 20 12:25:14 2014
@@ -11,4 +11,5 @@
     - test: 'request-bodies'
     - dir:  'danger'
     - test: 'content-type'
+    - dir:  'mailbox'
     - test: 'chunked-transfer'




More information about the asterisk-commits mailing list