[asterisk-commits] pabelanger: branch group/cdr_test_log_congestion r2040 - in /asterisk/team/gr...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Aug 30 16:23:35 CDT 2011


Author: pabelanger
Date: Tue Aug 30 16:23:31 2011
New Revision: 2040

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=2040
Log:
Updates and documentation

Modified:
    asterisk/team/group/cdr_test_log_congestion/lib/python/asterisk/CDRTestCase.py
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_originate_sip_congestion_log/run-test

Modified: asterisk/team/group/cdr_test_log_congestion/lib/python/asterisk/CDRTestCase.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/group/cdr_test_log_congestion/lib/python/asterisk/CDRTestCase.py?view=diff&rev=2040&r1=2039&r2=2040
==============================================================================
--- asterisk/team/group/cdr_test_log_congestion/lib/python/asterisk/CDRTestCase.py (original)
+++ asterisk/team/group/cdr_test_log_congestion/lib/python/asterisk/CDRTestCase.py Tue Aug 30 16:23:31 2011
@@ -22,27 +22,41 @@
     """
     CDRTestCase is a subclass of the Asterisk TestCase intended to make tests involving CDR files easier.
 
-    This test is used like the regular TestCase class, but includes additional functions for loading an
-    expectation list by asterisk index and AsteriskCSVCDRLine as well as for matching against all
-    CDRLineExpectations currently held by the class.
+    Example Usage:
+    class TestFoo(CDRTestCase):
+        def __init__(self):
+            TestCase.__init__(self):
+            self.add_expectation(AsteriskCSVCDRLine(
+                accountcode='',
+                source='',
+                destination='1',
+                dcontext='default',
+                callerid='',
+                channel='Local/1 at default-.*',
+                disposition='ANSWERED',
+                amaflags='DOCUMENTATION'
+            ))
+        def main():
+            test = TestFoo()
+            test.start_asterisk()
+            reactor.run()
+            test.stop_asterisk()
 
-    This class has a function, end(self) which can be overriden and used for any end of test evaluation.
-    Most commonly this will probably be used to analyze the CDR file and check for pass and failure
-    conditions.
+            return test.results()
     """
 
-    #2D array for storing CDR Expectations:
-    #index - ast to check against
-    #col 1 - Asterisk instance index (starting with 0)
-    #col 2 - AsteriskCSVCDRLine that goes with ast
     CDRLineExpectations = []
 
     def __init__(self):
+        """"
+        Create a single Asterisk instance.
+        """
         TestCase.__init__(self)
         self.create_asterisk()
 
     def add_expectation(self, cdrline):
-        """Add an expectation to the expectation list
+        """
+        Add an expectation to the expectation list
 
         Keyword Arguments:
         cdrline -- AsteriskCSVCDRLine for an expected element of the cdr
@@ -55,16 +69,7 @@
         """
         self.CDRLineExpectations.append([cdrline])
 
-
-    def match_cdrs(self):
-        """Test for Asterisk instances having CDR records that match their expectations
-
-        Returns:
-        boolean indicating match or mismatch
-
-        Example Usage:
-        does_match = self.match_cdrs()
-        """
+    def __match_cdrs(self):
 
         # We'll store the cdrlines for an individual instance of Asterisk in here
         records = []
@@ -82,10 +87,35 @@
         if cdr_expect.match(cdr_file):
             self.passed = True
 
+    def results(self):
+        """
+        Returns the test results.
+
+        Example Usage:
+        def foo(self):
+            test = bar()
+            test.start_asterisk()
+            reactor.run()
+            test.stop_asterisk()
+            return test.results()
+        """
+
+        self.__match_cdrs()
+        if self.passed == True:
+            return 0
+        return 1
+
     def ami_logoff(self, ami):
+        """
+        An AMI callback event.
+
+        """
         self.stop_reactor()
 
     def ami_connect(self, ami):
+        """
+        An AMI callback event from create_ami_factory() function.
+        """
         TestCase.ami_connect(self, ami)
         self.ami[0].originate(
             channel = 'Local/1 at default',
@@ -93,5 +123,8 @@
         ).addErrback(self.ami_logoff)
 
     def run(self):
+        """
+        Create an AMI factory with a calback for the ami_connect() function.
+        """
         TestCase.run(self)
         self.create_ami_factory()

Modified: asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_originate_sip_congestion_log/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_originate_sip_congestion_log/run-test?view=diff&rev=2040&r1=2039&r2=2040
==============================================================================
--- asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_originate_sip_congestion_log/run-test (original)
+++ asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_originate_sip_congestion_log/run-test Tue Aug 30 16:23:31 2011
@@ -46,7 +46,7 @@
     reactor.run()
     test.stop_asterisk()
 
-    return test.match_cdrs()
+    return test.results()
 
 if __name__ == '__main__':
     sys.exit(main())




More information about the asterisk-commits mailing list