changeset 116:c37fa787c022

More unittests for fetching namespaced variables and filters
author Franz Glasner <hg@dom66.de>
date Thu, 29 Mar 2018 08:53:35 +0200
parents a5339d39af5c
children c5b638f9c607
files tests/test.py
diffstat 1 files changed, 25 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test.py	Sun Mar 25 16:45:15 2018 +0200
+++ b/tests/test.py	Thu Mar 29 08:53:35 2018 +0200
@@ -3,6 +3,7 @@
 import sys
 import os
 import unittest
+import platform
 
 sys.path.insert(
     0,
@@ -153,18 +154,38 @@
             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"),
+            os.path.join(TESTDATADIR, "conf21.yml"),
+            os.path.join(TESTDATADIR, "conf22.ini"))
+        self.assertEqual(u(os.getcwd()), cfg.getvar("OS:cwd"))
+        self.assertEqual(u(platform.python_version()),
+                         cfg.getvar_s("PY:version"))
+
+    def test04_no_filter(self):
+        cfg = self._load(
+            os.path.join(TESTDATADIR, "conf20.yml"),
+            os.path.join(TESTDATADIR, "conf21.yml"),
+            os.path.join(TESTDATADIR, "conf22.ini"))
+
+        def _look():
+            return cfg.getvar("OS:cwd|upper")
+
+        self.assertRaises(KeyError, _look)
+
 
 class T02LoadAndMerge(_T02MixinLoadAndMerge, unittest.TestCase):
 
     def setUp(self):
         self._load = configmix.load
 
-    def test03_identity(self):
+    def test05_identity(self):
         cfg = configmix.ini.load(os.path.join(TESTDATADIR, "conf1.ini"))
         cfg2 = configmix.merge(cfg, None)
         self.assertEqual(id(cfg), id(cfg2))
 
-    def test04_identity(self):
+    def test06_identity(self):
         cfg = configmix.ini.load(os.path.join(TESTDATADIR, "conf1.ini"))
         cfg2 = configmix.merge(cfg, {})
         self.assertEqual(id(cfg), id(cfg2))
@@ -175,12 +196,12 @@
     def setUp(self):
         self._load = configmix.safe_load
 
-    def test03_deepcopy(self):
+    def test05_deepcopy(self):
         cfg = configmix.ini.load(os.path.join(TESTDATADIR, "conf1.ini"))
         cfg2 = configmix.safe_merge(cfg, None)
         self.assertNotEqual(id(cfg), id(cfg2))
 
-    def test04_deepcopy(self):
+    def test06_deepcopy(self):
         cfg = configmix.ini.load(os.path.join(TESTDATADIR, "conf1.ini"))
         cfg2 = configmix.safe_merge(cfg, {})
         self.assertNotEqual(id(cfg), id(cfg2))