[Osaas-commits] r11 - in trunk: . server/osaas server/test

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Aug 28 14:55:37 CEST 2007


Author: bh
Date: 2007-08-28 14:55:37 +0200 (Tue, 28 Aug 2007)
New Revision: 11

Modified:
   trunk/ChangeLog
   trunk/server/osaas/run.py
   trunk/server/test/test_config.py
Log:
* server/osaas/run.py (OSAASProgramMixin.add_db_options): New
method to add database options
(OSAASServerProgram.create_option_parser): Call add_db_options

* server/test/test_config.py (TestConfigParsing_DBConnection): New
class with test for the db connection options


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-08-28 12:45:11 UTC (rev 10)
+++ trunk/ChangeLog	2007-08-28 12:55:37 UTC (rev 11)
@@ -1,5 +1,14 @@
 2007-08-28  Bernhard Herzog  <bh at intevation.de>
 
+	* server/osaas/run.py (OSAASProgramMixin.add_db_options): New
+	method to add database options
+	(OSAASServerProgram.create_option_parser): Call add_db_options
+
+	* server/test/test_config.py (TestConfigParsing_DBConnection): New
+	class with test for the db connection options
+
+2007-08-28  Bernhard Herzog  <bh at intevation.de>
+
 	* server/osaas/run.py (OSAASServerProgram, OSAASProgramMixin):
 	Split the configuration handling -- the read_config_file method
 	and the optparse_option_class -- from OSAASServerProgram into the

Modified: trunk/server/osaas/run.py
===================================================================
--- trunk/server/osaas/run.py	2007-08-28 12:45:11 UTC (rev 10)
+++ trunk/server/osaas/run.py	2007-08-28 12:55:37 UTC (rev 11)
@@ -13,6 +13,11 @@
 
     optparse_option_class = OSAASOption
 
+    def add_db_options(self, parser):
+        for name in ["User", "Password", "DSN"]:
+            option = parser.add_option("--db-" + name.lower())
+            option.xml_path = "OSAASConfig/DBConnection/" + name
+
     def read_config_file(self, opts):
         if opts.config_file is not None:
             read_config_file(opts.config_file, opts)
@@ -27,6 +32,7 @@
                                              for part in name.split("-")])
             parser.get_option("--" + name).xml_path = path
         parser.add_option("--userdb-file", xml_path="OSAASConfig/UserDB")
+        self.add_db_options(parser)
         return parser
 
     def instantiate_server(self, server_class, server_address, opts, **kw):

Modified: trunk/server/test/test_config.py
===================================================================
--- trunk/server/test/test_config.py	2007-08-28 12:45:11 UTC (rev 10)
+++ trunk/server/test/test_config.py	2007-08-28 12:55:37 UTC (rev 11)
@@ -78,3 +78,24 @@
         self.assertRaises(ConfigXMLPathError,
                           prog.parse_options,
                           ["--config-file=%s" % self.filename])
+
+class TestConfigParsing_DBConnection(ConfigParserTest):
+
+    config = """\
+<?xml version='1.0'?>
+<OSAASConfig>
+  <ErrorLog>/var/log/osaas-error.log</ErrorLog>
+  <DBConnection>
+    <User>owsdbuser</User>
+    <Password>secret</Password>
+    <DSN>mydsn</DSN>
+  </DBConnection>
+</OSAASConfig>
+"""
+
+    def test(self):
+        prog = OSAASServerProgram()
+        opts, rest = prog.parse_options(["--config-file=%s" % self.filename])
+        self.assertEquals(opts.db_user, "owsdbuser")
+        self.assertEquals(opts.db_password, "secret")
+        self.assertEquals(opts.db_dsn, "mydsn")



More information about the Osaas-commits mailing list