[asterisk-commits] mjordan: testsuite/asterisk/trunk r3854 - /asterisk/trunk/lib/python/asterisk/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jun 14 06:37:23 CDT 2013


Author: mjordan
Date: Fri Jun 14 06:37:10 2013
New Revision: 3854

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=3854
Log:
Allow headers to not exist when performing condition matching

If a header match AMI instance attempts to match a header not in the
event, simply fail the matching. Keys have to exist in order to
match their values.

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

Modified: asterisk/trunk/lib/python/asterisk/ami.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/ami.py?view=diff&rev=3854&r1=3853&r2=3854
==============================================================================
--- asterisk/trunk/lib/python/asterisk/ami.py (original)
+++ asterisk/trunk/lib/python/asterisk/ami.py Fri Jun 14 06:37:10 2013
@@ -171,7 +171,11 @@
 
     def event_callback(self, ami, event):
         for k,v in self.match_requirements.items():
-            if not re.match(v, event.get(k.lower())):
+            if k.lower() not in event:
+                logger.warning("Requirement %s does not exist in event %s" %
+                                (k, event['event']))
+                self.passed = False
+            elif not re.match(v, event.get(k.lower())):
                 logger.warning("Requirement %s: %s does not match %s: %s in event" %
                         (k, v, k, event.get(k.lower())))
                 self.passed = False
@@ -180,7 +184,11 @@
                         (k, v, k, event.get(k.lower())))
 
         for k,v in self.nonmatch_requirements.items():
-            if re.match(v, event.get(k.lower(), '')):
+            if k.lower() not in event:
+                logger.warning("Requirement %s does not exist in event %s" %
+                                (k, event['event']))
+                self.passed = False
+            elif re.match(v, event.get(k.lower(), '')):
                 logger.warning("Requirement %s: %s matches %s: %s in event" %
                         (k, v, k, event.get(k.lower(), '')))
                 self.passed = False
@@ -221,7 +229,11 @@
             return
 
         for k,v in self.match_requirements[self.match_index].items():
-            if not re.match(v, event.get(k.lower())):
+            if k.lower() not in event:
+                logger.warning("Requirement %s does not exist in event %s" %
+                                (k, event['event']))
+                self.passed = False
+            elif not re.match(v, event.get(k.lower())):
                 logger.warning("Requirement %s: %s does not match %s: %s in event" %
                         (k, v, k, event.get(k.lower())))
                 self.passed = False
@@ -230,7 +242,11 @@
                         (k, v, k, event.get(k.lower())))
 
         for k,v in self.nonmatch_requirements[self.match_index].items():
-            if re.match(v, event.get(k.lower(), '')):
+            if k.lower() not in event:
+                logger.warning("Requirement %s does not exist in event %s" %
+                                (k, event['event']))
+                self.passed = False
+            elif re.match(v, event.get(k.lower(), '')):
                 logger.warning("Requirement %s: %s matches %s: %s in event" %
                         (k, v, k, event.get(k.lower(), '')))
                 self.passed = False




More information about the asterisk-commits mailing list