[asterisk-commits] pabelanger: branch pabelanger/testClass r1109 - in /asterisk/team/pabelanger/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Dec 8 14:14:00 CST 2010


Author: pabelanger
Date: Wed Dec  8 14:13:56 2010
New Revision: 1109

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=1109
Log:
Rename AsteriskTest to TestCase
Asterisk.base now set to /tmp/asterisk-testsuite
Pass commandline arguments to TestCase

Added:
    asterisk/team/pabelanger/testClass/lib/python/asterisk/TestCase.py
      - copied, changed from r1108, asterisk/team/pabelanger/testClass/lib/python/asterisk/AsteriskTest.py
Removed:
    asterisk/team/pabelanger/testClass/lib/python/asterisk/AsteriskTest.py
Modified:
    asterisk/team/pabelanger/testClass/lib/python/asterisk/__init__.py
    asterisk/team/pabelanger/testClass/lib/python/asterisk/asterisk.py
    asterisk/team/pabelanger/testClass/runtests.py
    asterisk/team/pabelanger/testClass/tests/manager/login/run-test

Copied: asterisk/team/pabelanger/testClass/lib/python/asterisk/TestCase.py (from r1108, asterisk/team/pabelanger/testClass/lib/python/asterisk/AsteriskTest.py)
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/testClass/lib/python/asterisk/TestCase.py?view=diff&rev=1109&p1=asterisk/team/pabelanger/testClass/lib/python/asterisk/AsteriskTest.py&r1=1108&p2=asterisk/team/pabelanger/testClass/lib/python/asterisk/TestCase.py&r2=1109
==============================================================================
--- asterisk/team/pabelanger/testClass/lib/python/asterisk/AsteriskTest.py (original)
+++ asterisk/team/pabelanger/testClass/lib/python/asterisk/TestCase.py Wed Dec  8 14:13:56 2010
@@ -8,23 +8,34 @@
 '''
 
 import sys
+from optparse import OptionParser
 
 from asterisk import Asterisk
 
-class AsteriskTest(object):
+class TestCase(object):
     __asterisk_class = []
-    base_dir = ""
-    test_dir = ""
+
+    def __init__(self, argv):
+        # get version info
+        parser = OptionParser()
+        parser.add_option("-v", "--version", dest="ast_version",
+                help="Asterisk version string")
+        parser.add_option("--test-name", dest="test_name",
+                help="Test name")
+
+        (self.options, args) = parser.parse_args(argv)
+        self.options.base = self.options.test_name.lstrip("tests/")
 
     def create_asterisk(self, count=1):
         for c in range(count):
             print "Creating Asterisk instance %d..." % (c + 1)
-            self.__asterisk_class.append(Asterisk(base=self.base_dir))
+            self.__asterisk_class.append(Asterisk(base=self.options.base))
             # Copy shared config files
-            self.__asterisk_class[c].install_configs("%s/configs" % (self.test_dir))
+            self.__asterisk_class[c].install_configs("%s/configs" %
+                    (self.options.test_name))
             # Copy test specific config files
             self.__asterisk_class[c].install_configs("%s/configs/ast%d" %
-                    (self.test_dir, c + 1))
+                    (self.options.test_name, c + 1))
 
     def start_asterisk(self):
         for index, item in enumerate(self.__asterisk_class):

Modified: asterisk/team/pabelanger/testClass/lib/python/asterisk/__init__.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/testClass/lib/python/asterisk/__init__.py?view=diff&rev=1109&r1=1108&r2=1109
==============================================================================
--- asterisk/team/pabelanger/testClass/lib/python/asterisk/__init__.py (original)
+++ asterisk/team/pabelanger/testClass/lib/python/asterisk/__init__.py Wed Dec  8 14:13:56 2010
@@ -1,1 +1,0 @@
-__all__ = [ "asterisk", "config", "version", "cdr", "utils" ]

Modified: asterisk/team/pabelanger/testClass/lib/python/asterisk/asterisk.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/testClass/lib/python/asterisk/asterisk.py?view=diff&rev=1109&r1=1108&r2=1109
==============================================================================
--- asterisk/team/pabelanger/testClass/lib/python/asterisk/asterisk.py (original)
+++ asterisk/team/pabelanger/testClass/lib/python/asterisk/asterisk.py Wed Dec  8 14:13:56 2010
@@ -48,17 +48,16 @@
 
         Keyword Arguments:
         base -- This is the root of the files associated with this instance of
-        Asterisk.  By default, the base is "tmp/" within the current working
-        directory.  Given a base, a unique directory name will be generated to
-        hold all files.
-
-        Example Usage:
-        self.asterisk = Asterisk(base=os.path.join(os.getcwd(),
-                                                   "tests/ami-login/tmp"))
+        Asterisk.  By default, the base is "/tmp/asterisk-testsuite" directory.
+        Given a base, it will be appended to the default base directory.
+
+        Example Usage:
+        self.asterisk = Asterisk(base="manager/login")
         """
         self.directories = {}
         self.ast_version = AsteriskVersion()
 
+        self.base = "/tmp/asterisk-testsuite"
         self.astetcdir = "/etc/asterisk"
         self.ast_binary = utils.which("asterisk") or "/usr/sbin/asterisk"
 
@@ -76,10 +75,8 @@
             print "No asterisk.conf found on the system!"
             return
 
-        # Choose an install base
-        self.base = base
-        if self.base is None:
-            self.base = "%s/tmp" % os.getcwd()
+        if base is not None:
+            self.base = "%s/%s" % (self.base, base)
         i = 1
         while True:
             if not os.path.isdir("%s/ast%d" % (self.base, i)):

Modified: asterisk/team/pabelanger/testClass/runtests.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/testClass/runtests.py?view=diff&rev=1109&r1=1108&r2=1109
==============================================================================
--- asterisk/team/pabelanger/testClass/runtests.py (original)
+++ asterisk/team/pabelanger/testClass/runtests.py Wed Dec  8 14:13:56 2010
@@ -81,7 +81,7 @@
             "res_fax_spandsp.so",
             "res_fax_digium.so",
         ]
-        ast = Asterisk(base="/tmp/asterisk-testsuite/runtests")
+        ast = Asterisk()
 
         if "astmoddir" not in ast.directories:
             return False
@@ -115,7 +115,8 @@
         start_time = time.time()
         cmd = [
             "%s/run-test" % self.test_name,
-            "-v", str(self.ast_version)
+            "-v", str(self.ast_version),
+            "--test-name", str(self.test_name)
         ]
         if os.path.exists(cmd[0]) and os.access(cmd[0], os.X_OK):
             print "Running %s ..." % cmd

Modified: asterisk/team/pabelanger/testClass/tests/manager/login/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/testClass/tests/manager/login/run-test?view=diff&rev=1109&r1=1108&r2=1109
==============================================================================
--- asterisk/team/pabelanger/testClass/tests/manager/login/run-test (original)
+++ asterisk/team/pabelanger/testClass/tests/manager/login/run-test Wed Dec  8 14:13:56 2010
@@ -17,14 +17,14 @@
 
 sys.path.append("lib/python")
 from asterisk.asterisk import Asterisk
-from asterisk.AsteriskTest import AsteriskTest
+from asterisk.TestCase import TestCase
 
 workingdir = "/tmp/asterisk-testsuite/manager/login"
 testdir = "tests/manager/login"
 
-class AMILoginTest(AsteriskTest):
-    def __init__(self):
-        AsteriskTest.__init__(self)
+class AMILoginTest(TestCase):
+    def __init__(self, argv):
+        TestCase.__init__(self, argv)
         self.base_dir = workingdir
         self.test_dir = testdir
         self.passed = False
@@ -68,8 +68,11 @@
         self.ami_factory.login('127.0.0.1', 5038).addCallbacks(self.on_connect,
                                                                self.on_error)
 
-def main():
-    test = AMILoginTest()
+def main(argv=None):
+    if argv is None:
+        argv = sys.argv
+
+    test = AMILoginTest(argv)
     test.start_asterisk()
     reactor.run()
     test.stop_asterisk()




More information about the asterisk-commits mailing list