aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_config.py
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2020-06-29 00:33:23 -0400
committerLibravatarUnit 193 <unit193@unit193.net>2020-06-29 00:33:23 -0400
commitd7db0f63f4b1f051a7ecf6d80cfacaae1626ce69 (patch)
tree64c9657783b7c1ec7db81ec1e41fedba3c5ad0b2 /test/test_config.py
parent2865adf5de64ea6ca38f734cc61ef805c4bc27d2 (diff)
parent02dd2886783cd303cff6890a741152d013bb00ce (diff)
Update upstream source from tag 'upstream/1.14.2'
Update to upstream version '1.14.2' with Debian dir 4efcdfd56b8d506548ba3400af16c1e34dea7260
Diffstat (limited to 'test/test_config.py')
-rw-r--r--test/test_config.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/test_config.py b/test/test_config.py
index 4171435..a9cefd4 100644
--- a/test/test_config.py
+++ b/test/test_config.py
@@ -68,6 +68,34 @@ class TestConfig(unittest.TestCase):
self.assertEqual(config.interpolate(("b",), "d", 1) , 2)
self.assertEqual(config.interpolate(("d",), "d", 1) , 2)
+ def test_interpolate_common(self):
+
+ def lookup():
+ return config.interpolate_common(
+ ("Z1", "Z2"), (
+ ("A1", "A2"),
+ ("B1",),
+ ("C1", "C2", "C3"),
+ ), "KEY", "DEFAULT",
+ )
+
+ def test(path, value, expected=None):
+ config.set(path, "KEY", value)
+ self.assertEqual(lookup(), expected or value)
+
+ self.assertEqual(lookup(), "DEFAULT")
+ test(("Z1",), 1)
+ test(("Z1", "Z2"), 2)
+ test(("Z1", "Z2", "C1"), 3)
+ test(("Z1", "Z2", "C1", "C2"), 4)
+ test(("Z1", "Z2", "C1", "C2", "C3"), 5)
+ test(("Z1", "Z2", "B1"), 6)
+ test(("Z1", "Z2", "A1"), 7)
+ test(("Z1", "Z2", "A1", "A2"), 8)
+ test(("Z1", "A1", "A2"), 999, 8)
+ test(("Z1", "Z2", "A1", "A2", "A3"), 999, 8)
+ test((), 9)
+
def test_set(self):
config.set(() , "c", [1, 2, 3])
config.set(("b",) , "c", [1, 2, 3])