[asterisk-commits] mjordan: testsuite/asterisk/trunk r1833 - in /asterisk/trunk: ./ lib/python/a...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Aug 11 16:11:37 CDT 2011


Author: mjordan
Date: Thu Aug 11 16:11:33 2011
New Revision: 1833

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=1833
Log:
Added leave_voicemail_nominal test; support for test failure as an expected result

Adds an initial test for app_voicemail, specifically the nominal execution of the VoiceMail
dialplan application.  Added support in test.yaml for properties/expectedResult option, which
will accept a value of 'Fail' to indicate that the test is expected to fail.  If the test fails,
a failure is not reported to the test execution engine and the test passes; otherwise, if the
test passes, a failure is reported to the test engine.

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


Added:
    asterisk/trunk/lib/python/asterisk/voicemail.py   (with props)
    asterisk/trunk/tests/apps/voicemail/
    asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/
    asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/
    asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/
    asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/extensions.conf   (with props)
    asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/manager.general.conf.inc   (with props)
    asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/sip.conf   (with props)
    asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/voicemail.conf   (with props)
    asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/
    asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/extensions.conf   (with props)
    asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/manager.general.conf.inc   (with props)
    asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/sip.conf   (with props)
    asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/run-test   (with props)
    asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/test-config.yaml   (with props)
    asterisk/trunk/tests/apps/voicemail/sounds/
    asterisk/trunk/tests/apps/voicemail/sounds/talking.ulaw   (with props)
    asterisk/trunk/tests/apps/voicemail/tests.yaml   (with props)
Modified:
    asterisk/trunk/lib/python/asterisk/asterisk.py
    asterisk/trunk/runtests.py
    asterisk/trunk/tests/apps/tests.yaml

Modified: asterisk/trunk/lib/python/asterisk/asterisk.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/asterisk.py?view=diff&rev=1833&r1=1832&r2=1833
==============================================================================
--- asterisk/trunk/lib/python/asterisk/asterisk.py (original)
+++ asterisk/trunk/lib/python/asterisk/asterisk.py Thu Aug 11 16:11:33 2011
@@ -42,6 +42,10 @@
     name and the value is the option's value to be written out into
     asterisk.conf.
     """
+
+    """The base working directory of this instance of Asterisk
+    """
+    baseDirectory = ""
 
     def __init__(self, base=None, ast_conf_options=None, host="127.0.0.1"):
         """Construct an Asterisk instance.
@@ -86,6 +90,7 @@
                 break
             i += 1
         os.makedirs(self.base)
+        self.baseDirectory = self.base
 
         # Mirror system install directory structure
         dir_cat = None

