[asterisk-commits] pabelanger: branch pabelanger/DialplanTestCase r1633 - in /asterisk/team/pabe...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jun 14 13:36:47 CDT 2011


Author: pabelanger
Date: Tue Jun 14 13:36:45 2011
New Revision: 1633

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=1633
Log:
Import example DialPlan test.

Added:
    asterisk/team/pabelanger/DialplanTestCase/tests/DialPlan/configs/
      - copied from r1632, asterisk/team/pabelanger/DialplanTestCase/tests/manager/login/configs/
    asterisk/team/pabelanger/DialplanTestCase/tests/DialPlan/configs/ast1/extensions.conf
      - copied, changed from r1632, asterisk/team/pabelanger/DialplanTestCase/tests/udptl/configs/ast2/extensions.conf
Modified:
    asterisk/team/pabelanger/DialplanTestCase/lib/python/asterisk/DialplanTestCase.py
    asterisk/team/pabelanger/DialplanTestCase/lib/python/asterisk/TestCase.py

Modified: asterisk/team/pabelanger/DialplanTestCase/lib/python/asterisk/DialplanTestCase.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/DialplanTestCase/lib/python/asterisk/DialplanTestCase.py?view=diff&rev=1633&r1=1632&r2=1633
==============================================================================
--- asterisk/team/pabelanger/DialplanTestCase/lib/python/asterisk/DialplanTestCase.py (original)
+++ asterisk/team/pabelanger/DialplanTestCase/lib/python/asterisk/DialplanTestCase.py Tue Jun 14 13:36:45 2011
@@ -17,5 +17,40 @@
 
 class DialplanTestCase(TestCase):
     def __init__(self, argv):
+        log.setLevel(logging.DEBUG)
         TestCase.__init__(self, argv)
         self.create_asterisk()
+
+    def run(self):
+        """
+
+        """
+        TestCase.run(self)
+        self.create_ami_factory()
+
+    def ami_connect(self, ami):
+        TestCase.ami_connect(self, ami)
+        self.ami[0].registerEvent("UserEvent", self.ami_UserEvent)
+        self.originate()
+
+    def originate(self):
+        self.ami[0].originate(
+                channel = "Local/s at DialContext",
+                exten = "s",
+                priority = "1",
+                context = "test"
+        )
+
+    def ami_UserEvent(self, ami, event):
+        if event.get("userevent") != "TestResult":
+            return
+        self.stop_reactor()
+
+        result = event.get("result")
+        if result  == "True":
+            self.passed = True
+            log.info('Test passed!')
+        else:
+            self.passed = False
+            log.info('Test passed!')
+

Modified: asterisk/team/pabelanger/DialplanTestCase/lib/python/asterisk/TestCase.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/DialplanTestCase/lib/python/asterisk/TestCase.py?view=diff&rev=1633&r1=1632&r2=1633
==============================================================================
--- asterisk/team/pabelanger/DialplanTestCase/lib/python/asterisk/TestCase.py (original)
+++ asterisk/team/pabelanger/DialplanTestCase/lib/python/asterisk/TestCase.py Tue Jun 14 13:36:45 2011
@@ -31,6 +31,8 @@
         argv --
 
         """
+        logging.basicConfig()
+        log.setLevel(logging.DEBUG)
         # get version info
         parser = OptionParser()
         parser.add_option("-v", "--version", dest="ast_version",
@@ -54,7 +56,7 @@
 
         """
         for c in range(count):
-            print "Creating Asterisk instance %d ..." % (c + 1)
+            log.debug("Creating Asterisk instance %d ..." % (c + 1))
             self.ast.append(Asterisk(base=self.options.base))
             self.ast[c].valgrind = self.options.valgrind
             # Copy shared config files
@@ -77,7 +79,7 @@
         for c in range(count):
             host = "127.0.0.%d" % (c + 1)
             self.ami.append(None)
-            print "Creating AMIFactory %d ..." % (c + 1)
+            log.debug("Creating AMIFactory %d ..." % (c + 1))
             self.ami_factory = manager.AMIFactory(username, secret, c)
             self.ami_factory.login(host).addCallbacks(self.ami_connect,
                     self.ami_login_error)
@@ -87,7 +89,7 @@
         for c in range(count):
             host = "127.0.0.%d" % (c + 1)
             self.fastagi.append(None)
-            print "Creating FastAGI Factory %d ..." % (c + 1)
+            log.debug("Creating FastAGI Factory %d ..." % (c + 1))
             self.fastagi_factory = fastagi.FastAGIFactory(self.fastagi_connect)
             reactor.listenTCP(4573, self.fastagi_factory,
                     self.reactor_timeout, host)
@@ -97,7 +99,7 @@
 
         """
         for index, item in enumerate(self.ast):
-            print "Starting Asterisk instance %d ..." % (index + 1)
+            log.debug("Starting Asterisk instance %d ..." % (index + 1))
             self.ast[index].start()
 
     def stop_asterisk(self):
@@ -105,14 +107,14 @@
 
         """
         for index, item in enumerate(self.ast):
-            print "Stopping Asterisk instance %d ..." % (index + 1)
+            log.debug("Stopping Asterisk instance %d ..." % (index + 1))
             self.ast[index].stop()
 
     def stop_reactor(self):
         """
 
         """
-        print "Stopping Reactor ..."
+        log.debug("Stopping Reactor ...")
         if reactor.running:
             reactor.stop()
 
@@ -123,10 +125,10 @@
         reactor.callLater(self.reactor_timeout, self.stop_reactor)
 
     def ami_login_error(self, ami):
-        print "Error logging into AMI"
+        log.error("Error logging into AMI")
         self.stop_reactor()
 
     def ami_connect(self, ami):
-        print "AMI Connect instance %s ..." % (ami.id + 1)
+        log.debug("AMI Connect instance %s ..." % (ami.id + 1))
         self.ami[ami.id] = ami
 

Copied: asterisk/team/pabelanger/DialplanTestCase/tests/DialPlan/configs/ast1/extensions.conf (from r1632, asterisk/team/pabelanger/DialplanTestCase/tests/udptl/configs/ast2/extensions.conf)
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/DialplanTestCase/tests/DialPlan/configs/ast1/extensions.conf?view=diff&rev=1633&p1=asterisk/team/pabelanger/DialplanTestCase/tests/udptl/configs/ast2/extensions.conf&r1=1632&p2=asterisk/team/pabelanger/DialplanTestCase/tests/DialPlan/configs/ast1/extensions.conf&r2=1633
==============================================================================
--- asterisk/team/pabelanger/DialplanTestCase/tests/udptl/configs/ast2/extensions.conf (original)
+++ asterisk/team/pabelanger/DialplanTestCase/tests/DialPlan/configs/ast1/extensions.conf Tue Jun 14 13:36:45 2011
@@ -1,8 +1,13 @@
-[facks]
-exten => 666,1,Answer()
-exten => 666,n,Wait(20)
-exten => 666,n,Hangup()
+[DialContext]
+exten => s,1,NoOp()
+    same => n,Answer()
+    same => n,Echo()
 
-exten => fax,1,ReceiveFax(recv.tiff)
+[test]
+exten => s,1,NoOp()
+    same => n,Answer()
+    same => n,Set(TestResult=True)
+    same => n,Hangup()
 
-exten => h,1,UserEvent(recvstatus, status: ${FAXSTATUS})
+exten => h,1,UserEvent(TestResult, result: ${TestResult})
+




More information about the asterisk-commits mailing list