[asterisk-commits] mjordan: branch mjordan/voicemail_tests_082811 r2068 - in /asterisk/team/mjor...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Sep 2 14:54:13 CDT 2011


Author: mjordan
Date: Fri Sep  2 14:54:09 2011
New Revision: 2068

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=2068
Log:
Local channel testing

Modified:
    asterisk/team/mjordan/voicemail_tests_082811/lib/python/asterisk/TestCase.py
    asterisk/team/mjordan/voicemail_tests_082811/lib/python/asterisk/voicemail.py
    asterisk/team/mjordan/voicemail_tests_082811/tests/apps/voicemail/check_voicemail_nominal/configs/ast1/extensions.conf
    asterisk/team/mjordan/voicemail_tests_082811/tests/apps/voicemail/check_voicemail_nominal/run-test

Modified: asterisk/team/mjordan/voicemail_tests_082811/lib/python/asterisk/TestCase.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mjordan/voicemail_tests_082811/lib/python/asterisk/TestCase.py?view=diff&rev=2068&r1=2067&r2=2068
==============================================================================
--- asterisk/team/mjordan/voicemail_tests_082811/lib/python/asterisk/TestCase.py (original)
+++ asterisk/team/mjordan/voicemail_tests_082811/lib/python/asterisk/TestCase.py Fri Sep  2 14:54:09 2011
@@ -117,6 +117,7 @@
         """
 
         """
+        logger.info("Setting reactor to timeout")
         reactor.callLater(self.reactor_timeout, self.stop_reactor)
 
     def ami_login_error(self, ami):
@@ -127,3 +128,12 @@
         logger.info("AMI Connect instance %s" % (ami.id + 1))
         self.ami[ami.id] = ami
 
+    """
+    Default handler for originate failures
+    """
+    def defaultHandleOriginateFailure(self, reason):
+        logger.error("Error sending originate:")
+        logger.error(reason.getTraceback())
+        self.stop_reactor()
+
+        return reason

Modified: asterisk/team/mjordan/voicemail_tests_082811/lib/python/asterisk/voicemail.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mjordan/voicemail_tests_082811/lib/python/asterisk/voicemail.py?view=diff&rev=2068&r1=2067&r2=2068
==============================================================================
--- asterisk/team/mjordan/voicemail_tests_082811/lib/python/asterisk/voicemail.py (original)
+++ asterisk/team/mjordan/voicemail_tests_082811/lib/python/asterisk/voicemail.py Fri Sep  2 14:54:09 2011
@@ -71,7 +71,8 @@
     """
     The default expected channel to be used to send info to the voicemail server
     """
-    defaultSenderChannel = "SIP/ast1-00000000"
+    #defaultSenderChannel = "SIP/ast1-00000000"
+    defaultSenderChannel = "Local/8052 at voicemail"
 
     def __init__(self):
         TestCase.__init__(self)
@@ -81,6 +82,21 @@
         self.astSender = None
         self.__testConditions = {}
         self.senderChannel = VoiceMailTest.defaultSenderChannel
+        self.channelAssigned = False
+
+    def ami_connect(self, ami):
+        super(VoiceMailTest, self).ami_connect(ami)
+        logger.info("Registering for Newchannel event")
+        """ Register for the Newchannel event to get the proper channel name """
+        ami.registerEvent('Newchannel', self.newChannelHandler)
+
+    def newChannelHandler(self, ami, event):
+        if event['event'] != 'Newchannel' or self.channelAssigned == True:
+            return
+
+        channel = event['channel']
+        logger.debug("Changing channel name to: " + channel)
+        self.senderChannel = channel
 
     """
     Create the test controller.  Should be called once amiReceiver and amiSender have both been set

Modified: asterisk/team/mjordan/voicemail_tests_082811/tests/apps/voicemail/check_voicemail_nominal/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mjordan/voicemail_tests_082811/tests/apps/voicemail/check_voicemail_nominal/configs/ast1/extensions.conf?view=diff&rev=2068&r1=2067&r2=2068
==============================================================================
--- asterisk/team/mjordan/voicemail_tests_082811/tests/apps/voicemail/check_voicemail_nominal/configs/ast1/extensions.conf (original)
+++ asterisk/team/mjordan/voicemail_tests_082811/tests/apps/voicemail/check_voicemail_nominal/configs/ast1/extensions.conf Fri Sep  2 14:54:09 2011
@@ -22,3 +22,17 @@
 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)
+
+[voicemailCaller]
+
+exten => sendDTMF,1,NoOp()
+	same => n,Verbose(1, Sending DTMF Signal ${DTMF_TO_SEND})
+	same => n,SendDTMF(${DTMF_TO_SEND})
+	same => n,Goto(voicemailCaller,wait,1)
+
+exten => hangup,1,NoOp()
+	same => n,Verbose(1, Hanging up)
+	same => n,Hangup()
+
+exten => wait,1,NoOp()
+	same => n,Wait(10000)

Modified: asterisk/team/mjordan/voicemail_tests_082811/tests/apps/voicemail/check_voicemail_nominal/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mjordan/voicemail_tests_082811/tests/apps/voicemail/check_voicemail_nominal/run-test?view=diff&rev=2068&r1=2067&r2=2068
==============================================================================
--- asterisk/team/mjordan/voicemail_tests_082811/tests/apps/voicemail/check_voicemail_nominal/run-test (original)
+++ asterisk/team/mjordan/voicemail_tests_082811/tests/apps/voicemail/check_voicemail_nominal/run-test Fri Sep  2 14:54:09 2011
@@ -263,7 +263,7 @@
     """
     The channel to connect to that acts as the voicemail server
     """
-    channel = "sip/ast1/8052"
+    channel = "Local/8052 at voicemail"
 
     """
     The voicemail manager object
