[asterisk-commits] dlee: testsuite/asterisk/trunk r3891 - /asterisk/trunk/lib/python/asterisk/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jul 8 15:54:47 CDT 2013


Author: dlee
Date: Mon Jul  8 15:54:45 2013
New Revision: 3891

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=3891
Log:
Added a default matcher that would catch any WebSocket validation failures

Modified:
    asterisk/trunk/lib/python/asterisk/ari.py

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=3891&r1=3890&r2=3891
==============================================================================
--- asterisk/trunk/lib/python/asterisk/ari.py (original)
+++ asterisk/trunk/lib/python/asterisk/ari.py Mon Jul  8 15:54:45 2013
@@ -22,6 +22,18 @@
 logger = logging.getLogger(__name__)
 
 DEFAULT_PORT = 8088
+
+
+#: Default matcher to ensure we don't have any validation failures on the
+#  WebSocket
+ValidationMatcher = {
+    'conditions': {
+        'match': {
+            'error': "^InvalidMessage$"
+        }
+    },
+    'count': 0
+}
 
 
 class WebSocketEventModule(object):
@@ -47,6 +59,8 @@
         self.event_matchers = [
             EventMatcher(self.ari, e, test_object)
             for e in module_config['events']]
+        self.event_matchers.append(EventMatcher(self.ari, ValidationMatcher,
+                                                test_object))
         apps = module_config.get('apps') or 'testsuite'
         if isinstance(apps, list):
             apps = ','.join(apps)
@@ -187,7 +201,8 @@
         '''
         url = self.build_url(*args)
         logger.info("GET %s %r" % (url, kwargs))
-        return raise_on_err(requests.get(url, params=kwargs, auth=self.userpass))
+        return raise_on_err(requests.get(url, params=kwargs,
+                                         auth=self.userpass))
 
     def post(self, *args, **kwargs):
         '''Send a POST request to ARI.
@@ -199,7 +214,8 @@
         '''
         url = self.build_url(*args, **kwargs)
         logger.info("POST %s %r" % (url, kwargs))
-        return raise_on_err(requests.post(url, params=kwargs, auth=self.userpass))
+        return raise_on_err(requests.post(url, params=kwargs,
+                                          auth=self.userpass))
 
     def delete(self, *args, **kwargs):
         '''Send a DELETE request to ARI.
@@ -211,7 +227,8 @@
         '''
         url = self.build_url(*args, **kwargs)
         logger.info("DELETE %s %r" % (url, kwargs))
-        return raise_on_err(requests.delete(url, params=kwargs, auth=self.userpass))
+        return raise_on_err(requests.delete(url, params=kwargs,
+                                            auth=self.userpass))
 
 
 def raise_on_err(resp):




More information about the asterisk-commits mailing list