[svn-commits] russell: testsuite/asterisk/trunk r590 - in /asterisk/trunk: lib/python/aster...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Jul 26 13:56:24 CDT 2010


Author: russell
Date: Mon Jul 26 13:56:21 2010
New Revision: 590

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=590
Log:
Provide the ability to override options in the [options] section of asterisk.conf

Modified:
    asterisk/trunk/lib/python/asterisk/asterisk.py
    asterisk/trunk/tests/manager/login/run-test

Modified: asterisk/trunk/lib/python/asterisk/asterisk.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/asterisk.py?view=diff&rev=590&r1=589&r2=590
==============================================================================
--- asterisk/trunk/lib/python/asterisk/asterisk.py (original)
+++ asterisk/trunk/lib/python/asterisk/asterisk.py Mon Jul 26 13:56:21 2010
@@ -36,9 +36,14 @@
     conflicting with each other.  For example, modules that listen for network
     connections will need to be configured to use different ports on each
     instance of Asterisk.
+
+    To set values for the [options] section in asterisk.conf, provide a
+    dictionary to the ast_conf_options parameter.  The key should be the option
+    name and the value is the option's value to be written out into
+    asterisk.conf.
     """
 
-    def __init__(self, base=None):
+    def __init__(self, base=None, ast_conf_options=None):
         """Construct an Asterisk instance.
 
         Keyword Arguments:
@@ -89,7 +94,7 @@
         if dir_cat is None:
             print "Unable to discover dir layout from asterisk.conf"
             return
-        self.__gen_ast_conf(ast_conf, dir_cat)
+        self.__gen_ast_conf(ast_conf, dir_cat, ast_conf_options)
         for (var, val) in dir_cat.options:
             self.__mirror_dir(var, val)
 
@@ -194,7 +199,7 @@
         process.wait()
         return output
 
-    def __gen_ast_conf(self, ast_conf, dir_cat):
+    def __gen_ast_conf(self, ast_conf, dir_cat, ast_conf_options):
         for (var, val) in dir_cat.options:
             if var == "astetcdir":
                 self.astetcdir = "%s%s" % (self.base, val)
@@ -217,11 +222,18 @@
                 for (var, val) in c.options:
                     self.directories[var] = val
                     f.write("%s = %s%s\n" % (var, self.base, val))
+            elif c.name == "options":
+                if ast_conf_options:
+                    for (var, val) in ast_conf_options.iteritems():
+                        f.write("%s = %s\n" % (var, val))
+                if not ast_conf_options or "nocolor" not in ast_conf_options:
+                    f.write("nocolor = yes")
+                for (var, val) in c.options:
+                    if not ast_conf_options or var not in ast_conf_options:
+                        f.write("%s = %s\n" % (var, val))
             else:
                 for (var, val) in c.options:
                     f.write("%s = %s\n" % (var, val))
-                if c.name == "options":
-                    f.write("nocolor = yes")
             f.write("\n")
 
         f.close()

Modified: asterisk/trunk/tests/manager/login/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/manager/login/run-test?view=diff&rev=590&r1=589&r2=590
==============================================================================
--- asterisk/trunk/tests/manager/login/run-test (original)
+++ asterisk/trunk/tests/manager/login/run-test Mon Jul 26 13:56:21 2010
@@ -28,7 +28,12 @@
         reactor.callWhenRunning(self.run)
 
         print "Creating Asterisk instance ..."
-        self.asterisk = Asterisk(base="/tmp/asterisk-testsuite/manager/login")
+        ast_conf_options = {
+            "verbose" : "10",
+            "debug" : "3"
+        }
+        self.asterisk = Asterisk(base="/tmp/asterisk-testsuite/manager/login",
+                                 ast_conf_options=ast_conf_options)
         self.asterisk.install_config("tests/manager/login/configs/manager.conf")
         self.asterisk.install_config("tests/manager/login/configs/logger.conf")
 
@@ -40,8 +45,6 @@
     def start_asterisk(self):
         self.log_last_step("Starting Asterisk")
         self.asterisk.start()
-        self.asterisk.cli_exec("core set verbose 10")
-        self.asterisk.cli_exec("core set debug 3")
 
     def stop_asterisk(self):
         self.asterisk.stop()




More information about the svn-commits mailing list