@@ -271,7 +271,7 @@
     voicemailManager = None
 
     def __init__(self):
-        VoiceMailTest.__init__(self)
+        super(CheckVoicemailNominal, self).__init__()
 
         """
         Add our test conditions to the test - these will help us verify through the
@@ -296,62 +296,51 @@
         self.addTestCondition("savedMessages", TestCondition(checkSavedMessages, 0))
 
         self.reactor_timeout = 120
-        self.create_asterisk(2)
+        self.create_asterisk()
 
     def ami_connect(self, ami):
-        logger.debug("Got AMI Connect for instance " + str(ami.id))
-        TestCase.ami_connect(self, ami)
+        logger.debug("BLAH")
+        super(CheckVoicemailNominal, self).ami_connect(ami)
+        logger.debug("BLAH")
 
         """ Record which AMI instance we've received and attempt to set up the test controller """
-        if (ami.id == 0):
-            self.amiReceiver = ami
-        elif (ami.id == 1):
-            self.amiSender = ami
-            self.astSender = self.ast[self.amiSender.id]
-
+        self.amiReceiver = ami
+        self.amiSender = ami
+        self.astSender = self.ast[self.amiSender.id]
+        logger.debug("BLAH")
         self.createTestController()
         if (self.testStateController != None):
             startObject = StartVoiceMailState(self.testStateController, self)
             self.testStateController.changeState(startObject)
             self.testStateController.addAssertHandler(self.handleAssert)
-
-        """ Now do specific processing on the AMI instances """
-        if (ami.id == 0):
-
-            ami.registerEvent('UserEvent', self.user_event)
-
-            """
-            Create some dummy voicemails in a valid voicemailbox - 1 urgent, 2 new, 2 old
-            """
-            self.voicemailManager = VoiceMailMailboxManagement(self.ast[0])
-            self.voicemailManager.createMailbox("default", "1234", True)
-
-            logger.debug("Creating dummy voicemails")
-            for i in range(0, 2):
-                if not self.voicemailManager.createDummyVoicemail("default","1234", self.voicemailManager.inboxFolderName, i, self.formats):
-                    logger.error("Failed to create voicemails in folder " + self.voicemailManager.inboxFolderName)
-                    self.stop_reactor()
-            for i in range(0, 1):
-                if not self.voicemailManager.createDummyVoicemail("default", "1234", self.voicemailManager.urgentFolderName, i, self.formats):
-                    logger.error("Failed to create voicemails in folder " + self.voicemailManager.urgentFolderName)
-                    self.stop_reactor()
-            for i in range(0, 2):
-                if not self.voicemailManager.createDummyVoicemail("default", "1234", self.voicemailManager.oldFolderName, i, self.formats):
-                    logger.error("Failed to create voicemails in folder " + self.voicemailManager.oldFolderName)
-                    self.stop_reactor()
-        else:
-            logger.debug("Originating call to " + self.channel)
-            df = ami.originate(self.channel, "voicemailCaller", "wait", 1)
-            df.addErrback(self.handleOriginateFailure)
-
-    def handleOriginateFailure(self, reason):
-        logger.error("Error sending originate:")
-        logger.error(reason.getTraceback())
-        self.stop_reactor()
-
-        return reason
-
-    def handleAssert(self, event):
+        logger.debug("BLAH")
+        ami.registerEvent('UserEvent', self.user_event)
+        logger.debug("BLAH")
+        """
+        Create some dummy voicemails in a valid voicemailbox - 1 urgent, 2 new, 2 old
+        """
+        self.voicemailManager = VoiceMailMailboxManagement(self.ast[0])
+        self.voicemailManager.createMailbox("default", "1234", True)
+
+        logger.debug("Creating dummy voicemails")
+        for i in range(0, 2):
+            if not self.voicemailManager.createDummyVoicemail("default","1234", self.voicemailManager.inboxFolderName, i, self.formats):
+                logger.error("Failed to create voicemails in folder " + self.voicemailManager.inboxFolderName)
+                self.stop_reactor()
+        for i in range(0, 1):
+            if not self.voicemailManager.createDummyVoicemail("default", "1234", self.voicemailManager.urgentFolderName, i, self.formats):
+                logger.error("Failed to create voicemails in folder " + self.voicemailManager.urgentFolderName)
+                self.stop_reactor()
+        for i in range(0, 2):
+            if not self.voicemailManager.createDummyVoicemail("default", "1234", self.voicemailManager.oldFolderName, i, self.formats):
+                logger.error("Failed to create voicemails in folder " + self.voicemailManager.oldFolderName)
+                self.stop_reactor()
+
+        logger.debug("Originating call to " + self.channel)
+        df = ami.originate(self.channel, "voicemailCaller", "wait", 1)
+        df.addErrback(self.defaultHandleOriginateFailure)
+
+    def handleAssert(self, ami, event):
         self.passed = False
         logger.error("Test Failed - Assert received")
         logger.error("\t\t AppFunction: " + event['appfunction'])
@@ -376,8 +365,8 @@
 
 
     def run(self):
-        TestCase.run(self)
-        self.create_ami_factory(2)
+        super(CheckVoicemailNominal, self).run()
+        self.create_ami_factory()
 
 
 def main():




More information about the asterisk-commits mailing list