[asterisk-commits] mmichelson: branch mmichelson/bridge-tests r3307 - in /asterisk/team/mmichels...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jul 10 08:40:56 CDT 2012


Author: mmichelson
Date: Tue Jul 10 08:40:52 2012
New Revision: 3307

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=3307
Log:
Address comments made by Matt Jordan on review 2013.


Added:
    asterisk/team/mmichelson/bridge-tests/sample-yaml/
    asterisk/team/mmichelson/bridge-tests/sample-yaml/ami-config.yaml.sample
      - copied unchanged from r3302, asterisk/team/mmichelson/bridge-tests/lib/python/asterisk/ami-config.yaml.sample
Removed:
    asterisk/team/mmichelson/bridge-tests/lib/python/asterisk/ami-config.yaml.sample
Modified:
    asterisk/team/mmichelson/bridge-tests/lib/python/asterisk/TestRunner.py
    asterisk/team/mmichelson/bridge-tests/lib/python/asterisk/ami.py

Modified: asterisk/team/mmichelson/bridge-tests/lib/python/asterisk/TestRunner.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mmichelson/bridge-tests/lib/python/asterisk/TestRunner.py?view=diff&rev=3307&r1=3306&r2=3307
==============================================================================
--- asterisk/team/mmichelson/bridge-tests/lib/python/asterisk/TestRunner.py (original)
+++ asterisk/team/mmichelson/bridge-tests/lib/python/asterisk/TestRunner.py Tue Jul 10 08:40:52 2012
@@ -183,6 +183,11 @@
         test_object_config = test_config[test_object_spec['config-section']]
     else:
         test_object_config = test_config
+
+    if ('load-from-test' in test_object_spec and
+            test_object_spec['load-from-test']):
+        TestModuleFinder.supported_paths.append(test_path)
+        sys.path.append(test_path)
 
     # The test object must support injection of its location as a parameter
     # to the constructor, and its test-configuration object (or the full test

Modified: asterisk/team/mmichelson/bridge-tests/lib/python/asterisk/ami.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mmichelson/bridge-tests/lib/python/asterisk/ami.py?view=diff&rev=3307&r1=3306&r2=3307
==============================================================================
--- asterisk/team/mmichelson/bridge-tests/lib/python/asterisk/ami.py (original)
+++ asterisk/team/mmichelson/bridge-tests/lib/python/asterisk/ami.py Tue Jul 10 08:40:52 2012
@@ -8,6 +8,13 @@
 logger = logging.getLogger(__name__)
 
 class AMIEventInstance(object):
+    ''' 
+    Base class for specific instances of AMI event observers
+
+    This handles common elements for both headermatch and callback
+    types of AMI event observers, allowing the individual types
+    to focus on their specific duties.
+    '''
     def __init__(self, instance_config, test_object):
         self.test_object = test_object
         self.match_conditions = instance_config['conditions']['match']
@@ -48,12 +55,17 @@
             ami.registerEvent(self.match_conditions['Event'], self.__event_callback)
 
     def event_callback(self, ami, event):
-        """Virtual method overridden by specific AMI Event
-        instance types"""
+        '''
+        Virtual method overridden by specific AMI Event
+        instance types
+        '''
+        pass
 
     def __event_callback(self, ami, event):
-        """Check event conditions to see if subclasses should
-        be called into"""
+        '''
+        Check event conditions to see if subclasses should
+        be called into
+        '''
 
         for k,v in self.match_conditions.items():
             if not re.match(v, event.get(k.lower())):
@@ -83,10 +95,13 @@
 
     def check_result(self, callback_param):
         '''Virtual method to be overridden by subclasses'''
+        pass
 
     def __check_result(self, callback_param):
-        '''This will check against event counts and the like and then
-        call into overridden veresions'''
+        '''
+        This will check against event counts and the like and then
+        call into overridden veresions
+        '''
         if (self.event_count > self.count_max
                 or self.event_count < self.count_min):
             logger.warning("Event occurred %d times, which is out of the"
@@ -96,6 +111,11 @@
         return self.check_result(callback_param)
 
 class AMIHeaderMatchInstance(AMIEventInstance):
+    '''
+    A subclass of AMIEventInstance that operates by matching headers of
+    AMI events to expected values. If a header does not match its expected
+    value, then the test will fail
+    '''
     def __init__(self, instance_config, test_object):
         super(AMIHeaderMatchInstance, self).__init__(instance_config, test_object)
         logger.debug("Initializing an AMIHeaderMatchInstance")
@@ -130,6 +150,11 @@
         return callback_param
 
 class AMICallbackInstance(AMIEventInstance):
+    '''
+    Subclass of AMIEventInstance that operates by calling a user-defined
+    callback function. The callback function returns the current disposition
+    of the test (i.e. whether the test is currently passing or failing).
+    '''
     def __init__(self, instance_config, test_object):
         super(AMICallbackInstance, self).__init__(instance_config, test_object)
         self.callback_module = instance_config['callback_module']
@@ -161,7 +186,7 @@
                     instance_type)
             raise Exception
 
-class AMIEvent(object):
+class AMIEventModule(object):
     def __init__(self, module_config, test_object):
         logger.debug("Initializing AMIEvent module")
         self.test_object = test_object




More information about the asterisk-commits mailing list