[asterisk-commits] dlee: testsuite/asterisk/trunk r4284 - in /asterisk/trunk: lib/python/asteris...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Oct 25 11:34:51 CDT 2013


Author: dlee
Date: Fri Oct 25 11:34:48 2013
New Revision: 4284

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=4284
Log:
Test ARI subscription support.

This patch also improves the logging from ari.py.

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

Added:
    asterisk/trunk/tests/rest_api/applications/
      - copied from r4283, asterisk/team/dlee/ASTERISK-22451-ari-subscribe-tests/tests/rest_api/applications/
Modified:
    asterisk/trunk/lib/python/asterisk/ari.py
    asterisk/trunk/tests/rest_api/tests.yaml

Modified: asterisk/trunk/lib/python/asterisk/ari.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/ari.py?view=diff&rev=4284&r1=4283&r2=4284
==============================================================================
--- asterisk/trunk/lib/python/asterisk/ari.py (original)
+++ asterisk/trunk/lib/python/asterisk/ari.py Fri Oct 25 11:34:48 2013
@@ -207,8 +207,12 @@
         :param event: Dictionary parsed from incoming JSON event.
         '''
         LOGGER.debug('Received event: %r' % event.get('type'))
+        matched = False
         for matcher in self.event_matchers:
-            matcher.on_event(event)
+            if matcher.on_event(event):
+                matched = True
+        if not matched:
+            LOGGER.info('Event had no matcher: %r' % event)
 
 
 class AriClientFactory(WebSocketClientFactory):
@@ -382,7 +386,8 @@
         :param resp: requests.models.Response object
         :returns: resp
         '''
-        if not self.allow_errors:
+        if not self.allow_errors and resp.status_code / 100 != 2:
+            LOGGER.error('%s (%d %s): %r' % (resp.url, resp.status_code, resp.reason, resp.text))
             resp.raise_for_status()
         return resp
 
@@ -418,7 +423,9 @@
             # Split call and accumulation to always call the callback
             try:
                 res = self.callback(self.ari, message)
-                if not res:
+                if res:
+                    return True
+                else:
                     LOGGER.error("Callback failed: %r" %
                                  self.instance_config)
                     self.passed = False
@@ -426,6 +433,7 @@
                 LOGGER.error("Exception in callback: %s" %
                              traceback.format_exc())
                 self.passed = False
+        return False
 
     def on_stop(self, *args):
         '''Callback for the end of the test.
@@ -433,7 +441,8 @@
         :param args: Ignored arguments.
         '''
         if not self.count_range.contains(self.count):
-            LOGGER.error("Expected %d <= count <= %d; was %d (%r)",
+            # max could be int or float('inf'); format with %r
+            LOGGER.error("Expected %d <= count <= %r; was %d (%r)",
                          self.count_range.min, self.count_range.max,
                          self.count, self.conditions)
             self.passed = False

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=4284&r1=4283&r2=4284
==============================================================================
--- asterisk/trunk/tests/rest_api/tests.yaml (original)
+++ asterisk/trunk/tests/rest_api/tests.yaml Fri Oct 25 11:34:48 2013
@@ -3,4 +3,5 @@
     - test: 'continue'
     - test: 'authentication'
     - test: 'CORS'
+    - dir:  'applications'
     - dir:  'bridges'




More information about the asterisk-commits mailing list