diff tests/test.py @ 196:13527d70e9e3

An additional unit test with a TOML style configuration file
author Franz Glasner <fzglas.hg@dom66.de>
date Fri, 03 May 2019 21:59:51 +0200
parents 28e6c1413947
children 0b855758ba08
line wrap: on
line diff
--- a/tests/test.py	Fri May 03 21:51:09 2019 +0200
+++ b/tests/test.py	Fri May 03 21:59:51 2019 +0200
@@ -223,6 +223,33 @@
             u("postgresql+psycopg2://the_database_user_2:the-database-password-2@3rd-host:5432/my_database_catalog"),
             url)
 
+    def test02_load_with_toml(self):
+        cfg = self._load(
+            os.path.join(TESTDATADIR, "conf20.yml"),
+            os.path.join(TESTDATADIR, "conf21.yml"),
+            # .ini replaced with an equivalent .toml
+            os.path.join(TESTDATADIR, "conf24.toml"))
+
+        self.assertEqual(u("the_database_user_2"),
+                         cfg.getvar_s("db.user.name"))
+        self.assertEqual(u("the-database-password-2"),
+                         cfg.getvar_s("db.user.pwd"))
+
+        tmpdir = cfg.getvar_s("tmpdir")
+        self.assertEqual(u(os.getcwd()) + u("/tmp\\4"), tmpdir)
+
+        self.assertEqual(u("3rd-host"),
+                         cfg.getvar_s("db.locinfo.ro.hostname"))
+        self.assertEqual(u("localhost"),
+                         cfg.getvar_s("db.locinfo.rw.hostname"))
+
+        self.assertEqual(5432, cfg.getvar_s("db.locinfo.ro.port"))
+
+        url = cfg.getvar_s("db.engines.ro.url")
+        self.assertEqual(
+            u("postgresql+psycopg2://the_database_user_2:the-database-password-2@3rd-host:5432/my_database_catalog"),
+            url)        
+
     def test03_namespace(self):
         cfg = self._load(
             os.path.join(TESTDATADIR, "conf20.yml"),