Added: asterisk/trunk/lib/python/asterisk/voicemail.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/voicemail.py?view=auto&rev=1833
==============================================================================
--- asterisk/trunk/lib/python/asterisk/voicemail.py (added)
+++ asterisk/trunk/lib/python/asterisk/voicemail.py Thu Aug 11 16:11:33 2011
@@ -1,0 +1,316 @@
+#!/usr/bin/env python
+# vim: sw=3 et:
+'''
+Copyright (C) 2011, 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 sys
+import os
+import glob
+import shutil
+
+from asterisk import Asterisk
+from config import Category
+from config import ConfigFile
+
+sys.path.append("lib/python")
+
+"""
+Class that manages creation of, verification of, and teardown of Asterisk mailboxes on the local filesystem
+"""
+class VoiceMailMailboxManagement(object):
+
+    """
+    Asterisk instance to track
+    """
+    __ast=None
+
+    """
+    Member variable that defines the base location for the voicemail folders
+    """
+    voicemailDirectory=""
+
+    """
+    The parent directory that this test resides in
+    """
+    testParentDir = "tests/apps/voicemail"
+
+    """
+    Name of the folder for new messages
+    """
+    inboxFolderName="INBOX"
+
+    """
+    Name of the folder for temporary messages
+    """
+    tempFolderName="tmp"
+
+    """
+    Name of the folder for old messages
+    """
+    oldFolderName="Old"
+
+    """
+    Name of the folder for urgent messages
+    """
+    urgentFolderName="Urgent"
+
+    """
+    Name of the folder for recorded greetings
+    """
+    greetingsFolderName="greet"
+
+    """
+    Constructor
+    ast    The instance of Asterisk to track
+    """
+    def __init__(self, ast):
+        self.__ast = ast
+        self.voicemailDirectory = self.__ast.directories['astspooldir'] + '/voicemail'
+
+
+    """
+    Creates the basic set of folders needed for a mailbox on the file system
+    context    The context that the mailbox will exist under
+    mailbox    The mailbox to create
+    createAllFolders    Optional parameter that will create all of the various folders.
+
+    In general, app_voicemail should be responsible for making the folders on the file system
+    as needed.  This method should only be needed when we want to bypass some of the standard applications
+    and create a known state of a voicemail mailbox
+
+    true on success, false on error
+    """
+    def createMailbox(self, context, mailbox, createAllFolders=False):
+        mailboxPath = self.__ast.baseDirectory + "%(vd)s/%(c)s/%(m)s" %{'vd': self.voicemailDirectory, 'c': context, 'm': mailbox}
+
+        try:
+            if not os.path.isdir(mailboxPath):
+                os.makedirs(mailboxPath)
+
+            if (createAllFolders):
+
+                inboxPath = "%(mp)s/%(f)s" %{'mp':mailboxPath, 'f':self.inboxFolderName}
+                if not os.path.isdir(inboxPath):
+                    os.makedirs(inboxPath)
+
+                tempPath = "%(mp)s/%(f)s" %{'mp':mailboxPath, 'f':self.tempFolderName}
+                if not os.path.isdir(tempPath):
+                    os.makedirs(tempPath)
+
+                oldPath = "%(mp)s/%(f)s" %{'mp':mailboxPath, 'f':self.oldFolderName}
+                if not os.path.isdir(oldPath):
+                    os.makedirs(oldPath)
+
+                urgentPath = "%(mp)s/%(f)s" %{'mp':mailboxPath, 'f':self.urgentFolderName}
+                if not os.path.isdir(urgentPath):
+                    os.makedirs(urgentPath)
+
+                greetingsPath = "%(mp)s/%(f)s" %{'mp':mailboxPath, 'f':self.greetingsFolderName}
+                if not os.path.isdir(greetingsPath):
+                    os.makedirs(greetingsPath)
+
+        except IOError as e:
+            if e.errno == errno.EACCESS:
+                print "You do not have sufficient permissions to perform the necessary directory manipulations"
+                return False
+
+        return True
+
+    """
+    Creates a dummy voicemail in the specified mailbox / folder
+    context    The context of the mailbox
+    mailbox    The mailbox
+    folder     The folder to create the voicemail in
+    msgnum     The message number
+    formats    The formats to create the sound file as
+
+    The 'formats' merely append particular designators on the end of the sound file,
+    /voicemail/sounds/talking.  The actual sound file is not converted.
+
+    True if the voicemail was created successfully, false otherwise
+    """
+    def createDummyVoicemail(self, context, mailbox, folder, msgnum, formats):
+        if not self.checkFolderExists(context, mailbox, folder):
+            return False
+
+        msgName = 'msg%04d' % (msgnum)
+        msgEnvName = msgName + ".txt"
+        msgEnvPath = self.__ast.baseDirectory + "%(vd)s/%(c)s/%(m)s/%(f)s/%(n)s" % {'vd':self.voicemailDirectory, 'c':context, 'm':mailbox, 'f':folder, 'n':msgEnvName}
+
+        f = open(msgEnvPath, 'w')
+        f.write(';\n')
+        f.write('; Message Information file\n')
+        f.write(';\n')
+        f.write('[message]\n')
+        f.write('origmailbox=' + mailbox + '\n')
+        f.write('context=' + context + '\n')
+        f.write('macrocontext=\n')
+        f.write('exten=' + mailbox + '\n')
+        f.write('rdnis=unknown\n')
+        f.write('priority=2\n')
+        f.write('callerchan=SIP/ast1-00000000\n')
+        f.write('callerid=\"Anonymous\"<ast1>\n')
+        f.write('origdate=Tue Aug  9 10:05:13 PM UTC 2011\n')
+        f.write('origtime=1312927513\n')
+        if (folder == self.urgentFolderName):
+            f.write('flag=Urgent\n')
+        else:
+            f.write('flag=\n')
+        f.write('duration=1\n')
+        f.close()
+
+        for format in formats:
+            msgFormatName = msgName + '.' + format
+            msgFormatPath = self.__ast.baseDirectory + "%(vd)s/%(c)s/%(m)s/%(f)s/%(n)s" % {'vd':self.voicemailDirectory, 'c':context, 'm':mailbox, 'f':folder, 'n':msgFormatName}
+            audioFile = os.path.join(os.getcwd(), "%s/sounds/talking.ulaw" % (self.testParentDir))
+            shutil.copy(audioFile, msgFormatPath)
+
+        return True
+
+    """
+    Checks that a folder exists for a particular user
+    context    The context of the mailbox
+    mailbox    The mailbox
+    folder     The folder to check; defaults to the default inbox name
+
+    true if the folder exists, false otherwise
+    """
+    def checkFolderExists(self, context, mailbox, folder=inboxFolderName):
+        mailboxPath = self.__ast.baseDirectory + "%(vd)s/%(c)s/%(m)s" %{'vd': self.voicemailDirectory, 'c': context, 'm': mailbox}
+
+        if not (os.path.exists(mailboxPath)):
+            return False
+
+        folderPath = "%(mp)s/%(f)s" %{'mp':mailboxPath, 'f':folder}
+
+        return os.path.exists(folderPath)
+
+    """
+    Check if a voicemail exists on the filesystem
+    context    The context of the mailbox
+    mailbox    The mailbox
+    msgnum     The 1-based index of the voicemail to check for
+    lstFormats The formats we expect to be recorded for us
+    folder     The folder to check under; default to the default inbox name
+
+    true if the voicemail exists, false otherwise
+    """
+    def checkVoicemailExists(self, context, mailbox, msgnum, lstFormats, folder=inboxFolderName):
+        retVal = True
+
+        """ construct the expected base file name
+        """
+        msgName = 'msg%04d' % (msgnum)
+
+        for format in lstFormats:
+            fileName = msgName + "." + format
+            retVal = retVal & self.checkVoiceFileExists(context, mailbox, fileName, folder)
+
+        """ make sure we have the message envelope file
+        """
+        fileName = msgName + ".txt"
+        retVal = retVal & self.checkVoiceFileExists(context, mailbox, fileName, folder)
+
+        return retVal
+
+    """
+    Check if a voicemail has the property specified
+    context    The context of the mailbox
+    mailbox    The mailbox
+    msgnum     The 1-based index of the voicemail to check for
+    propertyName    The name of the property to check
+    propertyValue    The value to check for
+    folder    The folder to check under; default to the default inbox name
+
+    true if the voicemail has the property and value specified; false otherwise
+    """
+    def checkVoicemailProperty(self, context, mailbox, msgnum, propertyName, propertyValue, folder=inboxFolderName):
+        lstFormats = []
+        if not self.checkVoicemailExists(context, mailbox, msgnum, lstFormats, folder):
+            return False
+
+        msgName = 'msg%(msgnum)04d' %{"msgnum":msgnum}
+        msgName = msgName + ".txt"
+        msgPath = self.__ast.baseDirectory + "%(vd)s/%(c)s/%(m)s/%(f)s/%(n)s" % {'vd':self.voicemailDirectory, 'c':context, 'm':mailbox, 'f':folder, 'n':msgName}
+
+        configFile = ConfigFile(msgPath)
+        for cat in configFile.categories:
+            if cat.name == 'message':
+                for kvp in cat.options:
+                    if kvp[0] == propertyName and kvp[1] == propertyValue:
+                        return True
+
+        return False
+
+    """
+    Checks if a file exists under the voicemail file structure
+    context    The context of the mailbox
+    mailbox    The mailbox
+    msgnum     The name of the file to check for
+    folder     The folder to check under; default to the default inbox name
+
+    true if the file exists, false otherwise
+    """
+    def checkVoiceFileExists(self, context, mailbox, name, folder=inboxFolderName):
+        if not (self.checkFolderExists(context, mailbox, folder)):
+            return False
+
+        msgPath = self.__ast.baseDirectory + "%(vd)s/%(c)s/%(m)s/%(f)s/%(n)s" % {'vd':self.voicemailDirectory, 'c':context, 'm':mailbox, 'f':folder, 'n':name}
+
+        if (os.path.exists(msgPath)):
+            return True
+        else:
+            return False
+
+
+    def __removeItemsFromFolder__(self, mailboxPath, folder):
+        folderPath = os.path.join(self.__ast.baseDirectory, "%(mp)s/%(f)s" % {'mp':mailboxPath, 'f':folder})
+
+        if not (os.path.exists(folderPath)):
+            return
+
+        folderPath = folderPath + '/*'
+        for voicemailFile in glob.glob(folderPath):
+            if not os.path.isdir(voicemailFile):
+                os.remove(voicemailFile)
+
+        return
+
+    """
+    Removes all items from a mailbox, and optionally removes the mailbox itself from the file system
+    context    The context the mailbox exists under
+    mailbox    The mailbox to remove
+    removeFolders    If true, the folders as well as their contents will be removed
+
+    This does not remove the context folder
+
+    False if the mailbox does not exist, otherwise True
+    """
+    def removeMailbox(self, context, mailbox, removeFolders=False):
+        mailboxPath = self.__ast.baseDirectory + "/%(vd)s/%(c)s/%(m)s" %{'vd': self.voicemailDirectory, 'c': context, 'm': mailbox}
+
+        if not (os.path.exists(mailboxPath)):
+            return False
+
+        self.__removeItemsFromFolder__(mailboxPath, self.inboxFolderName)
+        self.__removeItemsFromFolder__(mailboxPath, self.tempFolderName)
+        self.__removeItemsFromFolder__(mailboxPath, self.oldFolderName)
+        self.__removeItemsFromFolder__(mailboxPath, self.urgentFolderName)
+        self.__removeItemsFromFolder__(mailboxPath, self.greetingsFolderName)
+
+        if (removeFolders):
+            rmdir(os.path.join(self.__ast.baseDirectory, "%(mp)s/%(f)s" %{'mp':mailboxPath, 'f':self.inboxFolderName}))
+            rmdir(os.path.join(self.__ast.baseDirectory, "%(mp)s/%(f)s" %{'mp':mailboxPath, 'f':self.tempFolderName}))
+            rmdir(os.path.join(self.__ast.baseDirectory, "%(mp)s/%(f)s" %{'mp':mailboxPath, 'f':self.oldFolderName}))
+            rmdir(os.path.join(self.__ast.baseDirectory, "%(mp)s/%(f)s" %{'mp':mailboxPath, 'f':self.urgentFolderName}))
+            rmdir(os.path.join(self.__ast.baseDirectory, "%(mp)s/%(f)s" %{'mp':mailboxPath, 'f':self.greetingsFolderName}))
+
+            rmdir(mailboxPath)
+
+        return True
+

Propchange: asterisk/trunk/lib/python/asterisk/voicemail.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/lib/python/asterisk/voicemail.py
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/lib/python/asterisk/voicemail.py
------------------------------------------------------------------------------
    svn:mim-type = text/plain

Propchange: asterisk/trunk/lib/python/asterisk/voicemail.py
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: asterisk/trunk/runtests.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/runtests.py?view=diff&rev=1833&r1=1832&r2=1833
==============================================================================
--- asterisk/trunk/runtests.py (original)
+++ asterisk/trunk/runtests.py Thu Aug 11 16:11:33 2011
@@ -136,6 +136,7 @@
         self.minversion = None
         self.minversion_check = False
         self.deps = []
+        self.expectPass = True
 
         self.__parse_config()
         self.__check_deps(ast_version)
@@ -168,7 +169,8 @@
                 pass
             p.wait()
             f.close()
-            self.passed = p.returncode == 0
+
+            self.passed = (p.returncode == 0 and self.expectPass) or (p.returncode and not self.expectPass)
         else:
             print "FAILED TO EXECUTE %s, it must exist and be executable" % cmd
         self.time = time.time() - start_time
@@ -206,6 +208,13 @@
                 self.can_run = False
                 print "ERROR: '%s' is not a valid maxversion" % \
                         properties["maxversion"]
+        if "expectedResult" in properties:
+            try:
+                self.expectPass = not (properties["expectedResult"].upper().strip() == "FAIL")
+            except:
+                self.can_run = False
+                print "ERROR: '%s' is not a valid value for expectedResult" %\
+                        properties["expectedResult"]
 
     def __parse_config(self):
         test_config = "%s/test-config.yaml" % self.test_name

Modified: asterisk/trunk/tests/apps/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/tests.yaml?view=diff&rev=1833&r1=1832&r2=1833
==============================================================================
--- asterisk/trunk/tests/apps/tests.yaml (original)
+++ asterisk/trunk/tests/apps/tests.yaml Thu Aug 11 16:11:33 2011
@@ -3,3 +3,4 @@
     - test: 'directory_operator_exit'
     - test: 'directory_context_operator_exit'
     - test: 'directory_attendant_exit'
+    - dir: 'voicemail'

Added: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/extensions.conf?view=auto&rev=1833
==============================================================================
--- asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/extensions.conf Thu Aug 11 16:11:33 2011
@@ -1,0 +1,52 @@
+; Accepts a voicemail message and tests that the voicemail application returned successfully.
+; Exiting out to any other context is a failure.
+;
+
+[voicemail]
+
+;
+; Note that this one uses the unavailable message
+;
+exten => 1234,1,NoOp()
+    same => n,VoiceMail(1234 at default,u)
+    same => n,GotoIf($[${VMSTATUS} = SUCCESS]?pass:fail)
+    same => n(fail),UserEvent(TestResult,result: fail, status: VoiceMail failed to exit successfully - returned ${VMSTATUS})
+    same => n,Hangup()
+    same => n(pass),NoOp()
+    same => n,UserEvent(TestResult,result: pass, status: VoiceMail exited successfully)
+    same => n,Hangup()
+
+;
+; Note that this one uses the busy message
+;
+exten => 5678,1,NoOp()
+    same => n,VoiceMail(5678 at default,b)
+    same => n,GotoIf($[${VMSTATUS} = SUCCESS]?pass:fail)
+    same => n(fail),UserEvent(TestResult,result: fail, status: VoiceMail failed to exit successfully - returned ${VMSTATUS})
+    same => n,Hangup()
+    same => n(pass),NoOp()
+    same => n,UserEvent(TestResult,result: pass, status: VoiceMail exited successfully)
+    same => n,Hangup()
+
+;
+; Note that this one uses no special message code, and should default to unavailable.
+; It also tests delivering messages to a different context.
+;
+exten => 9000,1,NoOp()
+    same => n,VoiceMail(1234 at notdefault)
+    same => n,GotoIf($[${VMSTATUS} = SUCCESS]?pass:fail)
+    same => n(fail),UserEvent(TestResult,result: fail, status: VoiceMail failed to exit successfully - returned ${VMSTATUS})
+    same => n,Hangup()
+    same => n(pass),NoOp()
+    same => n,UserEvent(TestResult,result: pass, status: VoiceMail exited successfully)
+    same => n,Hangup()
+
+exten => o,1,UserEvent(TestResult,result: fail,status: failed to exit successfully through '#' key)
+
+exten => i,1,UserEvent(TestResult,result: fail,status: failed to exit successfully through '#' key)
+
+exten => e,1,UserEvent(TestResult,result: fail,status: failed to exit successfully through '#' key)
+
+exten => a,1,UserEvent(TestResult,result: fail,status: failed to exit successfully through '#' key)
+
+exten => t,1,UserEvent(TestResult,result: fail,status: failed to exit successfully through '#' key)

Propchange: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:mim-type = text/plain

Propchange: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/manager.general.conf.inc
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/manager.general.conf.inc?view=auto&rev=1833
==============================================================================
--- asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/manager.general.conf.inc (added)
+++ asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/manager.general.conf.inc Thu Aug 11 16:11:33 2011
@@ -1,0 +1,1 @@
+enabled = yes

Propchange: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/manager.general.conf.inc
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/manager.general.conf.inc
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/manager.general.conf.inc
------------------------------------------------------------------------------
    svn:mim-type = text/plain

Propchange: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/manager.general.conf.inc
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/sip.conf?view=auto&rev=1833
==============================================================================
--- asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/sip.conf (added)
+++ asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/sip.conf Thu Aug 11 16:11:33 2011
@@ -1,0 +1,52 @@
+[general]
+bindaddr = 127.0.0.1
+
+[ast2]
+type = friend
+context = voicemail
+fromuser = ast_server
+host = 127.0.0.2
+disallow = all
+allow = ulaw
+qualify = no
+insecure = invite
+
+[ast3]
+type = friend
+context = voicemail
+fromuser = ast_server
+host = 127.0.0.3
+disallow = all
+allow = ulaw
+qualify = no
+insecure = invite
+
+[ast4]
+type = friend
+context = voicemail
+fromuser = ast_server
+host = 127.0.0.4
+disallow = all
+allow = ulaw
+qualify = no
+insecure = invite
+
+[ast5]
+type = friend
+context = voicemail
+fromuser = ast_server
+host = 127.0.0.5
+disallow = all
+allow = ulaw
+qualify = no
+insecure = invite
+
+[ast6]
+type = friend
+context = voicemail
+fromuser = ast_server
+host = 127.0.0.6
+disallow = all
+allow = ulaw
+qualify = no
+insecure = invite

Propchange: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/sip.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/sip.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/sip.conf
------------------------------------------------------------------------------
    svn:mim-type = text/plain

Propchange: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/sip.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/voicemail.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/voicemail.conf?view=auto&rev=1833
==============================================================================
--- asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/voicemail.conf (added)
+++ asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/voicemail.conf Thu Aug 11 16:11:33 2011
@@ -1,0 +1,23 @@
+; Voicemail Configuration
+
+[general]
+format = ulaw|wav49|wav
+skipms = 3000
+maxsilence = 0
+silencethreshold = 128
+maxlogins = 3
+minsecs = 0
+
+[zonemessages]
+eastern = America/New_York|'vm-received' Q 'digits/at' IMp
+central = America/Chicago|'vm-received' Q 'digits/at' IMp
+central24 = America/Chicago|'vm-received' q 'digits/at' H N 'hours'
+military = Zulu|'vm-received' q 'digits/at' H N 'hours' 'phonetic/z_p'
+european = Europe/Copenhagen|'vm-received' a d b 'digits/at' HM
+
+[default]
+1234 => 1234,Mark Spencer
+5678 => 5678,Matt Jordan
+
+[notdefault]
+1234 => 1234,Paul Belanger

Propchange: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/voicemail.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/voicemail.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/voicemail.conf
------------------------------------------------------------------------------
    svn:mim-type = text/plain

Propchange: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast1/voicemail.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/extensions.conf?view=auto&rev=1833
==============================================================================
--- asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/extensions.conf (added)
+++ asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/extensions.conf Thu Aug 11 16:11:33 2011
@@ -1,0 +1,32 @@
+; Records a voicemail message using the audio file specified by the global
+; variable, TALK_AUDIO
+;
+; You may need to alter the Wait(10) statement if the audio prompt
+; played back by the receiver has a longer greeting then the default.
+
+[sendvoicemail]
+exten => 1234,1,NoOp()
+    same => n,Wait(10)
+    same => n,Verbose(1, Playing back ${TALK_AUDIO})
+    same => n,Playback(${TALK_AUDIO})
+    same => n,Verbose(1, Sending # key)
+    same => n,SendDTMF(#)
+    same => n,Wait(1)
+    same => n,Hangup()
+
+exten => 5678,1,NoOp()
+    same => n,Wait(10)
+    same => n,Verbose(1, Playing back ${TALK_AUDIO})
+    same => n,Playback(${TALK_AUDIO})
+    same => n,Verbose(1, Hanging up Abruptly)
+    same => n,Hangup()
+
+exten => 9000,1,NoOp()
+    same => n,Wait(10)
+    same => n,Verbose(1, Playing back ${TALK_AUDIO})
+    same => n,Playback(${TALK_AUDIO})
+    same => n,Verbose(1, Sending # key)
+    same => n,SendDTMF(#)
+    same => n,Wait(1)
+    same => n,Hangup()
+    

Propchange: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/extensions.conf
------------------------------------------------------------------------------
    svn:mim-type = text/plain

Propchange: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/manager.general.conf.inc
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/manager.general.conf.inc?view=auto&rev=1833
==============================================================================
--- asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/manager.general.conf.inc (added)
+++ asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/manager.general.conf.inc Thu Aug 11 16:11:33 2011
@@ -1,0 +1,2 @@
+enabled = yes
+bindaddr = 127.0.0.2

Propchange: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/manager.general.conf.inc
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/manager.general.conf.inc
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/manager.general.conf.inc
------------------------------------------------------------------------------
    svn:mim-type = text/plain

Propchange: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/manager.general.conf.inc
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/sip.conf?view=auto&rev=1833
==============================================================================
--- asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/sip.conf (added)
+++ asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/sip.conf Thu Aug 11 16:11:33 2011
@@ -1,0 +1,11 @@
+[general]
+bindaddr = 127.0.0.2
+
+[ast1]
+type = friend
+fromuser = ast2
+host = 127.0.0.1
+disallow = all
+allow = ulaw
+qualify = no
+insecure = invite

Propchange: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/sip.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/sip.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/sip.conf
------------------------------------------------------------------------------
    svn:mim-type = text/plain

Propchange: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/sip.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/run-test?view=auto&rev=1833
==============================================================================
--- asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/run-test (added)
+++ asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/run-test Thu Aug 11 16:11:33 2011
@@ -1,0 +1,129 @@
+#!/usr/bin/env python
+# vim: sw=3 et:
+'''
+Copyright (C) 2011, 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 sys
+import os
+import datetime
+
+from datetime import datetime
+from twisted.internet import reactor
+
+sys.path.append("lib/python")
+sys.path.append("tests/apps/voicemail")
+
+from asterisk.asterisk import Asterisk
+from asterisk.TestCase import TestCase
+from asterisk.voicemail import VoiceMailMailboxManagement
+
+class LeaveVoicemailNominal(TestCase):
+
+    """The parent directory that this test resides in
+    """
+    testParentDir = "tests/apps/voicemail"
+
+    def __init__(self, argv):
+        TestCase.__init__(self, argv)
+
+        self.create_asterisk(2)
+
+
+    def ami_connect(self, ami):
+        print str(datetime.now()) + " Got AMI Connect for instance " + str(ami.id)
+        TestCase.ami_connect(self, ami)
+
+        self.audioFile = os.path.join(os.getcwd(), "%s/sounds/talking" % (self.testParentDir))
+
+        ami.registerEvent('UserEvent', self.user_event)
+
+        if not (ami.id == 0):
+            self.ast[ami.id].cli_exec("dialplan set global TALK_AUDIO " + self.audioFile)
+
+            extensions = [1234,1234,5678,5678,9000]
+            for extension in extensions:
+                print str(datetime.now()) + " Originating call to sip/ast1/" + str(extension)
+                df = ami.originate("sip/ast1/" + str(extension), "sendvoicemail", str(extension), 1, None, "CallId-" + str(extension), None, None, None, {}, True )
+                df.addErrback(self.handleOriginateFailure)
+
+
+    def handleOriginateFailure(self, reason):
+        print str(datetime.now()) + " error sending originate:"
+        print reason.getTraceback()
+        self.stop_reactor()
+
+        return reason
+
+
+    def user_event(self, ami, event):
+        if event['userevent'] != 'TestResult':
+            return
+
+        if event['result'] == "pass":
+            self.passed = True
+            print str(datetime.now()) + " VoiceMail successfully exited"
+        else:
+            print str(datetime.now()) + " VoiceMail did not successfully exit:"
+            print str(datetime.now()) + " result: %s" % (event['result'],)
+            print str(datetime.now()) + " error: %s" % (event['error'],)
+
+        self.stop_reactor()
+
+
+    def run(self):
+        TestCase.run(self)
+        self.create_ami_factory(2)
+
+
+def main(argv = sys.argv):
+
+    test = LeaveVoicemailNominal(argv)
+    voicemailManager = VoiceMailMailboxManagement(test.ast[0])
+
+    test.start_asterisk()
+
+    reactor.run()
+
+    test.stop_asterisk()
+
+    """
+    Verify that all of the voicemails we expect to be created were created.  That would be:
+    Two voicemails in default/1234
+    Two voicemails in default/5678
+    One voicemail in notdefault/1234
+    All voicemails should have formats ulaw|wav49|wav
+    """
+    if test.passed:
+        formats = ["ulaw","wav","WAV"]
+        if not voicemailManager.checkVoicemailExists("default","1234",0,formats):
+            print str(datetime.now()) + " Failed to find voicemail 0 for default/1234"
+            test.passed = 0
+
+        if not voicemailManager.checkVoicemailExists("default","1234",1,formats):
+            print str(datetime.now()) + " Failed to find voicemail 1 for default/1234"
+            test.passed = 0
+
+        if not voicemailManager.checkVoicemailExists("default","5678",0,formats):
+            print str(datetime.now()) + " Failed to find voicemail 0 for default/5678"
+            test.passed = 0
+
+        if not voicemailManager.checkVoicemailExists("default","5678",1,formats):
+            print str(datetime.now()) + " Failed to find voicemail 0 for default/5678"
+            test.passed = 0
+
+        if not voicemailManager.checkVoicemailExists("notdefault","1234",0,formats):
+            print str(datetime.now()) + " Failed to find voicemail 0 for notdefault/1234"
+            test.passed = 0
+
+    if not test.passed:
+        return 1
+
+    return 0
+
+if __name__ == "__main__":
+   sys.exit(main() or 0)

Propchange: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/run-test
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/run-test
------------------------------------------------------------------------------
    svn:executable = *

Propchange: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/run-test
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/run-test
------------------------------------------------------------------------------
    svn:mim-type = text/plain

Propchange: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/run-test
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/test-config.yaml?view=auto&rev=1833
==============================================================================
--- asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/test-config.yaml (added)
+++ asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/test-config.yaml Thu Aug 11 16:11:33 2011
@@ -1,0 +1,14 @@
+testinfo:
+    summary: 'Test nominal execution of app_voicemails VoiceMail dialplan application'
+    description: |
+        This test verifies proper functionality of an operator leaving a voicemail.  It verifies
+        a bare-bones voicemail, wherein app_voicemail plays back a default greeting, records
+        a voicemail on the filesystem, and hangs up on the caller when the caller presses the pound
+        key or hangs up.
+
+properties:
+    minversion: '1.8'
+    dependencies:
+        - python : 'twisted'
+        - python : 'starpy'
+

Propchange: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native


[... 57 lines stripped ...]



More information about the asterisk-commits mailing list