[asterisk-commits] dlee: testsuite/asterisk/trunk r4086 - /asterisk/trunk/tests/fastagi/control-...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Aug 27 13:26:42 CDT 2013


Author: dlee
Date: Tue Aug 27 13:26:38 2013
New Revision: 4086

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=4086
Log:
testsuite: Fix fastagi/control-stream-file for Asterisk 12

Asterisk 12 changes the response of AGI 'control stream file' to include
the endpos of where the playback stopped.

StarPy [has a patch][1] to take this into account. This patch corrects
the corresponding test in the TestSuite.

In addition to fixing the test:
 * print statements were replaced with logging
 * clarified the logic for handling the response to controlStreamFile().

 [1]: https://github.com/asterisk/starpy/pull/23

(closes issue ASTERISK-22322)
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/2789/


Modified:
    asterisk/trunk/tests/fastagi/control-stream-file/run-test

Modified: asterisk/trunk/tests/fastagi/control-stream-file/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/fastagi/control-stream-file/run-test?view=diff&rev=4086&r1=4085&r2=4086
==============================================================================
--- asterisk/trunk/tests/fastagi/control-stream-file/run-test (original)
+++ asterisk/trunk/tests/fastagi/control-stream-file/run-test Tue Aug 27 13:26:38 2013
@@ -7,12 +7,16 @@
 the GNU General Public License Version 2.
 '''
 
+import logging
 import sys
+
 from twisted.internet import reactor
 
 sys.path.append("lib/python")
 from asterisk.asterisk import Asterisk
 from asterisk.TestCase import TestCase
+
+LOGGER = logging.getLogger(__name__)
 
 
 class FastAGIControlStreamFileTest(TestCase):
@@ -23,30 +27,29 @@
         self.create_fastagi_factory()
 
     def on_failure(self, reason):
-        print 'Could not run CONTROL STREAM FILE: ', reason.getTraceback()
+        LOGGER.error('Could not run CONTROL STREAM FILE: ', reason.getTraceback())
         self.agi.finish()
 
     # result of 0 indicates success
     def finish_test(self, result):
-        if result is "0":
-            self.passed = True
-
-        self.result_changed()
+        LOGGER.debug("Finished.")
+        try:
+            if result[0] == 0 and result[1] is None or result[1] == -1:
+                self.passed = True
+            else:
+                LOGGER.error("Unexpected result '%r'", result)
+        finally:
+            self.stop_reactor()
 
     def fastagi_connect(self, agi):
         self.agi = agi
-        print "Connection established."
+        LOGGER.debug("Connection established.")
         return agi.controlStreamFile("beep", "").addCallback(
             self.finish_test)
 
     def launch_test(self):
-        print "Originating call to begin test."
+        LOGGER.debug("Originating call to begin test.")
         self.ast[0].cli_originate("Local/504 at agitest extension echo at agitest")
-
-    # Read result before timeout
-    def result_changed(self):
-        if self.passed is True:
-            self.stop_reactor()
 
     def run(self):
         TestCase.run(self)




More information about the asterisk-commits mailing list