Mercurial > hgrepos > Python > libs > ConfigMix
annotate tests/test.py @ 737:282c8e64d7b1
FIX: tests on non-Windows
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sun, 29 Oct 2023 11:32:56 +0100 |
| parents | ef7bee8b54e1 |
| children | 20e3c2d956d9 |
| rev | line source |
|---|---|
| 93 | 1 # -*- coding: utf-8 -*- |
| 2 | |
| 3 import unittest | |
|
116
c37fa787c022
More unittests for fetching namespaced variables and filters
Franz Glasner <hg@dom66.de>
parents:
113
diff
changeset
|
4 import platform |
|
119
eefde3288fb8
FIX: YAML-file streams must be opened as UTF-8 text files; otherwise double encoding occurs for non-Unicode locales (e.g. Windows)
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
116
diff
changeset
|
5 import io |
|
619
75ecbe07abff
Introduct a test context to more easily switch between some unittest configurations
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
554
diff
changeset
|
6 import os |
|
697
57fe110c50c8
Implement a new "SYS" namespace with "prefix", "base_prefix" and "platform"
Franz Glasner <fzglas.hg@dom66.de>
parents:
692
diff
changeset
|
7 import sys |
| 93 | 8 |
|
619
75ecbe07abff
Introduct a test context to more easily switch between some unittest configurations
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
554
diff
changeset
|
9 from _test_context import TESTDATADIR |
| 93 | 10 |
| 11 import configmix | |
| 12 import configmix.ini | |
| 13 import configmix.yaml | |
|
122
21d92ff8cf31
Begin the handling of JSON-style configuration files
Franz Glasner <hg@dom66.de>
parents:
120
diff
changeset
|
14 import configmix.json |
| 93 | 15 import configmix.py |
|
195
28e6c1413947
Added support for TOML style configuration files
Franz Glasner <fzglas.hg@dom66.de>
parents:
183
diff
changeset
|
16 import configmix.toml |
|
542
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
17 import configmix.config |
|
432
b96f49c9c76b
Proper "repr()" for a jailed configuration: put the root path into the output
Franz Glasner <fzglas.hg@dom66.de>
parents:
427
diff
changeset
|
18 from configmix.compat import u, PY2 |
| 93 | 19 |
| 20 | |
| 21 class T01Basic(unittest.TestCase): | |
| 22 | |
| 23 """Check with low-level internal interfaces""" | |
| 24 | |
| 25 def __check_types(self, cfg): | |
| 26 self.assertEqual(u("the value"), | |
| 27 cfg.get("key1")) | |
| 28 self.assertTrue(isinstance(cfg.get("key1"), type(u('')))) | |
| 29 self.assertEqual(2, cfg.get("key2")) | |
| 30 self.assertEqual(5.7, cfg.get("key3")) | |
| 31 self.assertTrue(isinstance(cfg.get("key1"), type(u('')))) | |
| 32 self.assertTrue(cfg.get("key4")) | |
| 33 self.assertTrue(isinstance(cfg.get("key4"), bool)) | |
| 34 self.assertFalse(cfg.get("key5")) | |
| 35 self.assertTrue(isinstance(cfg.get("key5"), bool)) | |
| 95 | 36 self.assertEqual(255, cfg.get("key6")) |
|
120
ba5970a2dcef
The default file encoding when reading INI style files with configmix.ini.load() is now "UTF-8".
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
119
diff
changeset
|
37 self.assertEqual(u("Umlaute: ÄÖÜäöüß"), |
|
ba5970a2dcef
The default file encoding when reading INI style files with configmix.ini.load() is now "UTF-8".
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
119
diff
changeset
|
38 cfg.get("key7")) |
| 93 | 39 |
|
144
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
40 def __check_comment(self, cfg): |
|
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
41 # Check comments: low level comments are *not* filtered |
|
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
42 self.assertEqual(u("Comment 1"), cfg.get("__comment1")) |
|
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
43 self.assertEqual(u("Comment no 2"), cfg.get("__comment2")) |
|
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
44 |
|
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
45 def __check_no_comment(self, cfg): |
|
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
46 |
|
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
47 def _c(name): |
|
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
48 def _f(): |
|
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
49 cfg[u(name)] |
|
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
50 return _f |
|
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
51 |
|
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
52 # Variables with leading underscores are *not* imported by default |
|
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
53 self.assertRaises(KeyError, _c("__comment1")) |
|
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
54 self.assertRaises(KeyError, _c("__comment2")) |
|
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
55 |
|
97
1b4d95f60650
Build a tree-ish configuration from an INI style configuration file
Franz Glasner <hg@dom66.de>
parents:
95
diff
changeset
|
56 def __check_tree(self, cfg): |
|
1b4d95f60650
Build a tree-ish configuration from an INI style configuration file
Franz Glasner <hg@dom66.de>
parents:
95
diff
changeset
|
57 self.assertEqual(u("in the root namespace"), |
|
1b4d95f60650
Build a tree-ish configuration from an INI style configuration file
Franz Glasner <hg@dom66.de>
parents:
95
diff
changeset
|
58 cfg.get("key1")) |
|
1b4d95f60650
Build a tree-ish configuration from an INI style configuration file
Franz Glasner <hg@dom66.de>
parents:
95
diff
changeset
|
59 self.assertEqual(u("in the root namespace -- too"), |
|
1b4d95f60650
Build a tree-ish configuration from an INI style configuration file
Franz Glasner <hg@dom66.de>
parents:
95
diff
changeset
|
60 cfg.get("key2")) |
|
1b4d95f60650
Build a tree-ish configuration from an INI style configuration file
Franz Glasner <hg@dom66.de>
parents:
95
diff
changeset
|
61 self.assertEqual(32, |
|
1b4d95f60650
Build a tree-ish configuration from an INI style configuration file
Franz Glasner <hg@dom66.de>
parents:
95
diff
changeset
|
62 cfg["tree1"]["key3"]) |
|
1b4d95f60650
Build a tree-ish configuration from an INI style configuration file
Franz Glasner <hg@dom66.de>
parents:
95
diff
changeset
|
63 self.assertEqual(u("get this as `tree1.tree2.key4'"), |
|
1b4d95f60650
Build a tree-ish configuration from an INI style configuration file
Franz Glasner <hg@dom66.de>
parents:
95
diff
changeset
|
64 cfg["tree1"]["tree2"]["key4"]) |
|
1b4d95f60650
Build a tree-ish configuration from an INI style configuration file
Franz Glasner <hg@dom66.de>
parents:
95
diff
changeset
|
65 self.assertTrue(cfg["tree1"]["tree2"]["key5"]) |
|
1b4d95f60650
Build a tree-ish configuration from an INI style configuration file
Franz Glasner <hg@dom66.de>
parents:
95
diff
changeset
|
66 |
| 93 | 67 def test01_ini_types(self): |
| 68 cfg = configmix.ini.load(os.path.join(TESTDATADIR, "conf1.ini")) | |
| 69 self.__check_types(cfg) | |
|
144
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
70 self.__check_comment(cfg) |
| 93 | 71 |
|
198
0b855758ba08
An additional TOML-related unittest (types)
Franz Glasner <fzglas.hg@dom66.de>
parents:
196
diff
changeset
|
72 def test01_toml_types(self): |
|
0b855758ba08
An additional TOML-related unittest (types)
Franz Glasner <fzglas.hg@dom66.de>
parents:
196
diff
changeset
|
73 cfg = configmix.toml.load(os.path.join(TESTDATADIR, "conf1.toml")) |
|
0b855758ba08
An additional TOML-related unittest (types)
Franz Glasner <fzglas.hg@dom66.de>
parents:
196
diff
changeset
|
74 self.__check_types(cfg) |
|
227
f5011eec3b6e
Added a loader with key "ignore" that ignores the given configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
198
diff
changeset
|
75 self.__check_comment(cfg) |
|
198
0b855758ba08
An additional TOML-related unittest (types)
Franz Glasner <fzglas.hg@dom66.de>
parents:
196
diff
changeset
|
76 |
| 93 | 77 def test02_py_types(self): |
| 78 cfg = configmix.py.load(os.path.join(TESTDATADIR, "conf1.py")) | |
| 79 self.__check_types(cfg) | |
|
144
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
80 self.__check_no_comment(cfg) |
| 93 | 81 |
| 82 def test03_yaml_types(self): | |
|
119
eefde3288fb8
FIX: YAML-file streams must be opened as UTF-8 text files; otherwise double encoding occurs for non-Unicode locales (e.g. Windows)
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
116
diff
changeset
|
83 with io.open(os.path.join(TESTDATADIR, "conf1.yml"), "rt", |
|
eefde3288fb8
FIX: YAML-file streams must be opened as UTF-8 text files; otherwise double encoding occurs for non-Unicode locales (e.g. Windows)
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
116
diff
changeset
|
84 encoding="utf-8") as f: |
| 93 | 85 cfg = configmix.yaml.safe_load(f) |
|
134
2f2e819e8d17
Check the return type of the JSON and YAML loading functions: they must be a dict alike
Franz Glasner <hg@dom66.de>
parents:
130
diff
changeset
|
86 if configmix.yaml.OrderedDict: |
|
2f2e819e8d17
Check the return type of the JSON and YAML loading functions: they must be a dict alike
Franz Glasner <hg@dom66.de>
parents:
130
diff
changeset
|
87 self.assertTrue(isinstance(cfg, configmix.yaml.OrderedDict)) |
| 93 | 88 self.__check_types(cfg) |
|
144
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
89 self.__check_comment(cfg) |
| 93 | 90 |
|
122
21d92ff8cf31
Begin the handling of JSON-style configuration files
Franz Glasner <hg@dom66.de>
parents:
120
diff
changeset
|
91 def test04_json_types(self): |
|
21d92ff8cf31
Begin the handling of JSON-style configuration files
Franz Glasner <hg@dom66.de>
parents:
120
diff
changeset
|
92 cfg = configmix.json.load(os.path.join(TESTDATADIR, "conf1.json")) |
|
127
5b62d2c0e5a8
Use the available "OrderedDict" class as dict for the JSON parser
Franz Glasner <hg@dom66.de>
parents:
122
diff
changeset
|
93 self.assertTrue(isinstance(cfg, configmix.json.DictImpl)) |
|
122
21d92ff8cf31
Begin the handling of JSON-style configuration files
Franz Glasner <hg@dom66.de>
parents:
120
diff
changeset
|
94 self.__check_types(cfg) |
|
144
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
95 self.__check_comment(cfg) |
|
122
21d92ff8cf31
Begin the handling of JSON-style configuration files
Franz Glasner <hg@dom66.de>
parents:
120
diff
changeset
|
96 |
|
21d92ff8cf31
Begin the handling of JSON-style configuration files
Franz Glasner <hg@dom66.de>
parents:
120
diff
changeset
|
97 def test05_py_export_all(self): |
| 93 | 98 # When __all__ is given only it's keys are exported |
| 99 cfg = configmix.py.load(os.path.join(TESTDATADIR, "conf2.py")) | |
| 100 self.assertEqual(u("the next value"), cfg.get("key1")) | |
| 101 self.assertTrue(isinstance(cfg.get("key1"), type(u('')))) | |
| 102 self.assertTrue(cfg.get("key2") is None) | |
| 103 | |
|
122
21d92ff8cf31
Begin the handling of JSON-style configuration files
Franz Glasner <hg@dom66.de>
parents:
120
diff
changeset
|
104 def test06_py_hide_private(self): |
| 93 | 105 # When no __all__ is given all symbols with leading "_" are hidden |
| 106 cfg = configmix.py.load(os.path.join(TESTDATADIR, "conf3.py")) | |
| 107 self.assertEqual(u("the next value "), cfg.get("key1")) | |
| 108 self.assertTrue(isinstance(cfg.get("key1"), type(u('')))) | |
| 109 self.assertTrue(cfg.get("_key2") is None) | |
| 110 | |
|
122
21d92ff8cf31
Begin the handling of JSON-style configuration files
Franz Glasner <hg@dom66.de>
parents:
120
diff
changeset
|
111 def test07_ini_tree(self): |
|
97
1b4d95f60650
Build a tree-ish configuration from an INI style configuration file
Franz Glasner <hg@dom66.de>
parents:
95
diff
changeset
|
112 cfg = configmix.ini.load(os.path.join(TESTDATADIR, "conf10.ini")) |
|
1b4d95f60650
Build a tree-ish configuration from an INI style configuration file
Franz Glasner <hg@dom66.de>
parents:
95
diff
changeset
|
113 self.__check_tree(cfg) |
|
1b4d95f60650
Build a tree-ish configuration from an INI style configuration file
Franz Glasner <hg@dom66.de>
parents:
95
diff
changeset
|
114 |
|
122
21d92ff8cf31
Begin the handling of JSON-style configuration files
Franz Glasner <hg@dom66.de>
parents:
120
diff
changeset
|
115 def test08_py_tree(self): |
|
97
1b4d95f60650
Build a tree-ish configuration from an INI style configuration file
Franz Glasner <hg@dom66.de>
parents:
95
diff
changeset
|
116 cfg = configmix.py.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
1b4d95f60650
Build a tree-ish configuration from an INI style configuration file
Franz Glasner <hg@dom66.de>
parents:
95
diff
changeset
|
117 self.__check_tree(cfg) |
|
1b4d95f60650
Build a tree-ish configuration from an INI style configuration file
Franz Glasner <hg@dom66.de>
parents:
95
diff
changeset
|
118 |
|
122
21d92ff8cf31
Begin the handling of JSON-style configuration files
Franz Glasner <hg@dom66.de>
parents:
120
diff
changeset
|
119 def test09_yaml_tree(self): |
|
119
eefde3288fb8
FIX: YAML-file streams must be opened as UTF-8 text files; otherwise double encoding occurs for non-Unicode locales (e.g. Windows)
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
116
diff
changeset
|
120 with io.open(os.path.join(TESTDATADIR, "conf10.yml"), "rt", |
|
eefde3288fb8
FIX: YAML-file streams must be opened as UTF-8 text files; otherwise double encoding occurs for non-Unicode locales (e.g. Windows)
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
116
diff
changeset
|
121 encoding="utf-8") as f: |
|
97
1b4d95f60650
Build a tree-ish configuration from an INI style configuration file
Franz Glasner <hg@dom66.de>
parents:
95
diff
changeset
|
122 cfg = configmix.yaml.safe_load(f) |
|
1b4d95f60650
Build a tree-ish configuration from an INI style configuration file
Franz Glasner <hg@dom66.de>
parents:
95
diff
changeset
|
123 self.__check_tree(cfg) |
|
1b4d95f60650
Build a tree-ish configuration from an INI style configuration file
Franz Glasner <hg@dom66.de>
parents:
95
diff
changeset
|
124 |
|
130
b11af3ded7c1
Added more JSON specific unit tests
Franz Glasner <hg@dom66.de>
parents:
127
diff
changeset
|
125 def test10_json_tree(self): |
|
b11af3ded7c1
Added more JSON specific unit tests
Franz Glasner <hg@dom66.de>
parents:
127
diff
changeset
|
126 cfg = configmix.json.load(os.path.join(TESTDATADIR, "conf10.json")) |
|
b11af3ded7c1
Added more JSON specific unit tests
Franz Glasner <hg@dom66.de>
parents:
127
diff
changeset
|
127 self.__check_tree(cfg) |
|
b11af3ded7c1
Added more JSON specific unit tests
Franz Glasner <hg@dom66.de>
parents:
127
diff
changeset
|
128 |
|
195
28e6c1413947
Added support for TOML style configuration files
Franz Glasner <fzglas.hg@dom66.de>
parents:
183
diff
changeset
|
129 def test11_toml_tree(self): |
|
28e6c1413947
Added support for TOML style configuration files
Franz Glasner <fzglas.hg@dom66.de>
parents:
183
diff
changeset
|
130 cfg = configmix.toml.load(os.path.join(TESTDATADIR, "conf10.toml")) |
|
28e6c1413947
Added support for TOML style configuration files
Franz Glasner <fzglas.hg@dom66.de>
parents:
183
diff
changeset
|
131 self.__check_tree(cfg) |
|
28e6c1413947
Added support for TOML style configuration files
Franz Glasner <fzglas.hg@dom66.de>
parents:
183
diff
changeset
|
132 |
|
292
6a044778371a
Some unittests for the new "strict" YAML parsing mode to prevent duplicate keys within a single YAML document
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
276
diff
changeset
|
133 def test12_yaml_no_duplicate_keys(self): |
|
6a044778371a
Some unittests for the new "strict" YAML parsing mode to prevent duplicate keys within a single YAML document
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
276
diff
changeset
|
134 import yaml.constructor as yc |
|
6a044778371a
Some unittests for the new "strict" YAML parsing mode to prevent duplicate keys within a single YAML document
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
276
diff
changeset
|
135 with io.open(os.path.join(TESTDATADIR, "duplicate-keys.yml"), "rt", |
|
6a044778371a
Some unittests for the new "strict" YAML parsing mode to prevent duplicate keys within a single YAML document
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
276
diff
changeset
|
136 encoding="utf-8") as f: |
|
6a044778371a
Some unittests for the new "strict" YAML parsing mode to prevent duplicate keys within a single YAML document
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
276
diff
changeset
|
137 cfg = configmix.yaml.safe_load(f) |
|
6a044778371a
Some unittests for the new "strict" YAML parsing mode to prevent duplicate keys within a single YAML document
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
276
diff
changeset
|
138 |
|
6a044778371a
Some unittests for the new "strict" YAML parsing mode to prevent duplicate keys within a single YAML document
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
276
diff
changeset
|
139 with io.open(os.path.join(TESTDATADIR, "duplicate-keys.yml"), "rt", |
|
6a044778371a
Some unittests for the new "strict" YAML parsing mode to prevent duplicate keys within a single YAML document
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
276
diff
changeset
|
140 encoding="utf-8") as f: |
|
6a044778371a
Some unittests for the new "strict" YAML parsing mode to prevent duplicate keys within a single YAML document
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
276
diff
changeset
|
141 self.assertRaises(yc.ConstructorError, |
|
6a044778371a
Some unittests for the new "strict" YAML parsing mode to prevent duplicate keys within a single YAML document
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
276
diff
changeset
|
142 configmix.yaml.safe_load, |
|
6a044778371a
Some unittests for the new "strict" YAML parsing mode to prevent duplicate keys within a single YAML document
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
276
diff
changeset
|
143 f, strict=True) |
|
6a044778371a
Some unittests for the new "strict" YAML parsing mode to prevent duplicate keys within a single YAML document
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
276
diff
changeset
|
144 |
|
6a044778371a
Some unittests for the new "strict" YAML parsing mode to prevent duplicate keys within a single YAML document
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
276
diff
changeset
|
145 def test13_yaml_no_duplicate_keys_2(self): |
|
6a044778371a
Some unittests for the new "strict" YAML parsing mode to prevent duplicate keys within a single YAML document
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
276
diff
changeset
|
146 import yaml.constructor as yc |
|
6a044778371a
Some unittests for the new "strict" YAML parsing mode to prevent duplicate keys within a single YAML document
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
276
diff
changeset
|
147 with io.open(os.path.join(TESTDATADIR, "duplicate-keys-2.yml"), "rt", |
|
6a044778371a
Some unittests for the new "strict" YAML parsing mode to prevent duplicate keys within a single YAML document
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
276
diff
changeset
|
148 encoding="utf-8") as f: |
|
6a044778371a
Some unittests for the new "strict" YAML parsing mode to prevent duplicate keys within a single YAML document
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
276
diff
changeset
|
149 cfg = configmix.yaml.safe_load(f) |
|
6a044778371a
Some unittests for the new "strict" YAML parsing mode to prevent duplicate keys within a single YAML document
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
276
diff
changeset
|
150 |
|
6a044778371a
Some unittests for the new "strict" YAML parsing mode to prevent duplicate keys within a single YAML document
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
276
diff
changeset
|
151 with io.open(os.path.join(TESTDATADIR, "duplicate-keys-2.yml"), "rt", |
|
6a044778371a
Some unittests for the new "strict" YAML parsing mode to prevent duplicate keys within a single YAML document
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
276
diff
changeset
|
152 encoding="utf-8") as f: |
|
6a044778371a
Some unittests for the new "strict" YAML parsing mode to prevent duplicate keys within a single YAML document
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
276
diff
changeset
|
153 self.assertRaises(yc.ConstructorError, |
|
6a044778371a
Some unittests for the new "strict" YAML parsing mode to prevent duplicate keys within a single YAML document
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
276
diff
changeset
|
154 configmix.yaml.safe_load, |
|
6a044778371a
Some unittests for the new "strict" YAML parsing mode to prevent duplicate keys within a single YAML document
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
276
diff
changeset
|
155 f, strict=True) |
|
6a044778371a
Some unittests for the new "strict" YAML parsing mode to prevent duplicate keys within a single YAML document
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
276
diff
changeset
|
156 |
| 93 | 157 |
|
112
c50ad93eb5dc
Implemented a "safe_load()" to load with safe merging
Franz Glasner <hg@dom66.de>
parents:
109
diff
changeset
|
158 class _T02MixinLoadAndMerge: |
|
105
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
159 |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
160 def test01_load(self): |
|
112
c50ad93eb5dc
Implemented a "safe_load()" to load with safe merging
Franz Glasner <hg@dom66.de>
parents:
109
diff
changeset
|
161 cfg = self._load( |
|
105
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
162 os.path.join(TESTDATADIR, "conf20.yml"), |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
163 os.path.join(TESTDATADIR, "conf21.yml")) |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
164 |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
165 self.assertEqual(u("the_database_user"), |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
166 cfg.getvar_s("db.user.name")) |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
167 self.assertEqual(u("the-database-password"), |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
168 cfg.getvar_s("db.user.pwd")) |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
169 |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
170 tmpdir = cfg.getvar_s("tmpdir") |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
171 if os.name == 'nt': |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
172 self.assertFalse(u('/') in tmpdir) |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
173 self.assertEqual(os.path.normpath( |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
174 os.path.abspath(os.path.join(os.getcwd(), "tmp"))), |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
175 tmpdir) |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
176 |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
177 self.assertEqual(u("anotherhost"), |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
178 cfg.getvar_s("db.locinfo.ro.hostname")) |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
179 self.assertEqual(u("localhost"), |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
180 cfg.getvar_s("db.locinfo.rw.hostname")) |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
181 |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
182 self.assertEqual(5432, cfg.getvar_s("db.locinfo.ro.port")) |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
183 |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
184 url = cfg.getvar_s("db.engines.ro.url") |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
185 self.assertEqual( |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
186 u("postgresql+psycopg2://the_database_user:the-database-password@anotherhost:5432/my_database_catalog"), |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
187 url) |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
188 |
|
109
057d87d030f1
Test replacing lists by strings and replacing strings by lists
Franz Glasner <hg@dom66.de>
parents:
105
diff
changeset
|
189 self.assertEqual(u("not a list any more"), |
|
057d87d030f1
Test replacing lists by strings and replacing strings by lists
Franz Glasner <hg@dom66.de>
parents:
105
diff
changeset
|
190 cfg.getvar_s("test.List")) |
|
057d87d030f1
Test replacing lists by strings and replacing strings by lists
Franz Glasner <hg@dom66.de>
parents:
105
diff
changeset
|
191 |
|
057d87d030f1
Test replacing lists by strings and replacing strings by lists
Franz Glasner <hg@dom66.de>
parents:
105
diff
changeset
|
192 self.assertEqual(list(range(0, 3)), |
|
057d87d030f1
Test replacing lists by strings and replacing strings by lists
Franz Glasner <hg@dom66.de>
parents:
105
diff
changeset
|
193 cfg.getvar_s("test.Str")) |
|
057d87d030f1
Test replacing lists by strings and replacing strings by lists
Franz Glasner <hg@dom66.de>
parents:
105
diff
changeset
|
194 |
|
105
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
195 def test02_load_with_ini(self): |
|
112
c50ad93eb5dc
Implemented a "safe_load()" to load with safe merging
Franz Glasner <hg@dom66.de>
parents:
109
diff
changeset
|
196 cfg = self._load( |
|
105
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
197 os.path.join(TESTDATADIR, "conf20.yml"), |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
198 os.path.join(TESTDATADIR, "conf21.yml"), |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
199 os.path.join(TESTDATADIR, "conf22.ini")) |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
200 |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
201 self.assertEqual(u("the_database_user_2"), |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
202 cfg.getvar_s("db.user.name")) |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
203 self.assertEqual(u("the-database-password-2"), |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
204 cfg.getvar_s("db.user.pwd")) |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
205 |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
206 tmpdir = cfg.getvar_s("tmpdir") |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
207 self.assertEqual(u(os.getcwd()) + u("/tmp\\2"), tmpdir) |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
208 |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
209 self.assertEqual(u("3rd-host"), |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
210 cfg.getvar_s("db.locinfo.ro.hostname")) |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
211 self.assertEqual(u("localhost"), |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
212 cfg.getvar_s("db.locinfo.rw.hostname")) |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
213 |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
214 self.assertEqual(5432, cfg.getvar_s("db.locinfo.ro.port")) |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
215 |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
216 url = cfg.getvar_s("db.engines.ro.url") |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
217 self.assertEqual( |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
218 u("postgresql+psycopg2://the_database_user_2:the-database-password-2@3rd-host:5432/my_database_catalog"), |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
219 url) |
|
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
220 |
|
486
5a88c514d4e0
More unittests for interpolation
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
467
diff
changeset
|
221 def test02b_load_with_ini(self): |
|
5a88c514d4e0
More unittests for interpolation
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
467
diff
changeset
|
222 cfg = self._load( |
|
5a88c514d4e0
More unittests for interpolation
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
467
diff
changeset
|
223 os.path.join(TESTDATADIR, "conf20.yml"), |
|
5a88c514d4e0
More unittests for interpolation
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
467
diff
changeset
|
224 os.path.join(TESTDATADIR, "conf21.yml"), |
|
5a88c514d4e0
More unittests for interpolation
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
467
diff
changeset
|
225 os.path.join(TESTDATADIR, "conf22.ini")) |
|
5a88c514d4e0
More unittests for interpolation
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
467
diff
changeset
|
226 self.assertEqual(u("3rd-host3rd-host"), |
|
5a88c514d4e0
More unittests for interpolation
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
467
diff
changeset
|
227 cfg.getvar_s("db.locinfo.ro.hostname2")) |
|
5a88c514d4e0
More unittests for interpolation
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
467
diff
changeset
|
228 |
|
130
b11af3ded7c1
Added more JSON specific unit tests
Franz Glasner <hg@dom66.de>
parents:
127
diff
changeset
|
229 def test02_load_with_json(self): |
|
b11af3ded7c1
Added more JSON specific unit tests
Franz Glasner <hg@dom66.de>
parents:
127
diff
changeset
|
230 cfg = self._load( |
|
b11af3ded7c1
Added more JSON specific unit tests
Franz Glasner <hg@dom66.de>
parents:
127
diff
changeset
|
231 os.path.join(TESTDATADIR, "conf20.yml"), |
|
b11af3ded7c1
Added more JSON specific unit tests
Franz Glasner <hg@dom66.de>
parents:
127
diff
changeset
|
232 os.path.join(TESTDATADIR, "conf21.yml"), |
|
b11af3ded7c1
Added more JSON specific unit tests
Franz Glasner <hg@dom66.de>
parents:
127
diff
changeset
|
233 # .ini replaced with an equivalent .json |
|
b11af3ded7c1
Added more JSON specific unit tests
Franz Glasner <hg@dom66.de>
parents:
127
diff
changeset
|
234 os.path.join(TESTDATADIR, "conf23.json")) |
|
b11af3ded7c1
Added more JSON specific unit tests
Franz Glasner <hg@dom66.de>
parents:
127
diff
changeset
|
235 |
|
b11af3ded7c1
Added more JSON specific unit tests
Franz Glasner <hg@dom66.de>
parents:
127
diff
changeset
|
236 self.assertEqual(u("the_database_user_2"), |
|
b11af3ded7c1
Added more JSON specific unit tests
Franz Glasner <hg@dom66.de>
parents:
127
diff
changeset
|
237 cfg.getvar_s("db.user.name")) |
|
b11af3ded7c1
Added more JSON specific unit tests
Franz Glasner <hg@dom66.de>
parents:
127
diff
changeset
|
238 self.assertEqual(u("the-database-password-2"), |
|
b11af3ded7c1
Added more JSON specific unit tests
Franz Glasner <hg@dom66.de>
parents:
127
diff
changeset
|
239 cfg.getvar_s("db.user.pwd")) |
|
b11af3ded7c1
Added more JSON specific unit tests
Franz Glasner <hg@dom66.de>
parents:
127
diff
changeset
|
240 |
|
b11af3ded7c1
Added more JSON specific unit tests
Franz Glasner <hg@dom66.de>
parents:
127
diff
changeset
|
241 tmpdir = cfg.getvar_s("tmpdir") |
|
b11af3ded7c1
Added more JSON specific unit tests
Franz Glasner <hg@dom66.de>
parents:
127
diff
changeset
|
242 self.assertEqual(u(os.getcwd()) + u("/tmp\\3"), tmpdir) |
|
b11af3ded7c1
Added more JSON specific unit tests
Franz Glasner <hg@dom66.de>
parents:
127
diff
changeset
|
243 |
|
b11af3ded7c1
Added more JSON specific unit tests
Franz Glasner <hg@dom66.de>
parents:
127
diff
changeset
|
244 self.assertEqual(u("3rd-host"), |
|
b11af3ded7c1
Added more JSON specific unit tests
Franz Glasner <hg@dom66.de>
parents:
127
diff
changeset
|
245 cfg.getvar_s("db.locinfo.ro.hostname")) |
|
b11af3ded7c1
Added more JSON specific unit tests
Franz Glasner <hg@dom66.de>
parents:
127
diff
changeset
|
246 self.assertEqual(u("localhost"), |
|
b11af3ded7c1
Added more JSON specific unit tests
Franz Glasner <hg@dom66.de>
parents:
127
diff
changeset
|
247 cfg.getvar_s("db.locinfo.rw.hostname")) |
|
b11af3ded7c1
Added more JSON specific unit tests
Franz Glasner <hg@dom66.de>
parents:
127
diff
changeset
|
248 |
|
b11af3ded7c1
Added more JSON specific unit tests
Franz Glasner <hg@dom66.de>
parents:
127
diff
changeset
|
249 self.assertEqual(5432, cfg.getvar_s("db.locinfo.ro.port")) |
|
b11af3ded7c1
Added more JSON specific unit tests
Franz Glasner <hg@dom66.de>
parents:
127
diff
changeset
|
250 |
|
b11af3ded7c1
Added more JSON specific unit tests
Franz Glasner <hg@dom66.de>
parents:
127
diff
changeset
|
251 url = cfg.getvar_s("db.engines.ro.url") |
|
b11af3ded7c1
Added more JSON specific unit tests
Franz Glasner <hg@dom66.de>
parents:
127
diff
changeset
|
252 self.assertEqual( |
|
b11af3ded7c1
Added more JSON specific unit tests
Franz Glasner <hg@dom66.de>
parents:
127
diff
changeset
|
253 u("postgresql+psycopg2://the_database_user_2:the-database-password-2@3rd-host:5432/my_database_catalog"), |
|
b11af3ded7c1
Added more JSON specific unit tests
Franz Glasner <hg@dom66.de>
parents:
127
diff
changeset
|
254 url) |
|
b11af3ded7c1
Added more JSON specific unit tests
Franz Glasner <hg@dom66.de>
parents:
127
diff
changeset
|
255 |
|
196
13527d70e9e3
An additional unit test with a TOML style configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
195
diff
changeset
|
256 def test02_load_with_toml(self): |
|
13527d70e9e3
An additional unit test with a TOML style configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
195
diff
changeset
|
257 cfg = self._load( |
|
13527d70e9e3
An additional unit test with a TOML style configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
195
diff
changeset
|
258 os.path.join(TESTDATADIR, "conf20.yml"), |
|
13527d70e9e3
An additional unit test with a TOML style configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
195
diff
changeset
|
259 os.path.join(TESTDATADIR, "conf21.yml"), |
|
13527d70e9e3
An additional unit test with a TOML style configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
195
diff
changeset
|
260 # .ini replaced with an equivalent .toml |
|
13527d70e9e3
An additional unit test with a TOML style configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
195
diff
changeset
|
261 os.path.join(TESTDATADIR, "conf24.toml")) |
|
13527d70e9e3
An additional unit test with a TOML style configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
195
diff
changeset
|
262 |
|
13527d70e9e3
An additional unit test with a TOML style configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
195
diff
changeset
|
263 self.assertEqual(u("the_database_user_2"), |
|
13527d70e9e3
An additional unit test with a TOML style configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
195
diff
changeset
|
264 cfg.getvar_s("db.user.name")) |
|
13527d70e9e3
An additional unit test with a TOML style configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
195
diff
changeset
|
265 self.assertEqual(u("the-database-password-2"), |
|
13527d70e9e3
An additional unit test with a TOML style configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
195
diff
changeset
|
266 cfg.getvar_s("db.user.pwd")) |
|
13527d70e9e3
An additional unit test with a TOML style configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
195
diff
changeset
|
267 |
|
13527d70e9e3
An additional unit test with a TOML style configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
195
diff
changeset
|
268 tmpdir = cfg.getvar_s("tmpdir") |
|
13527d70e9e3
An additional unit test with a TOML style configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
195
diff
changeset
|
269 self.assertEqual(u(os.getcwd()) + u("/tmp\\4"), tmpdir) |
|
13527d70e9e3
An additional unit test with a TOML style configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
195
diff
changeset
|
270 |
|
13527d70e9e3
An additional unit test with a TOML style configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
195
diff
changeset
|
271 self.assertEqual(u("3rd-host"), |
|
13527d70e9e3
An additional unit test with a TOML style configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
195
diff
changeset
|
272 cfg.getvar_s("db.locinfo.ro.hostname")) |
|
13527d70e9e3
An additional unit test with a TOML style configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
195
diff
changeset
|
273 self.assertEqual(u("localhost"), |
|
13527d70e9e3
An additional unit test with a TOML style configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
195
diff
changeset
|
274 cfg.getvar_s("db.locinfo.rw.hostname")) |
|
13527d70e9e3
An additional unit test with a TOML style configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
195
diff
changeset
|
275 |
|
13527d70e9e3
An additional unit test with a TOML style configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
195
diff
changeset
|
276 self.assertEqual(5432, cfg.getvar_s("db.locinfo.ro.port")) |
|
13527d70e9e3
An additional unit test with a TOML style configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
195
diff
changeset
|
277 |
|
13527d70e9e3
An additional unit test with a TOML style configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
195
diff
changeset
|
278 url = cfg.getvar_s("db.engines.ro.url") |
|
13527d70e9e3
An additional unit test with a TOML style configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
195
diff
changeset
|
279 self.assertEqual( |
|
13527d70e9e3
An additional unit test with a TOML style configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
195
diff
changeset
|
280 u("postgresql+psycopg2://the_database_user_2:the-database-password-2@3rd-host:5432/my_database_catalog"), |
|
227
f5011eec3b6e
Added a loader with key "ignore" that ignores the given configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
198
diff
changeset
|
281 url) |
|
196
13527d70e9e3
An additional unit test with a TOML style configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
195
diff
changeset
|
282 |
|
116
c37fa787c022
More unittests for fetching namespaced variables and filters
Franz Glasner <hg@dom66.de>
parents:
113
diff
changeset
|
283 def test03_namespace(self): |
|
c37fa787c022
More unittests for fetching namespaced variables and filters
Franz Glasner <hg@dom66.de>
parents:
113
diff
changeset
|
284 cfg = self._load( |
|
c37fa787c022
More unittests for fetching namespaced variables and filters
Franz Glasner <hg@dom66.de>
parents:
113
diff
changeset
|
285 os.path.join(TESTDATADIR, "conf20.yml"), |
|
c37fa787c022
More unittests for fetching namespaced variables and filters
Franz Glasner <hg@dom66.de>
parents:
113
diff
changeset
|
286 os.path.join(TESTDATADIR, "conf21.yml"), |
|
c37fa787c022
More unittests for fetching namespaced variables and filters
Franz Glasner <hg@dom66.de>
parents:
113
diff
changeset
|
287 os.path.join(TESTDATADIR, "conf22.ini")) |
|
c37fa787c022
More unittests for fetching namespaced variables and filters
Franz Glasner <hg@dom66.de>
parents:
113
diff
changeset
|
288 self.assertEqual(u(os.getcwd()), cfg.getvar("OS:cwd")) |
|
c37fa787c022
More unittests for fetching namespaced variables and filters
Franz Glasner <hg@dom66.de>
parents:
113
diff
changeset
|
289 self.assertEqual(u(platform.python_version()), |
|
c37fa787c022
More unittests for fetching namespaced variables and filters
Franz Glasner <hg@dom66.de>
parents:
113
diff
changeset
|
290 cfg.getvar_s("PY:version")) |
|
698
3a9d661d33b5
Implement SYS:executable
Franz Glasner <fzglas.hg@dom66.de>
parents:
697
diff
changeset
|
291 self.assertEqual(u(sys.executable), cfg.getvar_s("SYS:executable")) |
|
697
57fe110c50c8
Implement a new "SYS" namespace with "prefix", "base_prefix" and "platform"
Franz Glasner <fzglas.hg@dom66.de>
parents:
692
diff
changeset
|
292 self.assertEqual(u(sys.prefix), cfg.getvar_s("SYS:prefix")) |
|
57fe110c50c8
Implement a new "SYS" namespace with "prefix", "base_prefix" and "platform"
Franz Glasner <fzglas.hg@dom66.de>
parents:
692
diff
changeset
|
293 self.assertEqual(u(sys.platform), cfg.getvar_s("SYS:platform")) |
|
57fe110c50c8
Implement a new "SYS" namespace with "prefix", "base_prefix" and "platform"
Franz Glasner <fzglas.hg@dom66.de>
parents:
692
diff
changeset
|
294 if hasattr(sys, "base_prefix"): |
|
57fe110c50c8
Implement a new "SYS" namespace with "prefix", "base_prefix" and "platform"
Franz Glasner <fzglas.hg@dom66.de>
parents:
692
diff
changeset
|
295 self.assertEqual(u(sys.base_prefix), |
|
57fe110c50c8
Implement a new "SYS" namespace with "prefix", "base_prefix" and "platform"
Franz Glasner <fzglas.hg@dom66.de>
parents:
692
diff
changeset
|
296 cfg.getvar_s("SYS:base_prefix")) |
|
57fe110c50c8
Implement a new "SYS" namespace with "prefix", "base_prefix" and "platform"
Franz Glasner <fzglas.hg@dom66.de>
parents:
692
diff
changeset
|
297 else: |
|
57fe110c50c8
Implement a new "SYS" namespace with "prefix", "base_prefix" and "platform"
Franz Glasner <fzglas.hg@dom66.de>
parents:
692
diff
changeset
|
298 self.assertRaises(KeyError, cfg.getvar_s, "SYS:base_prefix") |
|
116
c37fa787c022
More unittests for fetching namespaced variables and filters
Franz Glasner <hg@dom66.de>
parents:
113
diff
changeset
|
299 |
|
314
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
300 def test03_namespace_l(self): |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
301 cfg = self._load( |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
302 os.path.join(TESTDATADIR, "conf20.yml"), |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
303 os.path.join(TESTDATADIR, "conf21.yml"), |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
304 os.path.join(TESTDATADIR, "conf22.ini")) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
305 self.assertEqual(u(os.getcwd()), cfg.getvarl("cwd", namespace="OS")) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
306 self.assertEqual(u(platform.python_version()), |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
307 cfg.getvarl_s("version", namespace="PY")) |
|
697
57fe110c50c8
Implement a new "SYS" namespace with "prefix", "base_prefix" and "platform"
Franz Glasner <fzglas.hg@dom66.de>
parents:
692
diff
changeset
|
308 self.assertEqual(u(sys.prefix), |
|
57fe110c50c8
Implement a new "SYS" namespace with "prefix", "base_prefix" and "platform"
Franz Glasner <fzglas.hg@dom66.de>
parents:
692
diff
changeset
|
309 cfg.getvarl_s("prefix", namespace="SYS")) |
|
314
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
310 |
|
116
c37fa787c022
More unittests for fetching namespaced variables and filters
Franz Glasner <hg@dom66.de>
parents:
113
diff
changeset
|
311 def test04_no_filter(self): |
|
c37fa787c022
More unittests for fetching namespaced variables and filters
Franz Glasner <hg@dom66.de>
parents:
113
diff
changeset
|
312 cfg = self._load( |
|
c37fa787c022
More unittests for fetching namespaced variables and filters
Franz Glasner <hg@dom66.de>
parents:
113
diff
changeset
|
313 os.path.join(TESTDATADIR, "conf20.yml"), |
|
c37fa787c022
More unittests for fetching namespaced variables and filters
Franz Glasner <hg@dom66.de>
parents:
113
diff
changeset
|
314 os.path.join(TESTDATADIR, "conf21.yml"), |
|
c37fa787c022
More unittests for fetching namespaced variables and filters
Franz Glasner <hg@dom66.de>
parents:
113
diff
changeset
|
315 os.path.join(TESTDATADIR, "conf22.ini")) |
|
c37fa787c022
More unittests for fetching namespaced variables and filters
Franz Glasner <hg@dom66.de>
parents:
113
diff
changeset
|
316 |
|
c37fa787c022
More unittests for fetching namespaced variables and filters
Franz Glasner <hg@dom66.de>
parents:
113
diff
changeset
|
317 def _look(): |
|
c37fa787c022
More unittests for fetching namespaced variables and filters
Franz Glasner <hg@dom66.de>
parents:
113
diff
changeset
|
318 return cfg.getvar("OS:cwd|upper") |
|
c37fa787c022
More unittests for fetching namespaced variables and filters
Franz Glasner <hg@dom66.de>
parents:
113
diff
changeset
|
319 |
|
c37fa787c022
More unittests for fetching namespaced variables and filters
Franz Glasner <hg@dom66.de>
parents:
113
diff
changeset
|
320 self.assertRaises(KeyError, _look) |
|
c37fa787c022
More unittests for fetching namespaced variables and filters
Franz Glasner <hg@dom66.de>
parents:
113
diff
changeset
|
321 |
|
314
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
322 def test04_no_filter_l(self): |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
323 cfg = self._load( |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
324 os.path.join(TESTDATADIR, "conf20.yml"), |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
325 os.path.join(TESTDATADIR, "conf21.yml"), |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
326 os.path.join(TESTDATADIR, "conf22.ini")) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
327 |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
328 def _look(): |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
329 return cfg.getvarl("cwd|upper", namespace="OS") |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
330 |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
331 self.assertRaises(KeyError, _look) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
332 |
|
144
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
333 def test05_comments(self): |
|
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
334 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml"), |
|
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
335 os.path.join(TESTDATADIR, "conf21.yml"), |
|
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
336 os.path.join(TESTDATADIR, "conf22.ini"), |
|
198
0b855758ba08
An additional TOML-related unittest (types)
Franz Glasner <fzglas.hg@dom66.de>
parents:
196
diff
changeset
|
337 os.path.join(TESTDATADIR, "conf23.json"), |
|
0b855758ba08
An additional TOML-related unittest (types)
Franz Glasner <fzglas.hg@dom66.de>
parents:
196
diff
changeset
|
338 os.path.join(TESTDATADIR, "conf24.toml")) |
|
144
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
339 |
|
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
340 def _c(name): |
|
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
341 def _f(): |
|
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
342 cfg.getvar_s(name) |
|
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
343 return _f |
|
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
344 |
|
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
345 # Variables with leading underscores are *not* imported by default |
|
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
346 self.assertEqual(0o0027, int(cfg.getvar_s("process.umask"), 0)) |
|
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
347 self.assertRaises(KeyError, _c("process.__doc1")) |
|
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
348 self.assertRaises(KeyError, _c("db.__comment1")) |
|
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
349 self.assertRaises(KeyError, _c("db.user.__doc2")) |
|
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
350 |
|
314
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
351 def test05_comments_l(self): |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
352 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml"), |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
353 os.path.join(TESTDATADIR, "conf21.yml"), |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
354 os.path.join(TESTDATADIR, "conf22.ini"), |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
355 os.path.join(TESTDATADIR, "conf23.json"), |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
356 os.path.join(TESTDATADIR, "conf24.toml")) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
357 |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
358 def _c(*names): |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
359 def _f(): |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
360 cfg.getvarl_s(*names) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
361 return _f |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
362 |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
363 # Variables with leading underscores are *not* imported by default |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
364 self.assertEqual(0o0027, int(cfg.getvarl_s("process", "umask"), 0)) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
365 self.assertRaises(KeyError, _c("process", "__doc1")) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
366 self.assertRaises(KeyError, _c("db", "__comment1")) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
367 self.assertRaises(KeyError, _c("db", "user", "__doc2")) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
368 |
|
146
bbf47bfb48a2
Add a unittest that scans the complete configuration dict for comment keys
Franz Glasner <hg@dom66.de>
parents:
144
diff
changeset
|
369 def test06_check_all_comments(self): |
|
bbf47bfb48a2
Add a unittest that scans the complete configuration dict for comment keys
Franz Glasner <hg@dom66.de>
parents:
144
diff
changeset
|
370 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml"), |
|
bbf47bfb48a2
Add a unittest that scans the complete configuration dict for comment keys
Franz Glasner <hg@dom66.de>
parents:
144
diff
changeset
|
371 os.path.join(TESTDATADIR, "conf21.yml"), |
|
bbf47bfb48a2
Add a unittest that scans the complete configuration dict for comment keys
Franz Glasner <hg@dom66.de>
parents:
144
diff
changeset
|
372 os.path.join(TESTDATADIR, "conf22.ini"), |
|
198
0b855758ba08
An additional TOML-related unittest (types)
Franz Glasner <fzglas.hg@dom66.de>
parents:
196
diff
changeset
|
373 os.path.join(TESTDATADIR, "conf23.json"), |
|
0b855758ba08
An additional TOML-related unittest (types)
Franz Glasner <fzglas.hg@dom66.de>
parents:
196
diff
changeset
|
374 os.path.join(TESTDATADIR, "conf24.toml")) |
|
146
bbf47bfb48a2
Add a unittest that scans the complete configuration dict for comment keys
Franz Glasner <hg@dom66.de>
parents:
144
diff
changeset
|
375 |
|
bbf47bfb48a2
Add a unittest that scans the complete configuration dict for comment keys
Franz Glasner <hg@dom66.de>
parents:
144
diff
changeset
|
376 def _check(d): |
|
bbf47bfb48a2
Add a unittest that scans the complete configuration dict for comment keys
Franz Glasner <hg@dom66.de>
parents:
144
diff
changeset
|
377 for k, v in d.items(): |
|
bbf47bfb48a2
Add a unittest that scans the complete configuration dict for comment keys
Franz Glasner <hg@dom66.de>
parents:
144
diff
changeset
|
378 self.assertFalse(configmix._is_comment(k)) |
|
bbf47bfb48a2
Add a unittest that scans the complete configuration dict for comment keys
Franz Glasner <hg@dom66.de>
parents:
144
diff
changeset
|
379 if isinstance(v, dict): |
|
bbf47bfb48a2
Add a unittest that scans the complete configuration dict for comment keys
Franz Glasner <hg@dom66.de>
parents:
144
diff
changeset
|
380 _check(v) |
|
bbf47bfb48a2
Add a unittest that scans the complete configuration dict for comment keys
Franz Glasner <hg@dom66.de>
parents:
144
diff
changeset
|
381 |
|
bbf47bfb48a2
Add a unittest that scans the complete configuration dict for comment keys
Franz Glasner <hg@dom66.de>
parents:
144
diff
changeset
|
382 _check(cfg) |
|
bbf47bfb48a2
Add a unittest that scans the complete configuration dict for comment keys
Franz Glasner <hg@dom66.de>
parents:
144
diff
changeset
|
383 |
|
276
af371f9c016d
Allow deletion of key-value pairs when merging is done.
Franz Glasner <fzglas.hg@dom66.de>
parents:
251
diff
changeset
|
384 def test07_deletions(self): |
|
af371f9c016d
Allow deletion of key-value pairs when merging is done.
Franz Glasner <fzglas.hg@dom66.de>
parents:
251
diff
changeset
|
385 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml"), |
|
af371f9c016d
Allow deletion of key-value pairs when merging is done.
Franz Glasner <fzglas.hg@dom66.de>
parents:
251
diff
changeset
|
386 os.path.join(TESTDATADIR, "conf21.yml"), |
|
af371f9c016d
Allow deletion of key-value pairs when merging is done.
Franz Glasner <fzglas.hg@dom66.de>
parents:
251
diff
changeset
|
387 os.path.join(TESTDATADIR, "conf22.ini"), |
|
af371f9c016d
Allow deletion of key-value pairs when merging is done.
Franz Glasner <fzglas.hg@dom66.de>
parents:
251
diff
changeset
|
388 os.path.join(TESTDATADIR, "conf23.json"), |
|
af371f9c016d
Allow deletion of key-value pairs when merging is done.
Franz Glasner <fzglas.hg@dom66.de>
parents:
251
diff
changeset
|
389 os.path.join(TESTDATADIR, "conf24.toml"), |
|
af371f9c016d
Allow deletion of key-value pairs when merging is done.
Franz Glasner <fzglas.hg@dom66.de>
parents:
251
diff
changeset
|
390 os.path.join(TESTDATADIR, "delete-in-dict.yml")) |
|
af371f9c016d
Allow deletion of key-value pairs when merging is done.
Franz Glasner <fzglas.hg@dom66.de>
parents:
251
diff
changeset
|
391 # automatic clean-up |
|
af371f9c016d
Allow deletion of key-value pairs when merging is done.
Franz Glasner <fzglas.hg@dom66.de>
parents:
251
diff
changeset
|
392 self.assertRaises(KeyError, cfg.getvar_s, "not-deleted") |
|
af371f9c016d
Allow deletion of key-value pairs when merging is done.
Franz Glasner <fzglas.hg@dom66.de>
parents:
251
diff
changeset
|
393 # explicit deletion |
|
af371f9c016d
Allow deletion of key-value pairs when merging is done.
Franz Glasner <fzglas.hg@dom66.de>
parents:
251
diff
changeset
|
394 self.assertRaises(KeyError, cfg.getvar_s, "to-be-deleted") |
|
af371f9c016d
Allow deletion of key-value pairs when merging is done.
Franz Glasner <fzglas.hg@dom66.de>
parents:
251
diff
changeset
|
395 self.assertRaises(KeyError, cfg.getvar_s, "db.user.name") |
| 323 | 396 self.assertEqual("the-database-password-2", cfg.getvar_s("db.user.pwd")) |
|
276
af371f9c016d
Allow deletion of key-value pairs when merging is done.
Franz Glasner <fzglas.hg@dom66.de>
parents:
251
diff
changeset
|
397 self.assertRaises(KeyError, cfg.getvar_s, "test.Str") |
|
af371f9c016d
Allow deletion of key-value pairs when merging is done.
Franz Glasner <fzglas.hg@dom66.de>
parents:
251
diff
changeset
|
398 self.assertEqual("not a list any more", cfg.getvar_s("test.List")) |
|
af371f9c016d
Allow deletion of key-value pairs when merging is done.
Franz Glasner <fzglas.hg@dom66.de>
parents:
251
diff
changeset
|
399 self.assertEqual("the last value", |
|
af371f9c016d
Allow deletion of key-value pairs when merging is done.
Franz Glasner <fzglas.hg@dom66.de>
parents:
251
diff
changeset
|
400 cfg.getvar_s("to-be-deleted-but-reassigned")) |
|
af371f9c016d
Allow deletion of key-value pairs when merging is done.
Franz Glasner <fzglas.hg@dom66.de>
parents:
251
diff
changeset
|
401 |
|
314
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
402 def test07_deletions_l(self): |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
403 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml"), |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
404 os.path.join(TESTDATADIR, "conf21.yml"), |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
405 os.path.join(TESTDATADIR, "conf22.ini"), |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
406 os.path.join(TESTDATADIR, "conf23.json"), |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
407 os.path.join(TESTDATADIR, "conf24.toml"), |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
408 os.path.join(TESTDATADIR, "delete-in-dict.yml")) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
409 # automatic clean-up |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
410 self.assertRaises(KeyError, cfg.getvarl_s, "not-deleted") |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
411 # explicit deletion |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
412 self.assertRaises(KeyError, cfg.getvarl_s, "to-be-deleted") |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
413 self.assertRaises(KeyError, cfg.getvarl_s, "db" "user.name") |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
414 self.assertEqual("the-database-password-2", |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
415 cfg.getvarl_s("db", "user", "pwd")) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
416 self.assertRaises(KeyError, cfg.getvarl_s, "test", "Str") |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
417 self.assertEqual("not a list any more", cfg.getvarl_s("test", "List")) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
418 self.assertEqual("the last value", |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
419 cfg.getvarl_s("to-be-deleted-but-reassigned")) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
420 |
|
351
efbf7ba40287
Unittests for the "|None" filter
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
340
diff
changeset
|
421 def test08_None_filter_single(self): |
|
efbf7ba40287
Unittests for the "|None" filter
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
340
diff
changeset
|
422 cfg = self._load() |
|
525
be6ef72c55d5
Change Configuration.expand_variable() to Configuration.interpolate_variables()
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
516
diff
changeset
|
423 x = cfg.interpolate_variables("{{non-existing|None}}") |
|
351
efbf7ba40287
Unittests for the "|None" filter
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
340
diff
changeset
|
424 self.assertIsNone(x) |
|
efbf7ba40287
Unittests for the "|None" filter
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
340
diff
changeset
|
425 |
|
efbf7ba40287
Unittests for the "|None" filter
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
340
diff
changeset
|
426 def test09_None_filter_embedded(self): |
|
efbf7ba40287
Unittests for the "|None" filter
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
340
diff
changeset
|
427 cfg = self._load() |
|
525
be6ef72c55d5
Change Configuration.expand_variable() to Configuration.interpolate_variables()
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
516
diff
changeset
|
428 x = cfg.interpolate_variables("A{{non-existing|None}}Z") |
|
355
260354e9a7f9
Avoid DeprecationWarning: assertEquals() -> assertEqual()
Franz Glasner <fzglas.hg@dom66.de>
parents:
352
diff
changeset
|
429 self.assertEqual("AZ", x) |
|
351
efbf7ba40287
Unittests for the "|None" filter
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
340
diff
changeset
|
430 |
|
352
2b209bdf6995
Implement the "Empty" filter.
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
351
diff
changeset
|
431 def test10_Empty_filtersingle(self): |
|
2b209bdf6995
Implement the "Empty" filter.
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
351
diff
changeset
|
432 cfg = self._load() |
|
525
be6ef72c55d5
Change Configuration.expand_variable() to Configuration.interpolate_variables()
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
516
diff
changeset
|
433 x = cfg.interpolate_variables("{{non-existing|Empty}}") |
|
355
260354e9a7f9
Avoid DeprecationWarning: assertEquals() -> assertEqual()
Franz Glasner <fzglas.hg@dom66.de>
parents:
352
diff
changeset
|
434 self.assertEqual("", x) |
|
352
2b209bdf6995
Implement the "Empty" filter.
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
351
diff
changeset
|
435 |
|
356
a5c792074ec9
Unittest to check "None" and "Empty" filters for existing values: they just pass through unchanged
Franz Glasner <fzglas.hg@dom66.de>
parents:
355
diff
changeset
|
436 def test11_None_filter_pass_through(self): |
|
a5c792074ec9
Unittest to check "None" and "Empty" filters for existing values: they just pass through unchanged
Franz Glasner <fzglas.hg@dom66.de>
parents:
355
diff
changeset
|
437 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml"), |
|
a5c792074ec9
Unittest to check "None" and "Empty" filters for existing values: they just pass through unchanged
Franz Glasner <fzglas.hg@dom66.de>
parents:
355
diff
changeset
|
438 os.path.join(TESTDATADIR, "conf21.yml"), |
|
a5c792074ec9
Unittest to check "None" and "Empty" filters for existing values: they just pass through unchanged
Franz Glasner <fzglas.hg@dom66.de>
parents:
355
diff
changeset
|
439 os.path.join(TESTDATADIR, "conf22.ini"), |
|
a5c792074ec9
Unittest to check "None" and "Empty" filters for existing values: they just pass through unchanged
Franz Glasner <fzglas.hg@dom66.de>
parents:
355
diff
changeset
|
440 os.path.join(TESTDATADIR, "conf23.json"), |
|
a5c792074ec9
Unittest to check "None" and "Empty" filters for existing values: they just pass through unchanged
Franz Glasner <fzglas.hg@dom66.de>
parents:
355
diff
changeset
|
441 os.path.join(TESTDATADIR, "conf24.toml")) |
|
525
be6ef72c55d5
Change Configuration.expand_variable() to Configuration.interpolate_variables()
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
516
diff
changeset
|
442 x = cfg.interpolate_variables("{{intl.cache.items|None}}") |
|
356
a5c792074ec9
Unittest to check "None" and "Empty" filters for existing values: they just pass through unchanged
Franz Glasner <fzglas.hg@dom66.de>
parents:
355
diff
changeset
|
443 self.assertEqual(10, x) |
|
a5c792074ec9
Unittest to check "None" and "Empty" filters for existing values: they just pass through unchanged
Franz Glasner <fzglas.hg@dom66.de>
parents:
355
diff
changeset
|
444 |
|
a5c792074ec9
Unittest to check "None" and "Empty" filters for existing values: they just pass through unchanged
Franz Glasner <fzglas.hg@dom66.de>
parents:
355
diff
changeset
|
445 def test12_Empty_filter_pass_through(self): |
|
a5c792074ec9
Unittest to check "None" and "Empty" filters for existing values: they just pass through unchanged
Franz Glasner <fzglas.hg@dom66.de>
parents:
355
diff
changeset
|
446 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml"), |
|
a5c792074ec9
Unittest to check "None" and "Empty" filters for existing values: they just pass through unchanged
Franz Glasner <fzglas.hg@dom66.de>
parents:
355
diff
changeset
|
447 os.path.join(TESTDATADIR, "conf21.yml"), |
|
a5c792074ec9
Unittest to check "None" and "Empty" filters for existing values: they just pass through unchanged
Franz Glasner <fzglas.hg@dom66.de>
parents:
355
diff
changeset
|
448 os.path.join(TESTDATADIR, "conf22.ini"), |
|
a5c792074ec9
Unittest to check "None" and "Empty" filters for existing values: they just pass through unchanged
Franz Glasner <fzglas.hg@dom66.de>
parents:
355
diff
changeset
|
449 os.path.join(TESTDATADIR, "conf23.json"), |
|
a5c792074ec9
Unittest to check "None" and "Empty" filters for existing values: they just pass through unchanged
Franz Glasner <fzglas.hg@dom66.de>
parents:
355
diff
changeset
|
450 os.path.join(TESTDATADIR, "conf24.toml")) |
|
525
be6ef72c55d5
Change Configuration.expand_variable() to Configuration.interpolate_variables()
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
516
diff
changeset
|
451 x = cfg.interpolate_variables("{{intl.cache.items|Empty}}") |
|
356
a5c792074ec9
Unittest to check "None" and "Empty" filters for existing values: they just pass through unchanged
Franz Glasner <fzglas.hg@dom66.de>
parents:
355
diff
changeset
|
452 self.assertEqual(10, x) |
|
647
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
453 x = cfg.interpolate_variables("{{intl.cache.items|Empty}}") |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
454 self.assertEqual(10, x) |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
455 |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
456 def test12a_Empty_filter_pass_through_without_cache(self): |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
457 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml"), |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
458 os.path.join(TESTDATADIR, "conf21.yml"), |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
459 os.path.join(TESTDATADIR, "conf22.ini"), |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
460 os.path.join(TESTDATADIR, "conf23.json"), |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
461 os.path.join(TESTDATADIR, "conf24.toml")) |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
462 cfg.disable_cache() |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
463 x = cfg.interpolate_variables("{{intl.cache.items|Empty}}") |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
464 self.assertEqual(10, x) |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
465 x = cfg.interpolate_variables("{{intl.cache.items|Empty}}") |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
466 self.assertEqual(10, x) |
|
356
a5c792074ec9
Unittest to check "None" and "Empty" filters for existing values: they just pass through unchanged
Franz Glasner <fzglas.hg@dom66.de>
parents:
355
diff
changeset
|
467 |
|
364
1941f0188e81
FIX: Handle a "default" keyword parameter in ".getvar()" properly.
Franz Glasner <fzglas.hg@dom66.de>
parents:
356
diff
changeset
|
468 def test13_keyerror(self): |
|
1941f0188e81
FIX: Handle a "default" keyword parameter in ".getvar()" properly.
Franz Glasner <fzglas.hg@dom66.de>
parents:
356
diff
changeset
|
469 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
1941f0188e81
FIX: Handle a "default" keyword parameter in ".getvar()" properly.
Franz Glasner <fzglas.hg@dom66.de>
parents:
356
diff
changeset
|
470 self.assertRaises(KeyError, cfg.getvar_s, "non.existing.key") |
|
651
fe1299825a9a
Tests for indexed accesses (jail and non-jail)
Franz Glasner <fzglas.hg@dom66.de>
parents:
647
diff
changeset
|
471 self.assertRaises(KeyError, cfg.getvar_s, "non.existing.key") |
|
647
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
472 |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
473 def test13a_keyerror_without_cache(self): |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
474 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
475 cfg.disable_cache() |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
476 self.assertRaises(KeyError, cfg.getvar_s, "non.existing.key") |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
477 self.assertRaises(KeyError, cfg.getvar_s, "non.existing.key") |
|
364
1941f0188e81
FIX: Handle a "default" keyword parameter in ".getvar()" properly.
Franz Glasner <fzglas.hg@dom66.de>
parents:
356
diff
changeset
|
478 |
|
1941f0188e81
FIX: Handle a "default" keyword parameter in ".getvar()" properly.
Franz Glasner <fzglas.hg@dom66.de>
parents:
356
diff
changeset
|
479 def test14_getvar_with_default(self): |
|
1941f0188e81
FIX: Handle a "default" keyword parameter in ".getvar()" properly.
Franz Glasner <fzglas.hg@dom66.de>
parents:
356
diff
changeset
|
480 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
1941f0188e81
FIX: Handle a "default" keyword parameter in ".getvar()" properly.
Franz Glasner <fzglas.hg@dom66.de>
parents:
356
diff
changeset
|
481 self.assertEqual("999", cfg.getvar("non.existing.key", default="999")) |
|
1941f0188e81
FIX: Handle a "default" keyword parameter in ".getvar()" properly.
Franz Glasner <fzglas.hg@dom66.de>
parents:
356
diff
changeset
|
482 |
|
625
f167f8db4624
A unittest for the assertion, that a given default must be returned as identical object and not as copy
Franz Glasner <fzglas.hg@dom66.de>
parents:
619
diff
changeset
|
483 def test14_getvar_with_original_default(self): |
|
f167f8db4624
A unittest for the assertion, that a given default must be returned as identical object and not as copy
Franz Glasner <fzglas.hg@dom66.de>
parents:
619
diff
changeset
|
484 # The default must be the original and not a copy |
|
f167f8db4624
A unittest for the assertion, that a given default must be returned as identical object and not as copy
Franz Glasner <fzglas.hg@dom66.de>
parents:
619
diff
changeset
|
485 dflt = {"foo": "bar"} |
|
f167f8db4624
A unittest for the assertion, that a given default must be returned as identical object and not as copy
Franz Glasner <fzglas.hg@dom66.de>
parents:
619
diff
changeset
|
486 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
f167f8db4624
A unittest for the assertion, that a given default must be returned as identical object and not as copy
Franz Glasner <fzglas.hg@dom66.de>
parents:
619
diff
changeset
|
487 self.assertTrue(cfg.getvar("non.existing.key", default=dflt) is dflt) |
|
f167f8db4624
A unittest for the assertion, that a given default must be returned as identical object and not as copy
Franz Glasner <fzglas.hg@dom66.de>
parents:
619
diff
changeset
|
488 |
|
364
1941f0188e81
FIX: Handle a "default" keyword parameter in ".getvar()" properly.
Franz Glasner <fzglas.hg@dom66.de>
parents:
356
diff
changeset
|
489 def test15_getvar_s_with_default(self): |
|
1941f0188e81
FIX: Handle a "default" keyword parameter in ".getvar()" properly.
Franz Glasner <fzglas.hg@dom66.de>
parents:
356
diff
changeset
|
490 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
1941f0188e81
FIX: Handle a "default" keyword parameter in ".getvar()" properly.
Franz Glasner <fzglas.hg@dom66.de>
parents:
356
diff
changeset
|
491 self.assertEqual("999", cfg.getvar_s("non.existing.key", |
|
1941f0188e81
FIX: Handle a "default" keyword parameter in ".getvar()" properly.
Franz Glasner <fzglas.hg@dom66.de>
parents:
356
diff
changeset
|
492 default="999")) |
|
647
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
493 self.assertEqual("999", cfg.getvar_s("non.existing.key", |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
494 default="999")) |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
495 |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
496 def test15a_getvar_s_with_default_without_cache(self): |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
497 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
498 cfg.disable_cache() |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
499 self.assertEqual("999", cfg.getvar_s("non.existing.key", |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
500 default="999")) |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
501 self.assertEqual("999", cfg.getvar_s("non.existing.key", |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
502 default="999")) |
|
364
1941f0188e81
FIX: Handle a "default" keyword parameter in ".getvar()" properly.
Franz Glasner <fzglas.hg@dom66.de>
parents:
356
diff
changeset
|
503 |
|
625
f167f8db4624
A unittest for the assertion, that a given default must be returned as identical object and not as copy
Franz Glasner <fzglas.hg@dom66.de>
parents:
619
diff
changeset
|
504 def test15_getvar_s_with_original_default(self): |
|
f167f8db4624
A unittest for the assertion, that a given default must be returned as identical object and not as copy
Franz Glasner <fzglas.hg@dom66.de>
parents:
619
diff
changeset
|
505 # The default must be the original and not a copy |
|
f167f8db4624
A unittest for the assertion, that a given default must be returned as identical object and not as copy
Franz Glasner <fzglas.hg@dom66.de>
parents:
619
diff
changeset
|
506 dflt = {"foo2": "bar2"} |
|
f167f8db4624
A unittest for the assertion, that a given default must be returned as identical object and not as copy
Franz Glasner <fzglas.hg@dom66.de>
parents:
619
diff
changeset
|
507 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
f167f8db4624
A unittest for the assertion, that a given default must be returned as identical object and not as copy
Franz Glasner <fzglas.hg@dom66.de>
parents:
619
diff
changeset
|
508 self.assertTrue(cfg.getvar_s("non.existing.key", default=dflt) is dflt) |
|
f167f8db4624
A unittest for the assertion, that a given default must be returned as identical object and not as copy
Franz Glasner <fzglas.hg@dom66.de>
parents:
619
diff
changeset
|
509 |
|
629
2426fa273a29
Test defaults for interpolation errors
Franz Glasner <fzglas.hg@dom66.de>
parents:
628
diff
changeset
|
510 def test15_getvar_s_substituting_error_with_original_default(self): |
|
2426fa273a29
Test defaults for interpolation errors
Franz Glasner <fzglas.hg@dom66.de>
parents:
628
diff
changeset
|
511 # The default must be the original and not a copy |
|
2426fa273a29
Test defaults for interpolation errors
Franz Glasner <fzglas.hg@dom66.de>
parents:
628
diff
changeset
|
512 dflt = {"foo22": "bar22"} |
|
2426fa273a29
Test defaults for interpolation errors
Franz Glasner <fzglas.hg@dom66.de>
parents:
628
diff
changeset
|
513 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
2426fa273a29
Test defaults for interpolation errors
Franz Glasner <fzglas.hg@dom66.de>
parents:
628
diff
changeset
|
514 # exists ... |
|
2426fa273a29
Test defaults for interpolation errors
Franz Glasner <fzglas.hg@dom66.de>
parents:
628
diff
changeset
|
515 cfg.getvar(u"intl.localedir") |
|
2426fa273a29
Test defaults for interpolation errors
Franz Glasner <fzglas.hg@dom66.de>
parents:
628
diff
changeset
|
516 # ... but cannot interpolated |
|
2426fa273a29
Test defaults for interpolation errors
Franz Glasner <fzglas.hg@dom66.de>
parents:
628
diff
changeset
|
517 self.assertTrue(cfg.getvar_s(u"intl.localedir", default=dflt) is dflt) |
|
2426fa273a29
Test defaults for interpolation errors
Franz Glasner <fzglas.hg@dom66.de>
parents:
628
diff
changeset
|
518 |
|
625
f167f8db4624
A unittest for the assertion, that a given default must be returned as identical object and not as copy
Franz Glasner <fzglas.hg@dom66.de>
parents:
619
diff
changeset
|
519 def test15b_getvarl_with_original_default(self): |
|
f167f8db4624
A unittest for the assertion, that a given default must be returned as identical object and not as copy
Franz Glasner <fzglas.hg@dom66.de>
parents:
619
diff
changeset
|
520 # The default must be the original and not a copy |
|
f167f8db4624
A unittest for the assertion, that a given default must be returned as identical object and not as copy
Franz Glasner <fzglas.hg@dom66.de>
parents:
619
diff
changeset
|
521 dflt = {"foo2": "bar2"} |
|
f167f8db4624
A unittest for the assertion, that a given default must be returned as identical object and not as copy
Franz Glasner <fzglas.hg@dom66.de>
parents:
619
diff
changeset
|
522 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
628
c56971e85496
FIX: Arguments when calling .getvarl() and .getvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
625
diff
changeset
|
523 self.assertTrue(cfg.getvarl(u"non", u"existing", u"key", |
|
625
f167f8db4624
A unittest for the assertion, that a given default must be returned as identical object and not as copy
Franz Glasner <fzglas.hg@dom66.de>
parents:
619
diff
changeset
|
524 default=dflt) is dflt) |
|
f167f8db4624
A unittest for the assertion, that a given default must be returned as identical object and not as copy
Franz Glasner <fzglas.hg@dom66.de>
parents:
619
diff
changeset
|
525 |
|
f167f8db4624
A unittest for the assertion, that a given default must be returned as identical object and not as copy
Franz Glasner <fzglas.hg@dom66.de>
parents:
619
diff
changeset
|
526 def test15c_getvarl_s_with_original_default(self): |
|
f167f8db4624
A unittest for the assertion, that a given default must be returned as identical object and not as copy
Franz Glasner <fzglas.hg@dom66.de>
parents:
619
diff
changeset
|
527 # The default must be the original and not a copy |
|
f167f8db4624
A unittest for the assertion, that a given default must be returned as identical object and not as copy
Franz Glasner <fzglas.hg@dom66.de>
parents:
619
diff
changeset
|
528 dflt = {"foo3": "bar3"} |
|
f167f8db4624
A unittest for the assertion, that a given default must be returned as identical object and not as copy
Franz Glasner <fzglas.hg@dom66.de>
parents:
619
diff
changeset
|
529 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
628
c56971e85496
FIX: Arguments when calling .getvarl() and .getvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
625
diff
changeset
|
530 self.assertTrue(cfg.getvarl_s(u"non", u"existing", u"key4", |
|
625
f167f8db4624
A unittest for the assertion, that a given default must be returned as identical object and not as copy
Franz Glasner <fzglas.hg@dom66.de>
parents:
619
diff
changeset
|
531 default=dflt) is dflt) |
|
f167f8db4624
A unittest for the assertion, that a given default must be returned as identical object and not as copy
Franz Glasner <fzglas.hg@dom66.de>
parents:
619
diff
changeset
|
532 |
|
629
2426fa273a29
Test defaults for interpolation errors
Franz Glasner <fzglas.hg@dom66.de>
parents:
628
diff
changeset
|
533 def test15d_getvarl_s_substituting_error_with_original_default(self): |
|
2426fa273a29
Test defaults for interpolation errors
Franz Glasner <fzglas.hg@dom66.de>
parents:
628
diff
changeset
|
534 dflt = {"foo4": "bar4"} |
|
2426fa273a29
Test defaults for interpolation errors
Franz Glasner <fzglas.hg@dom66.de>
parents:
628
diff
changeset
|
535 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
2426fa273a29
Test defaults for interpolation errors
Franz Glasner <fzglas.hg@dom66.de>
parents:
628
diff
changeset
|
536 # key exists ... |
|
2426fa273a29
Test defaults for interpolation errors
Franz Glasner <fzglas.hg@dom66.de>
parents:
628
diff
changeset
|
537 cfg.getvarl(u"intl", u"localedir") |
|
2426fa273a29
Test defaults for interpolation errors
Franz Glasner <fzglas.hg@dom66.de>
parents:
628
diff
changeset
|
538 # ... but cannot interpolated |
|
2426fa273a29
Test defaults for interpolation errors
Franz Glasner <fzglas.hg@dom66.de>
parents:
628
diff
changeset
|
539 self.assertTrue(cfg.getvarl_s(u"intl", u"localedir", |
|
2426fa273a29
Test defaults for interpolation errors
Franz Glasner <fzglas.hg@dom66.de>
parents:
628
diff
changeset
|
540 default=dflt) is dflt) |
|
2426fa273a29
Test defaults for interpolation errors
Franz Glasner <fzglas.hg@dom66.de>
parents:
628
diff
changeset
|
541 |
|
364
1941f0188e81
FIX: Handle a "default" keyword parameter in ".getvar()" properly.
Franz Glasner <fzglas.hg@dom66.de>
parents:
356
diff
changeset
|
542 def test16_getintvar_s_with_default(self): |
|
1941f0188e81
FIX: Handle a "default" keyword parameter in ".getvar()" properly.
Franz Glasner <fzglas.hg@dom66.de>
parents:
356
diff
changeset
|
543 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
1941f0188e81
FIX: Handle a "default" keyword parameter in ".getvar()" properly.
Franz Glasner <fzglas.hg@dom66.de>
parents:
356
diff
changeset
|
544 self.assertEqual(9999, cfg.getintvar_s("non.existing.key", |
|
1941f0188e81
FIX: Handle a "default" keyword parameter in ".getvar()" properly.
Franz Glasner <fzglas.hg@dom66.de>
parents:
356
diff
changeset
|
545 default=9999)) |
|
1941f0188e81
FIX: Handle a "default" keyword parameter in ".getvar()" properly.
Franz Glasner <fzglas.hg@dom66.de>
parents:
356
diff
changeset
|
546 def test17_getintvar_s_with_default(self): |
|
1941f0188e81
FIX: Handle a "default" keyword parameter in ".getvar()" properly.
Franz Glasner <fzglas.hg@dom66.de>
parents:
356
diff
changeset
|
547 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
1941f0188e81
FIX: Handle a "default" keyword parameter in ".getvar()" properly.
Franz Glasner <fzglas.hg@dom66.de>
parents:
356
diff
changeset
|
548 self.assertFalse(cfg.getboolvar_s("non.existing.key", |
|
372
ac3e3cd6faae
FIX: 4ff02a4f401a made a somewhat wrong fix for Python 2.7: now the real fix takes into account that all text types are supposed to be Unicode in Python 2
Franz Glasner <fzglas.hg@dom66.de>
parents:
371
diff
changeset
|
549 default=u('false'))) |
|
364
1941f0188e81
FIX: Handle a "default" keyword parameter in ".getvar()" properly.
Franz Glasner <fzglas.hg@dom66.de>
parents:
356
diff
changeset
|
550 |
|
370
18622d265602
Unittests for ".getfirstvar()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
369
diff
changeset
|
551 def test18_getfirstvar_nonexisting(self): |
|
18622d265602
Unittests for ".getfirstvar()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
369
diff
changeset
|
552 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
18622d265602
Unittests for ".getfirstvar()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
369
diff
changeset
|
553 self.assertRaises( |
|
18622d265602
Unittests for ".getfirstvar()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
369
diff
changeset
|
554 KeyError, |
|
18622d265602
Unittests for ".getfirstvar()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
369
diff
changeset
|
555 cfg.getfirstvar, |
|
18622d265602
Unittests for ".getfirstvar()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
369
diff
changeset
|
556 "db.non.existing.key", |
|
18622d265602
Unittests for ".getfirstvar()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
369
diff
changeset
|
557 "db.non.existing.key2") |
|
18622d265602
Unittests for ".getfirstvar()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
369
diff
changeset
|
558 |
|
18622d265602
Unittests for ".getfirstvar()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
369
diff
changeset
|
559 def test19_getfirstvar_nonexisting_default(self): |
|
18622d265602
Unittests for ".getfirstvar()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
369
diff
changeset
|
560 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
18622d265602
Unittests for ".getfirstvar()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
369
diff
changeset
|
561 self.assertIsNone(cfg.getfirstvar("db.non.existing.key", |
|
18622d265602
Unittests for ".getfirstvar()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
369
diff
changeset
|
562 "db.non.existing.key2", |
|
18622d265602
Unittests for ".getfirstvar()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
369
diff
changeset
|
563 "intl.non.existing", |
|
18622d265602
Unittests for ".getfirstvar()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
369
diff
changeset
|
564 default=None)) |
|
18622d265602
Unittests for ".getfirstvar()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
369
diff
changeset
|
565 |
|
18622d265602
Unittests for ".getfirstvar()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
369
diff
changeset
|
566 def test20_getfirstvar_existing(self): |
|
18622d265602
Unittests for ".getfirstvar()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
369
diff
changeset
|
567 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
18622d265602
Unittests for ".getfirstvar()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
369
diff
changeset
|
568 self.assertEqual("test-configmix", cfg.getfirstvar("intl.domain")) |
|
18622d265602
Unittests for ".getfirstvar()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
369
diff
changeset
|
569 self.assertEqual("test-configmix", cfg.getfirstvar("intl.domain", |
|
18622d265602
Unittests for ".getfirstvar()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
369
diff
changeset
|
570 "intl.fallback")) |
|
18622d265602
Unittests for ".getfirstvar()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
369
diff
changeset
|
571 self.assertEqual("de", cfg.getfirstvar("intl.fallback", |
|
18622d265602
Unittests for ".getfirstvar()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
369
diff
changeset
|
572 "intl.domain", |
|
18622d265602
Unittests for ".getfirstvar()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
369
diff
changeset
|
573 default=None)) |
|
18622d265602
Unittests for ".getfirstvar()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
369
diff
changeset
|
574 |
|
18622d265602
Unittests for ".getfirstvar()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
369
diff
changeset
|
575 self.assertEqual("de", cfg.getfirstvar("intl.non.existing", |
|
18622d265602
Unittests for ".getfirstvar()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
369
diff
changeset
|
576 "intl.fallback", |
|
18622d265602
Unittests for ".getfirstvar()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
369
diff
changeset
|
577 default=None)) |
|
18622d265602
Unittests for ".getfirstvar()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
369
diff
changeset
|
578 |
|
647
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
579 def test20a_getfirstvar_existing_without_cache(self): |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
580 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
581 cfg.disable_cache() |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
582 self.assertEqual("test-configmix", cfg.getfirstvar("intl.domain")) |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
583 self.assertEqual("test-configmix", cfg.getfirstvar("intl.domain", |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
584 "intl.fallback")) |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
585 self.assertEqual("de", cfg.getfirstvar("intl.fallback", |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
586 "intl.domain", |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
587 default=None)) |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
588 |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
589 self.assertEqual("de", cfg.getfirstvar("intl.non.existing", |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
590 "intl.fallback", |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
591 default=None)) |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
592 |
|
371
873b9d2ecb0b
Unittests for ".getfirstvar_s()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
370
diff
changeset
|
593 def test21_getfirstvar_s_existing(self): |
|
873b9d2ecb0b
Unittests for ".getfirstvar_s()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
370
diff
changeset
|
594 cfg = self._load( |
|
873b9d2ecb0b
Unittests for ".getfirstvar_s()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
370
diff
changeset
|
595 os.path.join(TESTDATADIR, "conf20.yml"), |
|
873b9d2ecb0b
Unittests for ".getfirstvar_s()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
370
diff
changeset
|
596 os.path.join(TESTDATADIR, "conf21.yml")) |
|
873b9d2ecb0b
Unittests for ".getfirstvar_s()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
370
diff
changeset
|
597 self.assertEqual( |
|
873b9d2ecb0b
Unittests for ".getfirstvar_s()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
370
diff
changeset
|
598 os.getcwd()+"/locale", |
|
873b9d2ecb0b
Unittests for ".getfirstvar_s()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
370
diff
changeset
|
599 cfg.getfirstvar_s("intl.non.existing", "intl.localedir")) |
|
873b9d2ecb0b
Unittests for ".getfirstvar_s()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
370
diff
changeset
|
600 self.assertEqual( |
|
873b9d2ecb0b
Unittests for ".getfirstvar_s()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
370
diff
changeset
|
601 os.getcwd()+"/locale", |
|
873b9d2ecb0b
Unittests for ".getfirstvar_s()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
370
diff
changeset
|
602 cfg.getfirstvar_s("intl.localedir", "intl.non.existing")) |
|
873b9d2ecb0b
Unittests for ".getfirstvar_s()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
370
diff
changeset
|
603 |
|
873b9d2ecb0b
Unittests for ".getfirstvar_s()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
370
diff
changeset
|
604 def test22_getfirstvar_s_non_existing(self): |
|
873b9d2ecb0b
Unittests for ".getfirstvar_s()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
370
diff
changeset
|
605 cfg = self._load( |
|
873b9d2ecb0b
Unittests for ".getfirstvar_s()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
370
diff
changeset
|
606 os.path.join(TESTDATADIR, "conf20.yml"), |
|
873b9d2ecb0b
Unittests for ".getfirstvar_s()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
370
diff
changeset
|
607 os.path.join(TESTDATADIR, "conf21.yml")) |
|
873b9d2ecb0b
Unittests for ".getfirstvar_s()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
370
diff
changeset
|
608 self.assertIsNone( |
|
873b9d2ecb0b
Unittests for ".getfirstvar_s()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
370
diff
changeset
|
609 cfg.getfirstvar_s("intl.non.existing", "intl.non.existing2", |
|
873b9d2ecb0b
Unittests for ".getfirstvar_s()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
370
diff
changeset
|
610 default=None)) |
|
873b9d2ecb0b
Unittests for ".getfirstvar_s()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
370
diff
changeset
|
611 self.assertRaises( |
|
873b9d2ecb0b
Unittests for ".getfirstvar_s()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
370
diff
changeset
|
612 KeyError, |
|
873b9d2ecb0b
Unittests for ".getfirstvar_s()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
370
diff
changeset
|
613 cfg.getfirstvar_s, |
|
873b9d2ecb0b
Unittests for ".getfirstvar_s()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
370
diff
changeset
|
614 "intl.non.existing", |
|
873b9d2ecb0b
Unittests for ".getfirstvar_s()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
370
diff
changeset
|
615 "intl.non.existing2") |
|
873b9d2ecb0b
Unittests for ".getfirstvar_s()"
Franz Glasner <fzglas.hg@dom66.de>
parents:
370
diff
changeset
|
616 |
|
647
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
617 def test22a_getfirstvar_s_non_existing_without_cache(self): |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
618 cfg = self._load( |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
619 os.path.join(TESTDATADIR, "conf20.yml"), |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
620 os.path.join(TESTDATADIR, "conf21.yml")) |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
621 cfg.disable_cache() |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
622 self.assertIsNone( |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
623 cfg.getfirstvar_s("intl.non.existing", "intl.non.existing2", |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
624 default=None)) |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
625 self.assertRaises( |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
626 KeyError, |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
627 cfg.getfirstvar_s, |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
628 "intl.non.existing", |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
629 "intl.non.existing2") |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
630 |
|
373
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
631 def test23_getfirstintvar_s_nonexisting(self): |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
632 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
633 self.assertIsNone(cfg.getfirstintvar_s("db.non.existing.key", |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
634 "db.non.existing.key2", |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
635 "intl.non.existing", |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
636 default=None)) |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
637 self.assertRaises( |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
638 KeyError, |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
639 cfg.getfirstintvar_s, |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
640 "db.non.existing.key", |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
641 "db.non.exksting.key2", |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
642 "intl.non.existing") |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
643 |
|
457
e3ae8092eaf3
FIX: unittest: duplicate name of test-method removed
Franz Glasner <fzglas.hg@dom66.de>
parents:
456
diff
changeset
|
644 def test23_getfirstintvar_s_nonexisting_default(self): |
|
373
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
645 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
646 self.assertEqual(20, |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
647 cfg.getfirstintvar_s("db.non.existing.key", |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
648 "db.non.existing.key2", |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
649 "intl.non.existing", |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
650 default=u("20"))) |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
651 self.assertEqual(30, |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
652 cfg.getfirstintvar_s("db.non.existing.key", |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
653 "db.non.existing.key2", |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
654 "intl.non.existing", |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
655 default=30)) |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
656 self.assertRaises( |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
657 KeyError, |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
658 cfg.getfirstintvar_s, |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
659 "db.non.existing.key", |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
660 "db.non.exksting.key2", |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
661 "intl.non.existing") |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
662 |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
663 def test24_getfirstintvar_s_existing(self): |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
664 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
665 self.assertEqual(10, |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
666 cfg.getfirstintvar_s("db.non.existing.key", |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
667 "intl.cache.items", |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
668 "db.non.existing.key2", |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
669 default=u("20"))) |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
670 |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
671 def test25_getfirstboolvar_s_nonexisting(self): |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
672 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
673 self.assertFalse( |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
674 cfg.getfirstboolvar_s("db.non.existing.key", |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
675 "db.non.existing.key2", |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
676 "db.engines.rw.no-echo", |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
677 default=u("false"))) |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
678 self.assertTrue( |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
679 cfg.getfirstboolvar_s("db.non.existing.key", |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
680 "db.non.existing.key2", |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
681 "db.engines.rw.no-echo", |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
682 default=True)) |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
683 self.assertRaises( |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
684 KeyError, |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
685 cfg.getfirstboolvar_s, |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
686 "db.non.existing.key", |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
687 "db.non.exksting.key2", |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
688 "b.engines.rw.no-echo") |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
689 |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
690 def test26_getfirstboolvar_s_existing(self): |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
691 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
692 self.assertFalse( |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
693 cfg.getfirstboolvar_s("db.non.existing.key", |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
694 "db.engines.rw.echo", |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
695 "db.non.existing.key2", |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
696 default=u("true"))) |
|
0c65aac81807
Implement ".getfirstintvar_s()" and ".getfirstboolvar_s()" with unittests
Franz Glasner <fzglas.hg@dom66.de>
parents:
372
diff
changeset
|
697 |
|
381
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
698 def test27_getfirstvarl_nonexisting(self): |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
699 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
700 self.assertRaises( |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
701 KeyError, |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
702 cfg.getfirstvarl, |
|
492
a9a291927a4b
FIX: Tests when calling getfirstNNNl() and friends properly
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
486
diff
changeset
|
703 *[["db", "non", "existing", "key"], |
|
a9a291927a4b
FIX: Tests when calling getfirstNNNl() and friends properly
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
486
diff
changeset
|
704 ("db", "non", "existing", "key2")]) |
|
381
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
705 |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
706 def test27b_getfirstvarl_nonexisting(self): |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
707 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
708 self.assertRaises( |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
709 KeyError, |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
710 cfg.getfirstvarl, |
|
492
a9a291927a4b
FIX: Tests when calling getfirstNNNl() and friends properly
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
486
diff
changeset
|
711 *[{"namespace": None, "path": ["db", "non", "existing", "key"]}, |
|
a9a291927a4b
FIX: Tests when calling getfirstNNNl() and friends properly
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
486
diff
changeset
|
712 {"namespace": None, "path": ["db", "non", "existing", "key2"]}]) |
|
381
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
713 |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
714 def test28_getfirstvarl_nonexisting(self): |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
715 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
716 self.assertIsNone(cfg.getfirstvarl( |
|
492
a9a291927a4b
FIX: Tests when calling getfirstNNNl() and friends properly
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
486
diff
changeset
|
717 *[["db", "non", "existing", "key"], |
|
a9a291927a4b
FIX: Tests when calling getfirstNNNl() and friends properly
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
486
diff
changeset
|
718 ("db", "non", "existing", "key2")], |
|
381
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
719 default=None)) |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
720 |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
721 def test28b_getfirstvarl_nonexisting(self): |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
722 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
723 self.assertIsNone(cfg.getfirstvarl( |
|
492
a9a291927a4b
FIX: Tests when calling getfirstNNNl() and friends properly
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
486
diff
changeset
|
724 *[{"namespace": None, "path": ["db", "non", "existing", "key"]}, |
|
a9a291927a4b
FIX: Tests when calling getfirstNNNl() and friends properly
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
486
diff
changeset
|
725 {"namespace": None, "path": ("db", "non", "existing", "key2")}], |
|
381
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
726 default=None)) |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
727 |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
728 def test29_getfirstvarl_existing(self): |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
729 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
730 self.assertEqual( |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
731 "test-configmix", |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
732 cfg.getfirstvarl(*(("intl", "domain"),))) |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
733 self.assertEqual( |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
734 "test-configmix", |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
735 cfg.getfirstvarl(*(("intl", "domain"), ("intl", "fallback")))) |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
736 self.assertEqual( |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
737 "de", |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
738 cfg.getfirstvarl(*[["intl", "fallback"], |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
739 ["intl", "domain"]], |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
740 default=None)) |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
741 self.assertEqual( |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
742 "de", |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
743 cfg.getfirstvarl(*[["intl", "non", "existing"], |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
744 ["intl", "fallback"]], |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
745 default=None)) |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
746 |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
747 def test29b_getfirstvarl_existing(self): |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
748 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
749 self.assertEqual( |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
750 "test-configmix", |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
751 cfg.getfirstvarl(*({"namespace": None, |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
752 "path": ("intl", "domain")},))) |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
753 self.assertEqual( |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
754 "test-configmix", |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
755 cfg.getfirstvarl(*({"namespace": None, |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
756 "path": ("intl", "domain")}, |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
757 {"namespace": None, "path": ("intl", "fallback")}))) |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
758 self.assertEqual( |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
759 "de", |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
760 cfg.getfirstvarl(*[{"namespace": None, "path": ["intl", "fallback"]}, |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
761 {"namespace": None, "path": ["intl", "domain"]}], |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
762 default=None)) |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
763 self.assertEqual( |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
764 "de", |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
765 cfg.getfirstvarl(*[{"namespace": None, "path": ["intl", "non", "existing"]}, |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
766 {"namespace": None, "path": ["intl", "fallback"]}], |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
767 default=None)) |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
768 |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
769 def test30_getfirstvarl_s_existing(self): |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
770 cfg = self._load( |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
771 os.path.join(TESTDATADIR, "conf20.yml"), |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
772 os.path.join(TESTDATADIR, "conf21.yml")) |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
773 self.assertEqual( |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
774 os.getcwd()+"/locale", |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
775 cfg.getfirstvarl_s(*[["intl", "non", "existing"], |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
776 ["intl", "localedir"]])) |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
777 self.assertEqual( |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
778 os.getcwd()+"/locale", |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
779 cfg.getfirstvarl_s(*[["intl", "localedir"], ["intl", "non", "existing"]])) |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
780 |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
781 def test30b_getfirstvarl_s_existing(self): |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
782 cfg = self._load( |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
783 os.path.join(TESTDATADIR, "conf20.yml"), |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
784 os.path.join(TESTDATADIR, "conf21.yml")) |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
785 self.assertEqual( |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
786 os.getcwd()+"/locale", |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
787 cfg.getfirstvarl_s(*[{"namespace": None, "path": ["intl", "non", "existing"]}, |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
788 {"namespace": None, "path": ["intl", "localedir"]}])) |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
789 self.assertEqual( |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
790 os.getcwd()+"/locale", |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
791 cfg.getfirstvarl_s(*[{"namespace": None, "path": ["intl", "localedir"]}, {"namespace": None, "path": ["intl", "non", "existing"]}])) |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
792 |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
793 def test31_getfirstvar_s_non_existing(self): |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
794 cfg = self._load( |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
795 os.path.join(TESTDATADIR, "conf20.yml"), |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
796 os.path.join(TESTDATADIR, "conf21.yml")) |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
797 self.assertIsNone( |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
798 cfg.getfirstvarl_s( |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
799 *[["intl", "non", "existing"], ["intl", "non", "existing2"]], |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
800 default=None)) |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
801 self.assertRaises( |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
802 KeyError, |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
803 cfg.getfirstvarl_s, |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
804 ["intl" ,"non", "existing"], |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
805 ["intl", "non", "existing2"]) |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
806 |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
807 def test31b_getfirstvar_s_non_existing(self): |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
808 cfg = self._load( |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
809 os.path.join(TESTDATADIR, "conf20.yml"), |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
810 os.path.join(TESTDATADIR, "conf21.yml")) |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
811 self.assertIsNone( |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
812 cfg.getfirstvarl_s( |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
813 *[{"namespace": None, "path": ["intl", "non", "existing"]}, |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
814 {"namespace": None, "path": ["intl", "non", "existing2"]}], |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
815 default=None)) |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
816 self.assertRaises( |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
817 KeyError, |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
818 cfg.getfirstvarl_s, |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
819 {"namespace": None, "path": ["intl" ,"non", "existing"]}, |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
820 {"namespace": None, "path": ["intl", "non", "existing2"]}) |
|
fe3dfd687621
Implemented Configuration.getfirstvarl() and Configuration.getfirstvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
373
diff
changeset
|
821 |
|
390
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
822 def test32_getfirstintvarl_s_nonexisting(self): |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
823 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
824 self.assertIsNone(cfg.getfirstintvarl_s( |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
825 *(("db", "non", "existing", "key"), |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
826 ("db", "non", "existing", "key2"), |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
827 ("intl", "non", "existing")), |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
828 default=None)) |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
829 self.assertRaises( |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
830 KeyError, |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
831 cfg.getfirstintvarl_s, |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
832 ("db", "non", "existing", "key"), |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
833 ("db", "non", "exksting", "key2"), |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
834 ("intl", "non", "existing")) |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
835 |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
836 def test33_getfirstintvarl_s_nonexisting(self): |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
837 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
838 self.assertEqual( |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
839 20, |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
840 cfg.getfirstintvarl_s( |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
841 *(("db", "non", "existing", ".key"), |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
842 ("db", "non", "existing", "key2"), |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
843 ("intl", "non", "existing")), |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
844 default=u("20"))) |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
845 self.assertEqual( |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
846 30, |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
847 cfg.getfirstintvarl_s( |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
848 *(("db", "non", "existing", "key"), |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
849 ("db", "non", "existing", "key2"), |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
850 ("intl", "non", "existing")), |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
851 default=30)) |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
852 self.assertRaises( |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
853 KeyError, |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
854 cfg.getfirstintvarl_s, |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
855 ("db", "non", "existing", "key"), |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
856 ("db", "non", "exksting", "key2"), |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
857 ("intl", "non", "existing")) |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
858 |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
859 def test34_getfirstintvarl_s_existing(self): |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
860 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
861 self.assertEqual( |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
862 10, |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
863 cfg.getfirstintvarl_s( |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
864 *(("db", "non", "existing", "key"), |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
865 ("intl", "cache", "items"), |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
866 ("db", "non", "existing", "key2")), |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
867 default=u("20"))) |
|
0521e857c320
Tests for getfirstintvarl_s()
Franz Glasner <fzglas.hg@dom66.de>
parents:
381
diff
changeset
|
868 |
|
418
bb5f11abd12a
Implement .getkeysl() and .getkeys() for configuration objects that iterate over all the keys of a configuration value
Franz Glasner <fzglas.hg@dom66.de>
parents:
417
diff
changeset
|
869 def test35_keysl(self): |
|
bb5f11abd12a
Implement .getkeysl() and .getkeys() for configuration objects that iterate over all the keys of a configuration value
Franz Glasner <fzglas.hg@dom66.de>
parents:
417
diff
changeset
|
870 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
bb5f11abd12a
Implement .getkeysl() and .getkeys() for configuration objects that iterate over all the keys of a configuration value
Franz Glasner <fzglas.hg@dom66.de>
parents:
417
diff
changeset
|
871 self.assertEqual( |
|
bb5f11abd12a
Implement .getkeysl() and .getkeys() for configuration objects that iterate over all the keys of a configuration value
Franz Glasner <fzglas.hg@dom66.de>
parents:
417
diff
changeset
|
872 set([u"domain", u"localedir", u"fallback", u"cache",]), |
|
bb5f11abd12a
Implement .getkeysl() and .getkeys() for configuration objects that iterate over all the keys of a configuration value
Franz Glasner <fzglas.hg@dom66.de>
parents:
417
diff
changeset
|
873 set(cfg.getkeysl(u"intl"))) |
|
bb5f11abd12a
Implement .getkeysl() and .getkeys() for configuration objects that iterate over all the keys of a configuration value
Franz Glasner <fzglas.hg@dom66.de>
parents:
417
diff
changeset
|
874 |
|
bb5f11abd12a
Implement .getkeysl() and .getkeys() for configuration objects that iterate over all the keys of a configuration value
Franz Glasner <fzglas.hg@dom66.de>
parents:
417
diff
changeset
|
875 def test36_keys(self): |
|
bb5f11abd12a
Implement .getkeysl() and .getkeys() for configuration objects that iterate over all the keys of a configuration value
Franz Glasner <fzglas.hg@dom66.de>
parents:
417
diff
changeset
|
876 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
bb5f11abd12a
Implement .getkeysl() and .getkeys() for configuration objects that iterate over all the keys of a configuration value
Franz Glasner <fzglas.hg@dom66.de>
parents:
417
diff
changeset
|
877 self.assertEqual( |
|
bb5f11abd12a
Implement .getkeysl() and .getkeys() for configuration objects that iterate over all the keys of a configuration value
Franz Glasner <fzglas.hg@dom66.de>
parents:
417
diff
changeset
|
878 set([u"name", u"pwd"]), |
|
bb5f11abd12a
Implement .getkeysl() and .getkeys() for configuration objects that iterate over all the keys of a configuration value
Franz Glasner <fzglas.hg@dom66.de>
parents:
417
diff
changeset
|
879 set(cfg.getkeys(u"db.user"))) |
|
bb5f11abd12a
Implement .getkeysl() and .getkeys() for configuration objects that iterate over all the keys of a configuration value
Franz Glasner <fzglas.hg@dom66.de>
parents:
417
diff
changeset
|
880 |
|
419
079a82129110
Allow the empty variable name to retrieve the root configuration object
Franz Glasner <fzglas.hg@dom66.de>
parents:
418
diff
changeset
|
881 def test37_get_root_object(self): |
|
079a82129110
Allow the empty variable name to retrieve the root configuration object
Franz Glasner <fzglas.hg@dom66.de>
parents:
418
diff
changeset
|
882 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
079a82129110
Allow the empty variable name to retrieve the root configuration object
Franz Glasner <fzglas.hg@dom66.de>
parents:
418
diff
changeset
|
883 self.assertTrue(cfg.getvarl() is cfg) |
|
079a82129110
Allow the empty variable name to retrieve the root configuration object
Franz Glasner <fzglas.hg@dom66.de>
parents:
418
diff
changeset
|
884 |
|
079a82129110
Allow the empty variable name to retrieve the root configuration object
Franz Glasner <fzglas.hg@dom66.de>
parents:
418
diff
changeset
|
885 def test38_get_root_object(self): |
|
079a82129110
Allow the empty variable name to retrieve the root configuration object
Franz Glasner <fzglas.hg@dom66.de>
parents:
418
diff
changeset
|
886 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
079a82129110
Allow the empty variable name to retrieve the root configuration object
Franz Glasner <fzglas.hg@dom66.de>
parents:
418
diff
changeset
|
887 self.assertTrue(cfg.getvar(u"") is cfg) |
|
079a82129110
Allow the empty variable name to retrieve the root configuration object
Franz Glasner <fzglas.hg@dom66.de>
parents:
418
diff
changeset
|
888 |
|
079a82129110
Allow the empty variable name to retrieve the root configuration object
Franz Glasner <fzglas.hg@dom66.de>
parents:
418
diff
changeset
|
889 def test39_get_root_keys(self): |
|
079a82129110
Allow the empty variable name to retrieve the root configuration object
Franz Glasner <fzglas.hg@dom66.de>
parents:
418
diff
changeset
|
890 cfg = self._load(os.path.join(TESTDATADIR, "conf10.py")) |
|
079a82129110
Allow the empty variable name to retrieve the root configuration object
Franz Glasner <fzglas.hg@dom66.de>
parents:
418
diff
changeset
|
891 self.assertEqual( |
|
079a82129110
Allow the empty variable name to retrieve the root configuration object
Franz Glasner <fzglas.hg@dom66.de>
parents:
418
diff
changeset
|
892 set([u"key1", u"key2", u"tree1"]), |
|
079a82129110
Allow the empty variable name to retrieve the root configuration object
Franz Glasner <fzglas.hg@dom66.de>
parents:
418
diff
changeset
|
893 set(cfg.getkeys(u""))) |
|
079a82129110
Allow the empty variable name to retrieve the root configuration object
Franz Glasner <fzglas.hg@dom66.de>
parents:
418
diff
changeset
|
894 |
|
079a82129110
Allow the empty variable name to retrieve the root configuration object
Franz Glasner <fzglas.hg@dom66.de>
parents:
418
diff
changeset
|
895 def test39b_get_root_keys(self): |
|
079a82129110
Allow the empty variable name to retrieve the root configuration object
Franz Glasner <fzglas.hg@dom66.de>
parents:
418
diff
changeset
|
896 cfg = self._load(os.path.join(TESTDATADIR, "conf10.py")) |
|
079a82129110
Allow the empty variable name to retrieve the root configuration object
Franz Glasner <fzglas.hg@dom66.de>
parents:
418
diff
changeset
|
897 self.assertEqual( |
|
079a82129110
Allow the empty variable name to retrieve the root configuration object
Franz Glasner <fzglas.hg@dom66.de>
parents:
418
diff
changeset
|
898 set([u"key1", u"key2", u"tree1"]), |
|
079a82129110
Allow the empty variable name to retrieve the root configuration object
Franz Glasner <fzglas.hg@dom66.de>
parents:
418
diff
changeset
|
899 set(cfg.getkeysl())) |
|
079a82129110
Allow the empty variable name to retrieve the root configuration object
Franz Glasner <fzglas.hg@dom66.de>
parents:
418
diff
changeset
|
900 |
|
439
bd27da55483a
Optimized __contains__() implementation for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
437
diff
changeset
|
901 def test40_contains_with_string(self): |
|
bd27da55483a
Optimized __contains__() implementation for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
437
diff
changeset
|
902 cfg = self._load(os.path.join(TESTDATADIR, "conf10.py")) |
|
bd27da55483a
Optimized __contains__() implementation for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
437
diff
changeset
|
903 self.assertTrue(u"tree1" in cfg) |
|
bd27da55483a
Optimized __contains__() implementation for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
437
diff
changeset
|
904 self.assertFalse(u"non-existing-tree1" in cfg) |
|
bd27da55483a
Optimized __contains__() implementation for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
437
diff
changeset
|
905 |
|
bd27da55483a
Optimized __contains__() implementation for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
437
diff
changeset
|
906 def test41_contains_with_path(self): |
|
bd27da55483a
Optimized __contains__() implementation for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
437
diff
changeset
|
907 cfg = self._load(os.path.join(TESTDATADIR, "conf10.py")) |
|
bd27da55483a
Optimized __contains__() implementation for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
437
diff
changeset
|
908 self.assertTrue((u"tree1", u"tree2") in cfg) |
|
bd27da55483a
Optimized __contains__() implementation for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
437
diff
changeset
|
909 self.assertFalse((u"tree1", u"non-existing-tree2") in cfg) |
|
bd27da55483a
Optimized __contains__() implementation for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
437
diff
changeset
|
910 |
|
442
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
911 def test43_get_with_string(self): |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
912 cfg = self._load(os.path.join(TESTDATADIR, "conf10.py")) |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
913 self.assertEqual( |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
914 u"in the root namespace", |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
915 cfg.get(u"key1")) |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
916 self.assertTrue( |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
917 cfg.get(u"key1-not", default=None) is None) |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
918 |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
919 def test43_get_with_path(self): |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
920 cfg = self._load(os.path.join(TESTDATADIR, "conf10.py")) |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
921 self.assertEqual( |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
922 0x20, |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
923 cfg.get((u"tree1", u"key3"))) |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
924 self.assertEqual( |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
925 0x1, |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
926 cfg.get((u"no", u"key"), default=0x1)) |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
927 |
|
458
a68240971d3d
Tests: test for iterating the keys of a configuration
Franz Glasner <fzglas.hg@dom66.de>
parents:
457
diff
changeset
|
928 def test44_iterator(self): |
|
a68240971d3d
Tests: test for iterating the keys of a configuration
Franz Glasner <fzglas.hg@dom66.de>
parents:
457
diff
changeset
|
929 cfg = self._load(os.path.join(TESTDATADIR, "conf10.py")) |
|
a68240971d3d
Tests: test for iterating the keys of a configuration
Franz Glasner <fzglas.hg@dom66.de>
parents:
457
diff
changeset
|
930 s = [] |
|
a68240971d3d
Tests: test for iterating the keys of a configuration
Franz Glasner <fzglas.hg@dom66.de>
parents:
457
diff
changeset
|
931 for k in cfg: |
|
a68240971d3d
Tests: test for iterating the keys of a configuration
Franz Glasner <fzglas.hg@dom66.de>
parents:
457
diff
changeset
|
932 s.append(k) |
|
a68240971d3d
Tests: test for iterating the keys of a configuration
Franz Glasner <fzglas.hg@dom66.de>
parents:
457
diff
changeset
|
933 s.sort() |
|
a68240971d3d
Tests: test for iterating the keys of a configuration
Franz Glasner <fzglas.hg@dom66.de>
parents:
457
diff
changeset
|
934 |
|
a68240971d3d
Tests: test for iterating the keys of a configuration
Franz Glasner <fzglas.hg@dom66.de>
parents:
457
diff
changeset
|
935 self.assertEqual([u"key1", u"key2", u"tree1"], s) |
|
a68240971d3d
Tests: test for iterating the keys of a configuration
Franz Glasner <fzglas.hg@dom66.de>
parents:
457
diff
changeset
|
936 |
|
506
dffa692751b1
Implement clear_cache() for the configuration
Franz Glasner <fzglas.hg@dom66.de>
parents:
502
diff
changeset
|
937 def test45_clear_cache(self): |
|
dffa692751b1
Implement clear_cache() for the configuration
Franz Glasner <fzglas.hg@dom66.de>
parents:
502
diff
changeset
|
938 cfg = self._load(os.path.join(TESTDATADIR, "conf10.py")) |
|
dffa692751b1
Implement clear_cache() for the configuration
Franz Glasner <fzglas.hg@dom66.de>
parents:
502
diff
changeset
|
939 cfg.clear_cache() |
|
dffa692751b1
Implement clear_cache() for the configuration
Franz Glasner <fzglas.hg@dom66.de>
parents:
502
diff
changeset
|
940 |
|
647
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
941 def test46_reenable_cache(self): |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
942 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
651
fe1299825a9a
Tests for indexed accesses (jail and non-jail)
Franz Glasner <fzglas.hg@dom66.de>
parents:
647
diff
changeset
|
943 self.assertTrue(cfg.getvarl() is cfg) |
|
647
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
944 cfg.disable_cache() |
|
651
fe1299825a9a
Tests for indexed accesses (jail and non-jail)
Franz Glasner <fzglas.hg@dom66.de>
parents:
647
diff
changeset
|
945 self.assertTrue(cfg.getvarl() is cfg) |
|
647
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
946 cfg.clear_cache() |
|
651
fe1299825a9a
Tests for indexed accesses (jail and non-jail)
Franz Glasner <fzglas.hg@dom66.de>
parents:
647
diff
changeset
|
947 self.assertTrue(cfg.getvarl() is cfg) |
|
647
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
948 cfg.enable_cache() |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
949 self.assertTrue(cfg.getvarl() is cfg) |
|
df58983f28a2
Allow to disable the internal caching in configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
642
diff
changeset
|
950 |
|
651
fe1299825a9a
Tests for indexed accesses (jail and non-jail)
Franz Glasner <fzglas.hg@dom66.de>
parents:
647
diff
changeset
|
951 def test47_indexed_access_to_lists(self): |
|
fe1299825a9a
Tests for indexed accesses (jail and non-jail)
Franz Glasner <fzglas.hg@dom66.de>
parents:
647
diff
changeset
|
952 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
fe1299825a9a
Tests for indexed accesses (jail and non-jail)
Franz Glasner <fzglas.hg@dom66.de>
parents:
647
diff
changeset
|
953 for i in range(4): |
|
fe1299825a9a
Tests for indexed accesses (jail and non-jail)
Franz Glasner <fzglas.hg@dom66.de>
parents:
647
diff
changeset
|
954 self.assertEqual( |
|
fe1299825a9a
Tests for indexed accesses (jail and non-jail)
Franz Glasner <fzglas.hg@dom66.de>
parents:
647
diff
changeset
|
955 i, |
|
fe1299825a9a
Tests for indexed accesses (jail and non-jail)
Franz Glasner <fzglas.hg@dom66.de>
parents:
647
diff
changeset
|
956 cfg.getvarl_s(u"test", u"List", i)) |
|
fe1299825a9a
Tests for indexed accesses (jail and non-jail)
Franz Glasner <fzglas.hg@dom66.de>
parents:
647
diff
changeset
|
957 |
|
656
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
958 def test48_indexed_access_to_lists(self): |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
959 cfg = self._load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
960 for i in range(4): |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
961 self.assertEqual( |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
962 i, |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
963 cfg.getvar_s(u"test.List.~%d~" % (i, ))) |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
964 |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
965 def test49_index_access_to_lists_with_subdicts(self): |
|
651
fe1299825a9a
Tests for indexed accesses (jail and non-jail)
Franz Glasner <fzglas.hg@dom66.de>
parents:
647
diff
changeset
|
966 cfg = self._load(os.path.join(TESTDATADIR, |
|
fe1299825a9a
Tests for indexed accesses (jail and non-jail)
Franz Glasner <fzglas.hg@dom66.de>
parents:
647
diff
changeset
|
967 "index-access-for-jails.yml")) |
|
fe1299825a9a
Tests for indexed accesses (jail and non-jail)
Franz Glasner <fzglas.hg@dom66.de>
parents:
647
diff
changeset
|
968 for idx in range(len(cfg.getvarl(u"the-list"))): |
|
fe1299825a9a
Tests for indexed accesses (jail and non-jail)
Franz Glasner <fzglas.hg@dom66.de>
parents:
647
diff
changeset
|
969 self.assertEqual( |
|
fe1299825a9a
Tests for indexed accesses (jail and non-jail)
Franz Glasner <fzglas.hg@dom66.de>
parents:
647
diff
changeset
|
970 idx, |
|
fe1299825a9a
Tests for indexed accesses (jail and non-jail)
Franz Glasner <fzglas.hg@dom66.de>
parents:
647
diff
changeset
|
971 cfg.getvarl_s(u"the-list", idx, u"entry")) |
|
fe1299825a9a
Tests for indexed accesses (jail and non-jail)
Franz Glasner <fzglas.hg@dom66.de>
parents:
647
diff
changeset
|
972 |
|
656
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
973 def test50_index_access_to_lists_with_subdicts(self): |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
974 cfg = self._load(os.path.join(TESTDATADIR, |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
975 "index-access-for-jails.yml")) |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
976 for idx in range(len(cfg.getvarl(u"the-list"))): |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
977 self.assertEqual( |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
978 idx, |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
979 cfg.getvar_s(u"the-list.~%d~.entry" % (idx, ))) |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
980 |
|
657
213f0ec3bbbc
Test list access with negative indexes
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
656
diff
changeset
|
981 def test51_neg_index_access_to_lists_with_subdicts(self): |
|
213f0ec3bbbc
Test list access with negative indexes
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
656
diff
changeset
|
982 cfg = self._load(os.path.join(TESTDATADIR, |
|
213f0ec3bbbc
Test list access with negative indexes
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
656
diff
changeset
|
983 "index-access-for-jails.yml")) |
|
213f0ec3bbbc
Test list access with negative indexes
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
656
diff
changeset
|
984 self.assertEqual( |
|
213f0ec3bbbc
Test list access with negative indexes
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
656
diff
changeset
|
985 2, |
|
213f0ec3bbbc
Test list access with negative indexes
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
656
diff
changeset
|
986 cfg.getvarl_s(u"the-list", -1, u"entry")) |
|
213f0ec3bbbc
Test list access with negative indexes
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
656
diff
changeset
|
987 |
|
213f0ec3bbbc
Test list access with negative indexes
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
656
diff
changeset
|
988 def test52_neg_index_access_to_lists_with_subdicts(self): |
|
213f0ec3bbbc
Test list access with negative indexes
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
656
diff
changeset
|
989 cfg = self._load(os.path.join(TESTDATADIR, |
|
213f0ec3bbbc
Test list access with negative indexes
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
656
diff
changeset
|
990 "index-access-for-jails.yml")) |
|
213f0ec3bbbc
Test list access with negative indexes
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
656
diff
changeset
|
991 self.assertEqual( |
|
213f0ec3bbbc
Test list access with negative indexes
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
656
diff
changeset
|
992 2, |
|
213f0ec3bbbc
Test list access with negative indexes
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
656
diff
changeset
|
993 cfg.getvar_s(u"the-list.~%d~.entry" % (-1, ))) |
|
213f0ec3bbbc
Test list access with negative indexes
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
656
diff
changeset
|
994 |
|
659
b97e5f3bbc8e
Test indexed list access in variable interpolations: ok.
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
657
diff
changeset
|
995 def test53_expand_an_indexed_substitution(self): |
|
b97e5f3bbc8e
Test indexed list access in variable interpolations: ok.
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
657
diff
changeset
|
996 cfg = self._load(os.path.join(TESTDATADIR, |
|
b97e5f3bbc8e
Test indexed list access in variable interpolations: ok.
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
657
diff
changeset
|
997 "index-access-for-jails.yml")) |
|
b97e5f3bbc8e
Test indexed list access in variable interpolations: ok.
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
657
diff
changeset
|
998 self.assertEqual(1, cfg.getvar_s(u"expand-me")) |
|
b97e5f3bbc8e
Test indexed list access in variable interpolations: ok.
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
657
diff
changeset
|
999 self.assertEqual(2, cfg.getvar_s(u"expand-me-2")) |
|
b97e5f3bbc8e
Test indexed list access in variable interpolations: ok.
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
657
diff
changeset
|
1000 |
|
105
1c2f8a96dec2
Unittests with some real-worl-examples of .yml and .ini configuration files
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
97
diff
changeset
|
1001 |
|
112
c50ad93eb5dc
Implemented a "safe_load()" to load with safe merging
Franz Glasner <hg@dom66.de>
parents:
109
diff
changeset
|
1002 class T02LoadAndMerge(_T02MixinLoadAndMerge, unittest.TestCase): |
|
c50ad93eb5dc
Implemented a "safe_load()" to load with safe merging
Franz Glasner <hg@dom66.de>
parents:
109
diff
changeset
|
1003 |
|
c50ad93eb5dc
Implemented a "safe_load()" to load with safe merging
Franz Glasner <hg@dom66.de>
parents:
109
diff
changeset
|
1004 def setUp(self): |
|
c50ad93eb5dc
Implemented a "safe_load()" to load with safe merging
Franz Glasner <hg@dom66.de>
parents:
109
diff
changeset
|
1005 self._load = configmix.load |
|
c50ad93eb5dc
Implemented a "safe_load()" to load with safe merging
Franz Glasner <hg@dom66.de>
parents:
109
diff
changeset
|
1006 |
|
301
a03a6797533b
Renumber: make room for new tests implemented in the mixin class
Franz Glasner <fzglas.hg@dom66.de>
parents:
292
diff
changeset
|
1007 def test0100_identity(self): |
|
113
5b667c252f8c
Test whether safe_merge really returns a deepcopy in the initial case and when not really merging
Franz Glasner <hg@dom66.de>
parents:
112
diff
changeset
|
1008 cfg = configmix.ini.load(os.path.join(TESTDATADIR, "conf1.ini")) |
|
5b667c252f8c
Test whether safe_merge really returns a deepcopy in the initial case and when not really merging
Franz Glasner <hg@dom66.de>
parents:
112
diff
changeset
|
1009 cfg2 = configmix.merge(cfg, None) |
|
5b667c252f8c
Test whether safe_merge really returns a deepcopy in the initial case and when not really merging
Franz Glasner <hg@dom66.de>
parents:
112
diff
changeset
|
1010 self.assertEqual(id(cfg), id(cfg2)) |
|
5b667c252f8c
Test whether safe_merge really returns a deepcopy in the initial case and when not really merging
Franz Glasner <hg@dom66.de>
parents:
112
diff
changeset
|
1011 |
|
301
a03a6797533b
Renumber: make room for new tests implemented in the mixin class
Franz Glasner <fzglas.hg@dom66.de>
parents:
292
diff
changeset
|
1012 def test0101_identity(self): |
|
113
5b667c252f8c
Test whether safe_merge really returns a deepcopy in the initial case and when not really merging
Franz Glasner <hg@dom66.de>
parents:
112
diff
changeset
|
1013 cfg = configmix.ini.load(os.path.join(TESTDATADIR, "conf1.ini")) |
|
5b667c252f8c
Test whether safe_merge really returns a deepcopy in the initial case and when not really merging
Franz Glasner <hg@dom66.de>
parents:
112
diff
changeset
|
1014 cfg2 = configmix.merge(cfg, {}) |
|
5b667c252f8c
Test whether safe_merge really returns a deepcopy in the initial case and when not really merging
Franz Glasner <hg@dom66.de>
parents:
112
diff
changeset
|
1015 self.assertEqual(id(cfg), id(cfg2)) |
|
5b667c252f8c
Test whether safe_merge really returns a deepcopy in the initial case and when not really merging
Franz Glasner <hg@dom66.de>
parents:
112
diff
changeset
|
1016 |
|
112
c50ad93eb5dc
Implemented a "safe_load()" to load with safe merging
Franz Glasner <hg@dom66.de>
parents:
109
diff
changeset
|
1017 |
|
c50ad93eb5dc
Implemented a "safe_load()" to load with safe merging
Franz Glasner <hg@dom66.de>
parents:
109
diff
changeset
|
1018 class T03SafeLoadAndMerge(_T02MixinLoadAndMerge, unittest.TestCase): |
|
c50ad93eb5dc
Implemented a "safe_load()" to load with safe merging
Franz Glasner <hg@dom66.de>
parents:
109
diff
changeset
|
1019 |
|
c50ad93eb5dc
Implemented a "safe_load()" to load with safe merging
Franz Glasner <hg@dom66.de>
parents:
109
diff
changeset
|
1020 def setUp(self): |
|
c50ad93eb5dc
Implemented a "safe_load()" to load with safe merging
Franz Glasner <hg@dom66.de>
parents:
109
diff
changeset
|
1021 self._load = configmix.safe_load |
|
c50ad93eb5dc
Implemented a "safe_load()" to load with safe merging
Franz Glasner <hg@dom66.de>
parents:
109
diff
changeset
|
1022 |
|
301
a03a6797533b
Renumber: make room for new tests implemented in the mixin class
Franz Glasner <fzglas.hg@dom66.de>
parents:
292
diff
changeset
|
1023 def test0100_deepcopy(self): |
|
113
5b667c252f8c
Test whether safe_merge really returns a deepcopy in the initial case and when not really merging
Franz Glasner <hg@dom66.de>
parents:
112
diff
changeset
|
1024 cfg = configmix.ini.load(os.path.join(TESTDATADIR, "conf1.ini")) |
|
5b667c252f8c
Test whether safe_merge really returns a deepcopy in the initial case and when not really merging
Franz Glasner <hg@dom66.de>
parents:
112
diff
changeset
|
1025 cfg2 = configmix.safe_merge(cfg, None) |
|
5b667c252f8c
Test whether safe_merge really returns a deepcopy in the initial case and when not really merging
Franz Glasner <hg@dom66.de>
parents:
112
diff
changeset
|
1026 self.assertNotEqual(id(cfg), id(cfg2)) |
|
5b667c252f8c
Test whether safe_merge really returns a deepcopy in the initial case and when not really merging
Franz Glasner <hg@dom66.de>
parents:
112
diff
changeset
|
1027 |
|
301
a03a6797533b
Renumber: make room for new tests implemented in the mixin class
Franz Glasner <fzglas.hg@dom66.de>
parents:
292
diff
changeset
|
1028 def test0101_deepcopy(self): |
|
113
5b667c252f8c
Test whether safe_merge really returns a deepcopy in the initial case and when not really merging
Franz Glasner <hg@dom66.de>
parents:
112
diff
changeset
|
1029 cfg = configmix.ini.load(os.path.join(TESTDATADIR, "conf1.ini")) |
|
5b667c252f8c
Test whether safe_merge really returns a deepcopy in the initial case and when not really merging
Franz Glasner <hg@dom66.de>
parents:
112
diff
changeset
|
1030 cfg2 = configmix.safe_merge(cfg, {}) |
|
5b667c252f8c
Test whether safe_merge really returns a deepcopy in the initial case and when not really merging
Franz Glasner <hg@dom66.de>
parents:
112
diff
changeset
|
1031 self.assertNotEqual(id(cfg), id(cfg2)) |
|
5b667c252f8c
Test whether safe_merge really returns a deepcopy in the initial case and when not really merging
Franz Glasner <hg@dom66.de>
parents:
112
diff
changeset
|
1032 |
|
112
c50ad93eb5dc
Implemented a "safe_load()" to load with safe merging
Franz Glasner <hg@dom66.de>
parents:
109
diff
changeset
|
1033 |
|
140
d8d47893df5b
Unittests for custom configuration filename extensions
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
1034 class T04CustomExtension(unittest.TestCase): |
|
d8d47893df5b
Unittests for custom configuration filename extensions
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
1035 |
|
d8d47893df5b
Unittests for custom configuration filename extensions
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
1036 def setUp(self): |
|
d8d47893df5b
Unittests for custom configuration filename extensions
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
1037 self._reset() |
|
d8d47893df5b
Unittests for custom configuration filename extensions
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
1038 |
|
d8d47893df5b
Unittests for custom configuration filename extensions
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
1039 def tearDown(self): |
|
d8d47893df5b
Unittests for custom configuration filename extensions
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
1040 self._reset() |
|
d8d47893df5b
Unittests for custom configuration filename extensions
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
1041 |
|
d8d47893df5b
Unittests for custom configuration filename extensions
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
1042 def _reset(self): |
|
181
7cfdc972af42
Refactor: Renamed public functions to be conform with the new loader search
Franz Glasner <fzglas.hg@dom66.de>
parents:
171
diff
changeset
|
1043 configmix.clear_assoc() |
|
7cfdc972af42
Refactor: Renamed public functions to be conform with the new loader search
Franz Glasner <fzglas.hg@dom66.de>
parents:
171
diff
changeset
|
1044 for pat, fmode in configmix.DEFAULT_ASSOC: |
|
7cfdc972af42
Refactor: Renamed public functions to be conform with the new loader search
Franz Glasner <fzglas.hg@dom66.de>
parents:
171
diff
changeset
|
1045 configmix.set_assoc(pat, fmode) |
|
140
d8d47893df5b
Unittests for custom configuration filename extensions
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
1046 |
|
d8d47893df5b
Unittests for custom configuration filename extensions
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
1047 def test01_additional(self): |
|
181
7cfdc972af42
Refactor: Renamed public functions to be conform with the new loader search
Franz Glasner <fzglas.hg@dom66.de>
parents:
171
diff
changeset
|
1048 configmix.set_assoc("*.conf", configmix.get_default_assoc("*.yml")) |
|
140
d8d47893df5b
Unittests for custom configuration filename extensions
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
1049 cfg = configmix.load( |
|
d8d47893df5b
Unittests for custom configuration filename extensions
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
1050 os.path.join(TESTDATADIR, "conf1.ini"), |
|
d8d47893df5b
Unittests for custom configuration filename extensions
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
1051 os.path.join(TESTDATADIR, "conf30.conf")) |
|
d8d47893df5b
Unittests for custom configuration filename extensions
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
1052 self.assertEqual(u("Umlaute: ÄÖÜäöüß"), cfg.getvar_s("key7")) |
|
d8d47893df5b
Unittests for custom configuration filename extensions
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
1053 self.assertEqual(u("new value"), cfg.getvar_s("key-new")) |
|
d8d47893df5b
Unittests for custom configuration filename extensions
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
1054 |
|
d8d47893df5b
Unittests for custom configuration filename extensions
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
1055 def test02_only_style_wrong_style(self): |
|
181
7cfdc972af42
Refactor: Renamed public functions to be conform with the new loader search
Franz Glasner <fzglas.hg@dom66.de>
parents:
171
diff
changeset
|
1056 configmix.clear_assoc() |
|
7cfdc972af42
Refactor: Renamed public functions to be conform with the new loader search
Franz Glasner <fzglas.hg@dom66.de>
parents:
171
diff
changeset
|
1057 configmix.set_assoc("*.conf", configmix.get_default_assoc("*.yml")) |
|
140
d8d47893df5b
Unittests for custom configuration filename extensions
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
1058 |
|
d8d47893df5b
Unittests for custom configuration filename extensions
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
1059 def _ld(): |
|
d8d47893df5b
Unittests for custom configuration filename extensions
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
1060 return configmix.load(os.path.join(TESTDATADIR, "conf1.ini"), |
|
d8d47893df5b
Unittests for custom configuration filename extensions
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
1061 os.path.join(TESTDATADIR, "conf30.conf")) |
|
d8d47893df5b
Unittests for custom configuration filename extensions
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
1062 |
|
d8d47893df5b
Unittests for custom configuration filename extensions
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
1063 self.assertRaises(ValueError, _ld) |
|
d8d47893df5b
Unittests for custom configuration filename extensions
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
1064 |
|
227
f5011eec3b6e
Added a loader with key "ignore" that ignores the given configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
198
diff
changeset
|
1065 def test02_ignore_one_style(self): |
|
f5011eec3b6e
Added a loader with key "ignore" that ignores the given configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
198
diff
changeset
|
1066 configmix.clear_assoc() |
|
f5011eec3b6e
Added a loader with key "ignore" that ignores the given configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
198
diff
changeset
|
1067 configmix.set_assoc("*.conf", configmix.get_default_assoc("*.yml")) |
|
228
b2c75efad9e4
Renamed the 'ignore' loader key to '-*-ignore-*-'
Franz Glasner <fzglas.hg@dom66.de>
parents:
227
diff
changeset
|
1068 configmix.set_assoc("*", "-*-ignore-*-", append=True) |
|
227
f5011eec3b6e
Added a loader with key "ignore" that ignores the given configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
198
diff
changeset
|
1069 |
|
f5011eec3b6e
Added a loader with key "ignore" that ignores the given configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
198
diff
changeset
|
1070 cfg = configmix.load(os.path.join(TESTDATADIR, "conf1.ini"), |
|
f5011eec3b6e
Added a loader with key "ignore" that ignores the given configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
198
diff
changeset
|
1071 os.path.join(TESTDATADIR, "conf30.conf")) |
|
f5011eec3b6e
Added a loader with key "ignore" that ignores the given configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
198
diff
changeset
|
1072 self.assertEqual(u("new value"), cfg.getvar_s("key-new")) |
|
f5011eec3b6e
Added a loader with key "ignore" that ignores the given configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
198
diff
changeset
|
1073 self.assertRaises(KeyError, cfg.getvar_s, "key1") |
|
f5011eec3b6e
Added a loader with key "ignore" that ignores the given configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
198
diff
changeset
|
1074 |
|
f5011eec3b6e
Added a loader with key "ignore" that ignores the given configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
198
diff
changeset
|
1075 def test02_ignore_all(self): |
|
f5011eec3b6e
Added a loader with key "ignore" that ignores the given configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
198
diff
changeset
|
1076 configmix.clear_assoc() |
|
f5011eec3b6e
Added a loader with key "ignore" that ignores the given configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
198
diff
changeset
|
1077 configmix.set_assoc("*.conf", configmix.get_default_assoc("*.yml")) |
|
f5011eec3b6e
Added a loader with key "ignore" that ignores the given configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
198
diff
changeset
|
1078 # This inserts at index 0 effectively ignoring all configuration files! |
|
228
b2c75efad9e4
Renamed the 'ignore' loader key to '-*-ignore-*-'
Franz Glasner <fzglas.hg@dom66.de>
parents:
227
diff
changeset
|
1079 configmix.set_assoc("*", "-*-ignore-*-") |
|
227
f5011eec3b6e
Added a loader with key "ignore" that ignores the given configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
198
diff
changeset
|
1080 |
|
f5011eec3b6e
Added a loader with key "ignore" that ignores the given configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
198
diff
changeset
|
1081 cfg = configmix.load(os.path.join(TESTDATADIR, "conf1.ini"), |
|
f5011eec3b6e
Added a loader with key "ignore" that ignores the given configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
198
diff
changeset
|
1082 os.path.join(TESTDATADIR, "conf30.conf")) |
|
f5011eec3b6e
Added a loader with key "ignore" that ignores the given configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
198
diff
changeset
|
1083 self.assertRaises(KeyError, cfg.getvar_s, "key-new") |
|
251
2a8dcab2de8c
Do not implicitely convert a configuration value to text if the value is the result of just a variable expansion.
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
1084 self.assertRaises(KeyError, cfg.getvar_s, "key1") |
|
227
f5011eec3b6e
Added a loader with key "ignore" that ignores the given configuration file
Franz Glasner <fzglas.hg@dom66.de>
parents:
198
diff
changeset
|
1085 |
|
140
d8d47893df5b
Unittests for custom configuration filename extensions
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
1086 def test03_only_style_corrrect_style(self): |
|
181
7cfdc972af42
Refactor: Renamed public functions to be conform with the new loader search
Franz Glasner <fzglas.hg@dom66.de>
parents:
171
diff
changeset
|
1087 configmix.clear_assoc() |
|
7cfdc972af42
Refactor: Renamed public functions to be conform with the new loader search
Franz Glasner <fzglas.hg@dom66.de>
parents:
171
diff
changeset
|
1088 configmix.set_assoc("*.conf", configmix.get_default_assoc("*.yml")) |
|
140
d8d47893df5b
Unittests for custom configuration filename extensions
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
1089 cfg = configmix.load(os.path.join(TESTDATADIR, "conf30.conf")) |
|
d8d47893df5b
Unittests for custom configuration filename extensions
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
1090 self.assertEqual(u("new value"), cfg.getvar_s("key-new")) |
|
d8d47893df5b
Unittests for custom configuration filename extensions
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
1091 |
|
d8d47893df5b
Unittests for custom configuration filename extensions
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
1092 def _g(): |
|
d8d47893df5b
Unittests for custom configuration filename extensions
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
1093 return cfg.getvar_s("key7") |
|
144
7e6ec99d5ff5
Allow comments as keys and filter them by default
Franz Glasner <hg@dom66.de>
parents:
140
diff
changeset
|
1094 |
|
140
d8d47893df5b
Unittests for custom configuration filename extensions
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
1095 self.assertRaises(KeyError, _g) |
|
d8d47893df5b
Unittests for custom configuration filename extensions
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
1096 |
|
183
d1103f0f9166
Unit-tests with the file-mode scanner
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
181
diff
changeset
|
1097 def test04_determine_mode(self): |
|
d1103f0f9166
Unit-tests with the file-mode scanner
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
181
diff
changeset
|
1098 configmix.clear_assoc() |
|
d1103f0f9166
Unit-tests with the file-mode scanner
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
181
diff
changeset
|
1099 configmix.set_assoc("*.conf", configmix.try_determine_filemode) |
|
d1103f0f9166
Unit-tests with the file-mode scanner
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
181
diff
changeset
|
1100 cfg = configmix.load(os.path.join(TESTDATADIR, "conf30.conf")) |
|
d1103f0f9166
Unit-tests with the file-mode scanner
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
181
diff
changeset
|
1101 self.assertEqual(u("new value"), cfg.getvar_s("key-new")) |
|
d1103f0f9166
Unit-tests with the file-mode scanner
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
181
diff
changeset
|
1102 |
|
d1103f0f9166
Unit-tests with the file-mode scanner
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
181
diff
changeset
|
1103 self.assertRaises(KeyError, cfg.getvar_s, "key7") |
|
d1103f0f9166
Unit-tests with the file-mode scanner
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
181
diff
changeset
|
1104 |
|
d1103f0f9166
Unit-tests with the file-mode scanner
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
181
diff
changeset
|
1105 def test05_try_determine_mode_none(self): |
|
d1103f0f9166
Unit-tests with the file-mode scanner
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
181
diff
changeset
|
1106 configmix.clear_assoc() |
|
d1103f0f9166
Unit-tests with the file-mode scanner
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
181
diff
changeset
|
1107 configmix.set_assoc("*.conf", configmix.try_determine_filemode) |
|
d1103f0f9166
Unit-tests with the file-mode scanner
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
181
diff
changeset
|
1108 |
|
d1103f0f9166
Unit-tests with the file-mode scanner
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
181
diff
changeset
|
1109 def _ld(): |
|
d1103f0f9166
Unit-tests with the file-mode scanner
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
181
diff
changeset
|
1110 return configmix.load(os.path.join(TESTDATADIR, "no-mode.conf")) |
|
d1103f0f9166
Unit-tests with the file-mode scanner
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
181
diff
changeset
|
1111 |
|
d1103f0f9166
Unit-tests with the file-mode scanner
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
181
diff
changeset
|
1112 self.assertRaises(ValueError, _ld) |
|
d1103f0f9166
Unit-tests with the file-mode scanner
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
181
diff
changeset
|
1113 |
|
d1103f0f9166
Unit-tests with the file-mode scanner
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
181
diff
changeset
|
1114 def test06_try_determine_mode_unknown(self): |
|
d1103f0f9166
Unit-tests with the file-mode scanner
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
181
diff
changeset
|
1115 configmix.clear_assoc() |
|
d1103f0f9166
Unit-tests with the file-mode scanner
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
181
diff
changeset
|
1116 configmix.set_assoc("*.conf", configmix.try_determine_filemode) |
|
d1103f0f9166
Unit-tests with the file-mode scanner
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
181
diff
changeset
|
1117 |
|
d1103f0f9166
Unit-tests with the file-mode scanner
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
181
diff
changeset
|
1118 def _ld(): |
|
d1103f0f9166
Unit-tests with the file-mode scanner
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
181
diff
changeset
|
1119 return configmix.load(os.path.join(TESTDATADIR, "unknown-mode.conf")) |
|
d1103f0f9166
Unit-tests with the file-mode scanner
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
181
diff
changeset
|
1120 |
|
d1103f0f9166
Unit-tests with the file-mode scanner
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
181
diff
changeset
|
1121 self.assertRaises(KeyError, _ld) |
|
d1103f0f9166
Unit-tests with the file-mode scanner
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
181
diff
changeset
|
1122 |
|
140
d8d47893df5b
Unittests for custom configuration filename extensions
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
1123 |
|
251
2a8dcab2de8c
Do not implicitely convert a configuration value to text if the value is the result of just a variable expansion.
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
1124 class T05SubstituteExpand(unittest.TestCase): |
|
2a8dcab2de8c
Do not implicitely convert a configuration value to text if the value is the result of just a variable expansion.
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
1125 |
|
2a8dcab2de8c
Do not implicitely convert a configuration value to text if the value is the result of just a variable expansion.
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
1126 def setUp(self): |
|
2a8dcab2de8c
Do not implicitely convert a configuration value to text if the value is the result of just a variable expansion.
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
1127 self._reset() |
|
2a8dcab2de8c
Do not implicitely convert a configuration value to text if the value is the result of just a variable expansion.
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
1128 |
|
2a8dcab2de8c
Do not implicitely convert a configuration value to text if the value is the result of just a variable expansion.
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
1129 def tearDown(self): |
|
2a8dcab2de8c
Do not implicitely convert a configuration value to text if the value is the result of just a variable expansion.
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
1130 self._reset() |
|
2a8dcab2de8c
Do not implicitely convert a configuration value to text if the value is the result of just a variable expansion.
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
1131 |
|
2a8dcab2de8c
Do not implicitely convert a configuration value to text if the value is the result of just a variable expansion.
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
1132 def _reset(self): |
|
2a8dcab2de8c
Do not implicitely convert a configuration value to text if the value is the result of just a variable expansion.
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
1133 configmix.clear_assoc() |
|
2a8dcab2de8c
Do not implicitely convert a configuration value to text if the value is the result of just a variable expansion.
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
1134 for pat, fmode in configmix.DEFAULT_ASSOC: |
|
2a8dcab2de8c
Do not implicitely convert a configuration value to text if the value is the result of just a variable expansion.
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
1135 configmix.set_assoc(pat, fmode) |
|
2a8dcab2de8c
Do not implicitely convert a configuration value to text if the value is the result of just a variable expansion.
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
1136 |
|
2a8dcab2de8c
Do not implicitely convert a configuration value to text if the value is the result of just a variable expansion.
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
1137 def test01_expand_int_ini(self): |
|
2a8dcab2de8c
Do not implicitely convert a configuration value to text if the value is the result of just a variable expansion.
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
1138 cfg = configmix.load(os.path.join(TESTDATADIR, "conf1.ini")) |
|
2a8dcab2de8c
Do not implicitely convert a configuration value to text if the value is the result of just a variable expansion.
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
1139 self.assertEqual(2, cfg.getvar_s("key100")) |
|
2a8dcab2de8c
Do not implicitely convert a configuration value to text if the value is the result of just a variable expansion.
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
1140 |
|
314
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1141 def test01_expand_int_ini_l(self): |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1142 cfg = configmix.load(os.path.join(TESTDATADIR, "conf1.ini")) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1143 self.assertEqual(2, cfg.getvarl_s("key100")) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1144 |
|
251
2a8dcab2de8c
Do not implicitely convert a configuration value to text if the value is the result of just a variable expansion.
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
1145 def test02_expand_int_indirect_ini(self): |
|
2a8dcab2de8c
Do not implicitely convert a configuration value to text if the value is the result of just a variable expansion.
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
1146 cfg = configmix.load(os.path.join(TESTDATADIR, "conf1.ini")) |
|
2a8dcab2de8c
Do not implicitely convert a configuration value to text if the value is the result of just a variable expansion.
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
1147 self.assertEqual(2, cfg.getvar_s("key102")) |
|
2a8dcab2de8c
Do not implicitely convert a configuration value to text if the value is the result of just a variable expansion.
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
1148 |
|
314
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1149 def test02_expand_int_indirect_ini_l(self): |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1150 cfg = configmix.load(os.path.join(TESTDATADIR, "conf1.ini")) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1151 self.assertEqual(2, cfg.getvarl_s("key102")) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1152 |
|
251
2a8dcab2de8c
Do not implicitely convert a configuration value to text if the value is the result of just a variable expansion.
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
1153 def test03_expand_int2str_ini(self): |
|
2a8dcab2de8c
Do not implicitely convert a configuration value to text if the value is the result of just a variable expansion.
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
1154 cfg = configmix.load(os.path.join(TESTDATADIR, "conf1.ini")) |
|
2a8dcab2de8c
Do not implicitely convert a configuration value to text if the value is the result of just a variable expansion.
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
1155 self.assertEqual("the 2 value", cfg.getvar_s("key101")) |
|
2a8dcab2de8c
Do not implicitely convert a configuration value to text if the value is the result of just a variable expansion.
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
1156 |
|
314
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1157 def test03_expand_int2str_ini_l(self): |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1158 cfg = configmix.load(os.path.join(TESTDATADIR, "conf1.ini")) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1159 self.assertEqual("the 2 value", cfg.getvarl_s("key101")) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1160 |
|
251
2a8dcab2de8c
Do not implicitely convert a configuration value to text if the value is the result of just a variable expansion.
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
1161 def test04_expand_intint2str_ini(self): |
|
2a8dcab2de8c
Do not implicitely convert a configuration value to text if the value is the result of just a variable expansion.
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
1162 cfg = configmix.load(os.path.join(TESTDATADIR, "conf1.ini")) |
|
276
af371f9c016d
Allow deletion of key-value pairs when merging is done.
Franz Glasner <fzglas.hg@dom66.de>
parents:
251
diff
changeset
|
1163 self.assertEqual("22", cfg.getvar_s("key103")) |
|
251
2a8dcab2de8c
Do not implicitely convert a configuration value to text if the value is the result of just a variable expansion.
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
1164 |
|
314
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1165 def test04_expand_intint2str_ini_l(self): |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1166 cfg = configmix.load(os.path.join(TESTDATADIR, "conf1.ini")) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1167 self.assertEqual("22", cfg.getvarl_s("key103")) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1168 |
|
516
ad1e630ba736
FIX: Do not filter-out all False values then interpolating (zero int, boolean False)
Franz Glasner <fzglas.hg@dom66.de>
parents:
506
diff
changeset
|
1169 def test05_expand_falsy_values(self): |
|
ad1e630ba736
FIX: Do not filter-out all False values then interpolating (zero int, boolean False)
Franz Glasner <fzglas.hg@dom66.de>
parents:
506
diff
changeset
|
1170 cfg = configmix.load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
ad1e630ba736
FIX: Do not filter-out all False values then interpolating (zero int, boolean False)
Franz Glasner <fzglas.hg@dom66.de>
parents:
506
diff
changeset
|
1171 self.assertEqual( |
|
ad1e630ba736
FIX: Do not filter-out all False values then interpolating (zero int, boolean False)
Franz Glasner <fzglas.hg@dom66.de>
parents:
506
diff
changeset
|
1172 u"AFalseB0C", |
|
ad1e630ba736
FIX: Do not filter-out all False values then interpolating (zero int, boolean False)
Franz Glasner <fzglas.hg@dom66.de>
parents:
506
diff
changeset
|
1173 cfg.getvar_s("test-falsy-values.v")) |
|
ad1e630ba736
FIX: Do not filter-out all False values then interpolating (zero int, boolean False)
Franz Glasner <fzglas.hg@dom66.de>
parents:
506
diff
changeset
|
1174 |
|
251
2a8dcab2de8c
Do not implicitely convert a configuration value to text if the value is the result of just a variable expansion.
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
1175 |
|
305
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1176 class T06References(unittest.TestCase): |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1177 |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1178 def setUp(self): |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1179 self._reset() |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1180 self._cfg = configmix.load( |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1181 os.path.join(TESTDATADIR, "conf20.yml"), |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1182 os.path.join(TESTDATADIR, "conf21.yml"), |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1183 os.path.join(TESTDATADIR, "conf22.ini"), |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1184 os.path.join(TESTDATADIR, "conf23.json"), |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1185 os.path.join(TESTDATADIR, "conf24.toml"), |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1186 os.path.join(TESTDATADIR, "reference-style.yml")) |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1187 |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1188 def tearDown(self): |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1189 self._reset() |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1190 |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1191 def _reset(self): |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1192 configmix.clear_assoc() |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1193 for pat, fmode in configmix.DEFAULT_ASSOC: |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1194 configmix.set_assoc(pat, fmode) |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1195 |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1196 def test01_reference_without_expansions(self): |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1197 self.assertTrue(isinstance(self._cfg.getvar("wsgi.profiler"), dict)) |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1198 self.assertTrue(isinstance( |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1199 self._cfg.getvar("wsgi.profiler.params"), dict)) |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1200 self.assertEqual("werkzeug", |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1201 self._cfg.getvar("wsgi.profiler.params.type")) |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1202 self.assertTrue(self._cfg.getvar("wsgi.profiler.params.params.evalex")) |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1203 self.assertEqual(self._cfg.getvar("wsgi.debugger"), |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1204 self._cfg.getvar("wsgi.profiler.params")) |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1205 |
|
314
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1206 def test01_reference_without_expansions_l(self): |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1207 self.assertTrue(isinstance(self._cfg.getvarl("wsgi", "profiler"), dict)) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1208 self.assertTrue(isinstance( |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1209 self._cfg.getvarl("wsgi", "profiler", "params"), dict)) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1210 self.assertEqual( |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1211 "werkzeug", |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1212 self._cfg.getvarl("wsgi", "profiler", "params", "type")) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1213 self.assertTrue(self._cfg.getvarl( |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1214 "wsgi", "profiler", "params", "params", "evalex")) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1215 self.assertEqual(self._cfg.getvarl("wsgi", "debugger"), |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1216 self._cfg.getvarl("wsgi", "profiler", "params")) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1217 |
|
305
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1218 def test02_reference__with_expansions(self): |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1219 self.assertTrue(isinstance(self._cfg.getvar_s("wsgi.profiler"), dict)) |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1220 self.assertTrue(isinstance( |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1221 self._cfg.getvar_s("wsgi.profiler.params"), dict)) |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1222 self.assertTrue( |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1223 self._cfg.getvar_s("wsgi.profiler.params.params.evalex")) |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1224 self.assertEqual("werkzeug", |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1225 self._cfg.getvar_s("wsgi.profiler.params.type")) |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1226 |
|
314
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1227 def test02_reference__with_expansions_l(self): |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1228 self.assertTrue(isinstance( |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1229 self._cfg.getvarl_s("wsgi", "profiler"), dict)) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1230 self.assertTrue(isinstance( |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1231 self._cfg.getvarl_s("wsgi", "profiler", "params"), dict)) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1232 self.assertTrue( |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1233 self._cfg.getvarl_s("wsgi", "profiler", "params", "params", "evalex")) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1234 self.assertEqual( |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1235 "werkzeug", |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1236 self._cfg.getvarl_s("wsgi", "profiler", "params", "type")) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1237 |
|
437
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1238 def test03_direct_attribute_access_to_expanded_references(self): |
|
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1239 self.assertEqual( |
|
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1240 u"werkzeug", |
|
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1241 self._cfg.wsgi.profiler.params.type) |
|
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1242 |
|
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1243 def test03b_dict_like_access_expands_references(self): |
|
305
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1244 self.assertEqual( |
|
437
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1245 u"werkzeug", |
|
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1246 self._cfg[(u"wsgi", u"profiler", u"params", u"type")]) |
|
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1247 |
|
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1248 def test03c_dict_like_access_with_single_string_key(self): |
|
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1249 self.assertTrue( |
|
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1250 u"profiler" in self._cfg[u"wsgi"]) |
|
305
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1251 |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1252 def test04_indirect_recursive_references(self): |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1253 self.assertEqual( |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1254 "werkzeug", |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1255 self._cfg.getvar_s("testref.here.params.type")) |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1256 self.assertTrue( |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1257 self._cfg.getvar_s("testref.here.params.params.evalex")) |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1258 |
|
314
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1259 def test04_indirect_recursive_references_l(self): |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1260 self.assertEqual( |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1261 "werkzeug", |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1262 self._cfg.getvarl_s("testref", "here", "params", "type")) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1263 self.assertTrue( |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1264 self._cfg.getvarl_s("testref", "here", "params", "params", "evalex")) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1265 |
|
305
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1266 def test05_recursive_expansion(self): |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1267 c = self._cfg.getvar_s("testref") |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1268 self.assertTrue(c["here"]["params"]["params"]["evalex"]) |
|
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1269 |
|
314
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1270 def test05_recursive_expansion_l(self): |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1271 c = self._cfg.getvarl_s("testref") |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1272 self.assertTrue(c["here"]["params"]["params"]["evalex"]) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1273 |
|
309
f77dba9fc164
New unittest for the behaviour of ".getvar()" with regard to config references
Franz Glasner <fzglas.hg@dom66.de>
parents:
305
diff
changeset
|
1274 def test06_no_recursive_expansion_in_getvar_parents(self): |
|
f77dba9fc164
New unittest for the behaviour of ".getvar()" with regard to config references
Franz Glasner <fzglas.hg@dom66.de>
parents:
305
diff
changeset
|
1275 v = self._cfg.getvar("wsgi.profiler") |
|
f77dba9fc164
New unittest for the behaviour of ".getvar()" with regard to config references
Franz Glasner <fzglas.hg@dom66.de>
parents:
305
diff
changeset
|
1276 self.assertEqual( |
|
f77dba9fc164
New unittest for the behaviour of ".getvar()" with regard to config references
Franz Glasner <fzglas.hg@dom66.de>
parents:
305
diff
changeset
|
1277 "{{ref:#wsgi.debugger}}", |
|
f77dba9fc164
New unittest for the behaviour of ".getvar()" with regard to config references
Franz Glasner <fzglas.hg@dom66.de>
parents:
305
diff
changeset
|
1278 v["params"]) |
|
f77dba9fc164
New unittest for the behaviour of ".getvar()" with regard to config references
Franz Glasner <fzglas.hg@dom66.de>
parents:
305
diff
changeset
|
1279 |
|
314
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1280 def test06_no_recursive_expansion_in_getvar_parents_l(self): |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1281 v = self._cfg.getvarl("wsgi", "profiler") |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1282 self.assertEqual( |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1283 "{{ref:#wsgi.debugger}}", |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1284 v["params"]) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1285 |
|
312
0788e8e162f6
Unittests for explicit expansion of configuration references
Franz Glasner <fzglas.hg@dom66.de>
parents:
309
diff
changeset
|
1286 def test07_explicit_reference_expansion(self): |
|
0788e8e162f6
Unittests for explicit expansion of configuration references
Franz Glasner <fzglas.hg@dom66.de>
parents:
309
diff
changeset
|
1287 v = self._cfg.getvar("wsgi.profiler") |
|
0788e8e162f6
Unittests for explicit expansion of configuration references
Franz Glasner <fzglas.hg@dom66.de>
parents:
309
diff
changeset
|
1288 self.assertTrue(isinstance(self._cfg.expand_if_reference(v["params"]), |
|
0788e8e162f6
Unittests for explicit expansion of configuration references
Franz Glasner <fzglas.hg@dom66.de>
parents:
309
diff
changeset
|
1289 dict)) |
|
0788e8e162f6
Unittests for explicit expansion of configuration references
Franz Glasner <fzglas.hg@dom66.de>
parents:
309
diff
changeset
|
1290 |
|
314
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1291 def test07_explicit_reference_expansion_l(self): |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1292 v = self._cfg.getvarl("wsgi", "profiler") |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1293 self.assertTrue(isinstance(self._cfg.expand_if_reference(v["params"]), |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1294 dict)) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1295 |
|
313
15a1d5fd0aa1
Further unittest for config reference expansion
Franz Glasner <fzglas.hg@dom66.de>
parents:
312
diff
changeset
|
1296 def test08_explicit_indirect_expansion_through_value(self): |
|
15a1d5fd0aa1
Further unittest for config reference expansion
Franz Glasner <fzglas.hg@dom66.de>
parents:
312
diff
changeset
|
1297 v = self._cfg.getvar_s("expand-ref-value.key0") |
|
15a1d5fd0aa1
Further unittest for config reference expansion
Franz Glasner <fzglas.hg@dom66.de>
parents:
312
diff
changeset
|
1298 self.assertTrue(isinstance(v, bool)) |
|
15a1d5fd0aa1
Further unittest for config reference expansion
Franz Glasner <fzglas.hg@dom66.de>
parents:
312
diff
changeset
|
1299 self.assertTrue(v) |
|
15a1d5fd0aa1
Further unittest for config reference expansion
Franz Glasner <fzglas.hg@dom66.de>
parents:
312
diff
changeset
|
1300 # but not that .getvar does not **not** |
|
15a1d5fd0aa1
Further unittest for config reference expansion
Franz Glasner <fzglas.hg@dom66.de>
parents:
312
diff
changeset
|
1301 v2 = self._cfg.getvar("expand-ref-value.key0") |
|
15a1d5fd0aa1
Further unittest for config reference expansion
Franz Glasner <fzglas.hg@dom66.de>
parents:
312
diff
changeset
|
1302 self.assertEqual("{{testref.here.params.params.evalex}}", v2) |
|
15a1d5fd0aa1
Further unittest for config reference expansion
Franz Glasner <fzglas.hg@dom66.de>
parents:
312
diff
changeset
|
1303 |
|
314
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1304 def test08_explicit_indirect_expansion_through_value_l(self): |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1305 v = self._cfg.getvarl_s("expand-ref-value", "key0") |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1306 self.assertTrue(isinstance(v, bool)) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1307 self.assertTrue(v) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1308 # but not that .getvar does not **not** |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1309 v2 = self._cfg.getvarl("expand-ref-value", "key0") |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1310 self.assertEqual("{{testref.here.params.params.evalex}}", v2) |
|
043a6412be3c
Implemented new access methods .getvarl() and .getvarl_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
1311 |
|
305
f529ca46dd50
Implemented the "ref" namespace to get configuration tree references.
Franz Glasner <fzglas.hg@dom66.de>
parents:
301
diff
changeset
|
1312 |
|
320
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1313 class T07Quoting(unittest.TestCase): |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1314 |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1315 def setUp(self): |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1316 self._reset() |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1317 self._cfg = configmix.load(os.path.join(TESTDATADIR, "quoting.yml")) |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1318 |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1319 def tearDown(self): |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1320 self._reset() |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1321 |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1322 def _reset(self): |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1323 configmix.clear_assoc() |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1324 for pat, fmode in configmix.DEFAULT_ASSOC: |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1325 configmix.set_assoc(pat, fmode) |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1326 |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1327 def test_getvar(self): |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1328 self.assertEqual( |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1329 "value", |
|
325
ab33d51f3412
By default quote the "#" character also because it is typically a comment in all the configuration file formats.
Franz Glasner <fzglas.hg@dom66.de>
parents:
323
diff
changeset
|
1330 self._cfg.getvar("%x23%x3a%x7c%x25%x2e.%x2e.%x3a.%x25.%x7c./.%x23")) |
|
320
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1331 self.assertEqual( |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1332 "value", |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1333 self._cfg.getvar( |
|
325
ab33d51f3412
By default quote the "#" character also because it is typically a comment in all the configuration file formats.
Franz Glasner <fzglas.hg@dom66.de>
parents:
323
diff
changeset
|
1334 "%u0023%u003a%u007c%u0025%u002e.%u002e.%u003a.%u0025.%u007c./.%u0023")) |
|
320
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1335 self.assertEqual( |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1336 "value", |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1337 self._cfg.getvar( |
|
325
ab33d51f3412
By default quote the "#" character also because it is typically a comment in all the configuration file formats.
Franz Glasner <fzglas.hg@dom66.de>
parents:
323
diff
changeset
|
1338 "%U00000023%U0000003a%U0000007c%U00000025%U0000002e.%U0000002e.%U0000003a.%U00000025.%U0000007c./.%U00000023")) |
|
320
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1339 |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1340 def test_getvar_s(self): |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1341 self.assertEqual( |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1342 "value", |
|
325
ab33d51f3412
By default quote the "#" character also because it is typically a comment in all the configuration file formats.
Franz Glasner <fzglas.hg@dom66.de>
parents:
323
diff
changeset
|
1343 self._cfg.getvar_s("%x23%x3a%x7c%x25%x2e.%x2e.%x3a.%x25.%x7c./.%x23")) |
|
320
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1344 self.assertEqual( |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1345 "value", |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1346 self._cfg.getvar_s( |
|
325
ab33d51f3412
By default quote the "#" character also because it is typically a comment in all the configuration file formats.
Franz Glasner <fzglas.hg@dom66.de>
parents:
323
diff
changeset
|
1347 "%u0023%u003a%u007c%u0025%u002e.%u002e.%u003a.%u0025.%u007c./.%u0023")) |
|
320
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1348 self.assertEqual( |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1349 "value", |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1350 self._cfg.getvar_s( |
|
325
ab33d51f3412
By default quote the "#" character also because it is typically a comment in all the configuration file formats.
Franz Glasner <fzglas.hg@dom66.de>
parents:
323
diff
changeset
|
1351 "%U00000023%U0000003a%U0000007c%U00000025%U0000002e.%U0000002e.%U0000003a.%U00000025.%U0000007c./.%U00000023")) |
|
320
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1352 |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1353 def test_getvarl(self): |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1354 self.assertEqual( |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1355 "value", |
|
325
ab33d51f3412
By default quote the "#" character also because it is typically a comment in all the configuration file formats.
Franz Glasner <fzglas.hg@dom66.de>
parents:
323
diff
changeset
|
1356 self._cfg.getvarl("#:|%.", ".", ":", "%", "|", "/", "#")) |
|
320
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1357 |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1358 def test_getvarl_s(self): |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1359 self.assertEqual( |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1360 "value", |
|
325
ab33d51f3412
By default quote the "#" character also because it is typically a comment in all the configuration file formats.
Franz Glasner <fzglas.hg@dom66.de>
parents:
323
diff
changeset
|
1361 self._cfg.getvarl_s("#:|%.", ".", ":", "%", "|", "/", "#")) |
|
320
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1362 |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1363 def test_interpolation1(self): |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1364 self.assertEqual( |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1365 "value", |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1366 self._cfg.getvarl_s("events", "qc-2021.1-5G-summit", "xname")) |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1367 |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1368 def test_interpolation2(self): |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1369 self.assertEqual( |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1370 "value", |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1371 self._cfg.getvar_s("events.qc-2021%x2e1-5G-summit.xname")) |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1372 |
|
325
ab33d51f3412
By default quote the "#" character also because it is typically a comment in all the configuration file formats.
Franz Glasner <fzglas.hg@dom66.de>
parents:
323
diff
changeset
|
1373 def test_reference1(self): |
|
ab33d51f3412
By default quote the "#" character also because it is typically a comment in all the configuration file formats.
Franz Glasner <fzglas.hg@dom66.de>
parents:
323
diff
changeset
|
1374 self.assertTrue( |
|
ab33d51f3412
By default quote the "#" character also because it is typically a comment in all the configuration file formats.
Franz Glasner <fzglas.hg@dom66.de>
parents:
323
diff
changeset
|
1375 isinstance( |
|
ab33d51f3412
By default quote the "#" character also because it is typically a comment in all the configuration file formats.
Franz Glasner <fzglas.hg@dom66.de>
parents:
323
diff
changeset
|
1376 self._cfg.getvar_s("events.qc-2021%x2e1-5G-summit.xref"), |
|
ab33d51f3412
By default quote the "#" character also because it is typically a comment in all the configuration file formats.
Franz Glasner <fzglas.hg@dom66.de>
parents:
323
diff
changeset
|
1377 dict)) |
|
ab33d51f3412
By default quote the "#" character also because it is typically a comment in all the configuration file formats.
Franz Glasner <fzglas.hg@dom66.de>
parents:
323
diff
changeset
|
1378 |
|
ab33d51f3412
By default quote the "#" character also because it is typically a comment in all the configuration file formats.
Franz Glasner <fzglas.hg@dom66.de>
parents:
323
diff
changeset
|
1379 def test_reference2(self): |
|
320
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1380 self.assertEqual( |
|
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1381 "value", |
|
325
ab33d51f3412
By default quote the "#" character also because it is typically a comment in all the configuration file formats.
Franz Glasner <fzglas.hg@dom66.de>
parents:
323
diff
changeset
|
1382 self._cfg.getvar_s("events.qc-2021%x2e1-5G-summit.xref.%x23")) |
|
320
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1383 |
|
329
d81d2cdf4925
FIX: Handle the unquoting of namespaces within Configuration.getvar() properly.
Franz Glasner <fzglas.hg@dom66.de>
parents:
327
diff
changeset
|
1384 def test_namespace_quoting(self): |
|
d81d2cdf4925
FIX: Handle the unquoting of namespaces within Configuration.getvar() properly.
Franz Glasner <fzglas.hg@dom66.de>
parents:
327
diff
changeset
|
1385 v1 = self._cfg.getvar("PY:version") |
|
d81d2cdf4925
FIX: Handle the unquoting of namespaces within Configuration.getvar() properly.
Franz Glasner <fzglas.hg@dom66.de>
parents:
327
diff
changeset
|
1386 v2 = self._cfg.getvar("P%x59:version") |
|
331
4f31e69d1ad5
Tests: for namespace quoting use some encoding variants also
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
1387 v3 = self._cfg.getvar("%U00000050Y:version") |
|
4f31e69d1ad5
Tests: for namespace quoting use some encoding variants also
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
1388 v4 = self._cfg.getvar("%x50%u0059:version") |
|
332
5c2c72d26b63
Tests: add a test for variable interpolation with a quoted namespace
Franz Glasner <fzglas.hg@dom66.de>
parents:
331
diff
changeset
|
1389 v5 = self._cfg.getvarl_s("events", "qc-2021.1-5G-summit", "xver") |
|
338
933df3ffd428
Tests: add some more asserte to test_namespace_quoting
Franz Glasner <fzglas.hg@dom66.de>
parents:
337
diff
changeset
|
1390 v6 = self._cfg.getvar_s("events.qc-2021%x2e1-5G-summit.xver") |
|
329
d81d2cdf4925
FIX: Handle the unquoting of namespaces within Configuration.getvar() properly.
Franz Glasner <fzglas.hg@dom66.de>
parents:
327
diff
changeset
|
1391 self.assertEqual(v1, v2) |
|
d81d2cdf4925
FIX: Handle the unquoting of namespaces within Configuration.getvar() properly.
Franz Glasner <fzglas.hg@dom66.de>
parents:
327
diff
changeset
|
1392 self.assertEqual(v1, v3) |
|
d81d2cdf4925
FIX: Handle the unquoting of namespaces within Configuration.getvar() properly.
Franz Glasner <fzglas.hg@dom66.de>
parents:
327
diff
changeset
|
1393 self.assertEqual(v1, v4) |
| 337 | 1394 self.assertEqual(v1, v5) |
|
338
933df3ffd428
Tests: add some more asserte to test_namespace_quoting
Franz Glasner <fzglas.hg@dom66.de>
parents:
337
diff
changeset
|
1395 self.assertEqual(v1, v6) |
|
320
98490375d90c
Allow variable name quoting to be used in .getvar() and .getvar_s() and references
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
1396 |
|
340
176e22110fc5
docs, tests: notes and additional tests when quoting the "ref" namespace name
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
1397 def test_direct_ref_namespace_quoting(self): |
|
176e22110fc5
docs, tests: notes and additional tests when quoting the "ref" namespace name
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
1398 v = self._cfg.getvar_s("re%x66:#%x23%u003a%x7c%U00000025%x2e.%x2e.%x3a.%x25.%x7c./.%x23") |
|
176e22110fc5
docs, tests: notes and additional tests when quoting the "ref" namespace name
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
1399 self.assertEqual("value", v) |
|
176e22110fc5
docs, tests: notes and additional tests when quoting the "ref" namespace name
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
1400 |
| 330 | 1401 |
|
395
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1402 class T08Jailed(unittest.TestCase): |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1403 |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1404 def setUp(self): |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1405 pass |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1406 |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1407 def tearDown(self): |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1408 self._reset() |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1409 |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1410 def _reset(self): |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1411 configmix.clear_assoc() |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1412 for pat, fmode in configmix.DEFAULT_ASSOC: |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1413 configmix.set_assoc(pat, fmode) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1414 |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1415 def test_root(self): |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1416 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1417 jcfg = cfg.jailed(root=u"tree1") |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1418 |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1419 self.assertTrue(jcfg.getvarl(u"tree2", u"key5")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1420 self.assertTrue(jcfg.getvarl_s(u"tree2", u"key5")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1421 self.assertEqual( |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1422 u"get this as `tree1.tree2.key4'", |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1423 jcfg.getvarl(u"tree2", u"key4")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1424 self.assertEqual( |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1425 u"get this as `tree1.tree2.key4'", |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1426 jcfg.getvarl_s(u"tree2", u"key4")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1427 |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1428 self.assertTrue(jcfg.getvar(u"tree2.key5")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1429 self.assertTrue(jcfg.getvar_s(u"tree2.key5")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1430 self.assertEqual( |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1431 u"get this as `tree1.tree2.key4'", |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1432 jcfg.getvar(u"tree2.key4")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1433 self.assertEqual( |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1434 u"get this as `tree1.tree2.key4'", |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1435 jcfg.getvar_s(u"tree2.key4")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1436 |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1437 def test_root2(self): |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1438 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1439 jcfg = cfg.jailed(root=u"tree1.tree2") |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1440 |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1441 self.assertTrue(jcfg.getvarl(u"key5")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1442 self.assertTrue(jcfg.getvarl_s(u"key5")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1443 self.assertEqual( |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1444 u"get this as `tree1.tree2.key4'", |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1445 jcfg.getvarl(u"key4")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1446 self.assertEqual( |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1447 u"get this as `tree1.tree2.key4'", |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1448 jcfg.getvarl_s(u"key4")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1449 |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1450 self.assertTrue(jcfg.getvar(u"key5")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1451 self.assertTrue(jcfg.getvar_s(u"key5")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1452 self.assertEqual( |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1453 u"get this as `tree1.tree2.key4'", |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1454 jcfg.getvar(u"key4")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1455 self.assertEqual( |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1456 u"get this as `tree1.tree2.key4'", |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1457 jcfg.getvar_s(u"key4")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1458 |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1459 def test_root_non_existing_raises(self): |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1460 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1461 self.assertRaises(KeyError, cfg.jailed, root=u"tree-non-existing") |
|
456
d6be95841380
Add a test for proper exception formatting when .rebind() raises a KeyError
Franz Glasner <fzglas.hg@dom66.de>
parents:
448
diff
changeset
|
1462 self.assertRaises( |
|
d6be95841380
Add a test for proper exception formatting when .rebind() raises a KeyError
Franz Glasner <fzglas.hg@dom66.de>
parents:
448
diff
changeset
|
1463 KeyError, cfg.jailed, rootpath=(u"non", u"existing", u"tree")) |
|
395
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1464 |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1465 def test_rootpath(self): |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1466 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1467 jcfg = cfg.jailed(rootpath=[u"tree1"]) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1468 |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1469 self.assertTrue(jcfg.getvarl(u"tree2", u"key5")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1470 self.assertTrue(jcfg.getvarl_s(u"tree2", u"key5")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1471 self.assertEqual( |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1472 u"get this as `tree1.tree2.key4'", |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1473 jcfg.getvarl_s(u"tree2", u"key4")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1474 |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1475 self.assertTrue(jcfg.getvar(u"tree2.key5")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1476 self.assertTrue(jcfg.getvar_s(u"tree2.key5")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1477 self.assertEqual( |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1478 u"get this as `tree1.tree2.key4'", |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1479 jcfg.getvar_s(u"tree2.key4")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1480 |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1481 def test_rootpath_non_existing_raises(self): |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1482 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1483 self.assertRaises( |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1484 KeyError, cfg.jailed, rootpath=[u"tree-non-existing"]) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1485 |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1486 def test_root_empty(self): |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1487 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
416
2abde0d3c735
FIX: Handle .jailed() with an empty "root" properly
Franz Glasner <fzglas.hg@dom66.de>
parents:
412
diff
changeset
|
1488 jcfg = cfg.jailed(root=u"") |
|
395
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1489 |
|
417
83d537f1dfbb
Implement sub-jails: allow to get a jailed configuration from a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
416
diff
changeset
|
1490 self.assertFalse(jcfg._path) |
|
83d537f1dfbb
Implement sub-jails: allow to get a jailed configuration from a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
416
diff
changeset
|
1491 self.assertFalse(jcfg._pathstr) |
|
83d537f1dfbb
Implement sub-jails: allow to get a jailed configuration from a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
416
diff
changeset
|
1492 self.assertTrue(jcfg._path is not None) |
|
83d537f1dfbb
Implement sub-jails: allow to get a jailed configuration from a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
416
diff
changeset
|
1493 self.assertTrue(jcfg._pathstr is not None) |
|
83d537f1dfbb
Implement sub-jails: allow to get a jailed configuration from a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
416
diff
changeset
|
1494 |
|
395
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1495 self.assertTrue(jcfg.getvarl(u"tree1", u"tree2", u"key5")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1496 self.assertTrue(jcfg.getvarl_s(u"tree1", u"tree2", u"key5")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1497 self.assertEqual( |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1498 u"get this as `tree1.tree2.key4'", |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1499 jcfg.getvarl_s(u"tree1", u"tree2", u"key4")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1500 |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1501 self.assertTrue(jcfg.getvar(u"tree1.tree2.key5")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1502 self.assertTrue(jcfg.getvar_s(u"tree1.tree2.key5")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1503 self.assertEqual( |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1504 u"get this as `tree1.tree2.key4'", |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1505 jcfg.getvar_s(u"tree1.tree2.key4")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1506 |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1507 def test_rootpath_empty(self): |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1508 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1509 jcfg = cfg.jailed(rootpath=tuple()) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1510 |
|
417
83d537f1dfbb
Implement sub-jails: allow to get a jailed configuration from a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
416
diff
changeset
|
1511 self.assertFalse(jcfg._path) |
|
83d537f1dfbb
Implement sub-jails: allow to get a jailed configuration from a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
416
diff
changeset
|
1512 self.assertFalse(jcfg._pathstr) |
|
83d537f1dfbb
Implement sub-jails: allow to get a jailed configuration from a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
416
diff
changeset
|
1513 self.assertTrue(jcfg._path is not None) |
|
83d537f1dfbb
Implement sub-jails: allow to get a jailed configuration from a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
416
diff
changeset
|
1514 self.assertTrue(jcfg._pathstr is not None) |
|
83d537f1dfbb
Implement sub-jails: allow to get a jailed configuration from a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
416
diff
changeset
|
1515 |
|
395
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1516 self.assertTrue(jcfg.getvarl(u"tree1", u"tree2", u"key5")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1517 self.assertTrue(jcfg.getvarl_s(u"tree1", u"tree2", u"key5")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1518 self.assertEqual( |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1519 u"get this as `tree1.tree2.key4'", |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1520 jcfg.getvarl_s(u"tree1", u"tree2", u"key4")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1521 |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1522 self.assertTrue(jcfg.getvar(u"tree1.tree2.key5")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1523 self.assertTrue(jcfg.getvar_s(u"tree1.tree2.key5")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1524 self.assertEqual( |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1525 u"get this as `tree1.tree2.key4'", |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1526 jcfg.getvar_s(u"tree1.tree2.key4")) |
|
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
1527 |
|
398
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1528 def test_rootpath_getfirstvar_nonexisting(self): |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1529 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1530 jcfg = cfg.jailed(rootpath=(u"tree1",)) |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1531 |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1532 self.assertIsNone(jcfg.getfirstvarl( |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1533 *[(u"a", u"b"), |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1534 (u"tree2", u"no-key")], |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1535 default=None)) |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1536 self.assertIsNone(jcfg.getfirstvarl_s( |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1537 *[(u"a", u"b"), |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1538 (u"tree2", u"no-key")], |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1539 default=None)) |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1540 self.assertIsNone(jcfg.getfirstvar( |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1541 u"a.b", u"tree2.no-key", |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1542 default=None)) |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1543 self.assertIsNone(jcfg.getfirstvar_s( |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1544 u"a.b", u"tree2.no-key", |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1545 default=None)) |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1546 |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1547 def test_rootpath_getfirstvar_raising(self): |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1548 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1549 jcfg = cfg.jailed(rootpath=(u"tree1",)) |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1550 |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1551 self.assertRaises( |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1552 KeyError, |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1553 jcfg.getfirstvarl, |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1554 (u"a", u"b"), |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1555 (u"tree2", u"no-key")) |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1556 self.assertRaises( |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1557 KeyError, |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1558 jcfg.getfirstvarl_s, |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1559 (u"a", u"b"), |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1560 (u"tree2", u"no-key")) |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1561 self.assertRaises( |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1562 KeyError, |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1563 jcfg.getfirstvar, |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1564 u"a.b", u"tree2.no-key") |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1565 self.assertRaises( |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1566 KeyError, |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1567 jcfg.getfirstvar_s, |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1568 u"a.b", u"tree2.no-key") |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1569 |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1570 def test_rootpath_getfirstvar_existing(self): |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1571 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1572 jcfg = cfg.jailed(rootpath=(u"tree1",)) |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1573 |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1574 self.assertEqual( |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1575 u"get this as `tree1.tree2.key4'", |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1576 jcfg.getfirstvarl( |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1577 *[(u"a", u"b"), |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1578 (u"tree2", u"key4")])) |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1579 self.assertEqual( |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1580 0x20, |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1581 jcfg.getfirstvarl_s( |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1582 *[(u"a", u"b"), |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1583 (u"key3", ), |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1584 (u"tree2", u"key4")])) |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1585 self.assertEqual( |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1586 0x20, |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1587 jcfg.getfirstvar( |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1588 u"key1", u"key3")) |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1589 self.assertEqual( |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1590 u"get this as `tree1.tree2.key4'", |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1591 jcfg.getfirstvar_s( |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1592 u"a.b", u"tree2.key4", u"tree2.key5")) |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1593 |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1594 def test_root_getfirstvar_nonexisting(self): |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1595 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1596 jcfg = cfg.jailed(root=u"tree1") |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1597 |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1598 self.assertIsNone(jcfg.getfirstvarl( |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1599 *[(u"a", u"b"), |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1600 (u"tree2", u"no-key")], |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1601 default=None)) |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1602 self.assertIsNone(jcfg.getfirstvarl_s( |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1603 *[(u"a", u"b"), |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1604 (u"tree2", u"no-key")], |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1605 default=None)) |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1606 self.assertIsNone(jcfg.getfirstvarl_s( |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1607 *[(u"a", u"b"), |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1608 (u"tree2", u"no-key")], |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1609 default=None)) |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1610 self.assertIsNone(jcfg.getfirstvar_s( |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1611 u"a.b", u"tree2.no-key", |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1612 default=None)) |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1613 |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1614 def test_root_getfirstvar_raising(self): |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1615 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1616 jcfg = cfg.jailed(root=u"tree1") |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1617 |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1618 self.assertRaises( |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1619 KeyError, |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1620 jcfg.getfirstvarl, |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1621 (u"a", u"b"), |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1622 (u"tree2", u"no-key")) |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1623 self.assertRaises( |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1624 KeyError, |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1625 jcfg.getfirstvarl_s, |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1626 (u"a", u"b"), |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1627 (u"tree2", u"no-key")) |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1628 self.assertRaises( |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1629 KeyError, |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1630 jcfg.getfirstvar, |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1631 u"a.b", u"tree2.no-key") |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1632 self.assertRaises( |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1633 KeyError, |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1634 jcfg.getfirstvar_s, |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1635 u"a.b", u"tree2.no-key") |
|
b1f82b853290
Jailed configuration: implement more methods: getfirstvarl, getfirstvarl_s, getfirstvar and getfirstvar_s
Franz Glasner <fzglas.hg@dom66.de>
parents:
395
diff
changeset
|
1636 |
|
407
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1637 def test_base_rebind(self): |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1638 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1639 self.assertFalse(cfg.is_jail) |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1640 |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1641 jcfg = cfg.jailed(rootpath=[]) |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1642 self.assertTrue(jcfg.is_jail) |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1643 |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1644 self.assertTrue(jcfg.base is cfg) |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1645 |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1646 self.assertRaises( |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1647 KeyError, |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1648 jcfg.getvarl, |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1649 u"tree1", u"tree2", u"no-key") |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1650 self.assertEqual( |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1651 0x20, |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1652 jcfg.getvar(u"tree1.key3")) |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1653 self.assertEqual( |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1654 u"in the root namespace", |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1655 jcfg.getvar("key1")) |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1656 |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1657 cfg2 = configmix.load(os.path.join(TESTDATADIR, "conf2.py")) |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1658 self.assertFalse(cfg2.is_jail) |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1659 |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1660 jcfg.rebind(cfg2) |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1661 self.assertTrue(jcfg.base is cfg2) |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1662 |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1663 self.assertRaises( |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1664 KeyError, |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1665 jcfg.getvar, |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1666 u"tree1.key3") |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1667 self.assertEqual( |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1668 u"the next value", |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1669 jcfg.getvar("key1")) |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1670 |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1671 def test_rebind_no_nesting(self): |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1672 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1673 self.assertFalse(cfg.is_jail) |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1674 |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1675 jcfg1 = cfg.jailed(rootpath=[]) |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1676 self.assertTrue(jcfg1.is_jail) |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1677 jcfg2 = cfg.jailed(rootpath=[u"tree1"]) |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1678 self.assertTrue(jcfg2.is_jail) |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1679 |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1680 self.assertRaises( |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1681 TypeError, |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1682 jcfg1.rebind, |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1683 jcfg2) |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1684 |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1685 # base is not because rebind() failed |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1686 self.assertTrue(cfg is jcfg1.base) |
|
1bec7f5fafe8
Unittests for the new base and rebind features
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
404
diff
changeset
|
1687 |
|
412
816327e178b0
Provide coercing methods for the jailed configuration: getintXXX(), getboolXXX(), getfloatXXX() and friends.
Franz Glasner <fzglas.hg@dom66.de>
parents:
407
diff
changeset
|
1688 def test_getbool(self): |
|
816327e178b0
Provide coercing methods for the jailed configuration: getintXXX(), getboolXXX(), getfloatXXX() and friends.
Franz Glasner <fzglas.hg@dom66.de>
parents:
407
diff
changeset
|
1689 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
816327e178b0
Provide coercing methods for the jailed configuration: getintXXX(), getboolXXX(), getfloatXXX() and friends.
Franz Glasner <fzglas.hg@dom66.de>
parents:
407
diff
changeset
|
1690 jcfg = cfg.jailed(rootpath=(u"tree1", u"tree2")) |
|
816327e178b0
Provide coercing methods for the jailed configuration: getintXXX(), getboolXXX(), getfloatXXX() and friends.
Franz Glasner <fzglas.hg@dom66.de>
parents:
407
diff
changeset
|
1691 |
|
816327e178b0
Provide coercing methods for the jailed configuration: getintXXX(), getboolXXX(), getfloatXXX() and friends.
Franz Glasner <fzglas.hg@dom66.de>
parents:
407
diff
changeset
|
1692 self.assertFalse(jcfg.getboolvar_s(u"key6")) |
|
816327e178b0
Provide coercing methods for the jailed configuration: getintXXX(), getboolXXX(), getfloatXXX() and friends.
Franz Glasner <fzglas.hg@dom66.de>
parents:
407
diff
changeset
|
1693 self.assertEqual(u"off", jcfg.getvarl_s(u"key6")) |
|
816327e178b0
Provide coercing methods for the jailed configuration: getintXXX(), getboolXXX(), getfloatXXX() and friends.
Franz Glasner <fzglas.hg@dom66.de>
parents:
407
diff
changeset
|
1694 self.assertTrue(jcfg.getvar_s(u"key6")) |
|
816327e178b0
Provide coercing methods for the jailed configuration: getintXXX(), getboolXXX(), getfloatXXX() and friends.
Franz Glasner <fzglas.hg@dom66.de>
parents:
407
diff
changeset
|
1695 |
|
417
83d537f1dfbb
Implement sub-jails: allow to get a jailed configuration from a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
416
diff
changeset
|
1696 def test_subjail_from_rootpath_empty(self): |
|
83d537f1dfbb
Implement sub-jails: allow to get a jailed configuration from a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
416
diff
changeset
|
1697 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
83d537f1dfbb
Implement sub-jails: allow to get a jailed configuration from a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
416
diff
changeset
|
1698 jcfg = cfg.jailed(rootpath=tuple()) |
|
83d537f1dfbb
Implement sub-jails: allow to get a jailed configuration from a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
416
diff
changeset
|
1699 |
|
83d537f1dfbb
Implement sub-jails: allow to get a jailed configuration from a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
416
diff
changeset
|
1700 sjcfg = jcfg.jailed(rootpath=(u"tree1",)) |
|
83d537f1dfbb
Implement sub-jails: allow to get a jailed configuration from a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
416
diff
changeset
|
1701 |
|
83d537f1dfbb
Implement sub-jails: allow to get a jailed configuration from a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
416
diff
changeset
|
1702 self.assertTrue(sjcfg._path) |
|
83d537f1dfbb
Implement sub-jails: allow to get a jailed configuration from a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
416
diff
changeset
|
1703 self.assertTrue(sjcfg._pathstr) |
|
83d537f1dfbb
Implement sub-jails: allow to get a jailed configuration from a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
416
diff
changeset
|
1704 |
|
83d537f1dfbb
Implement sub-jails: allow to get a jailed configuration from a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
416
diff
changeset
|
1705 self.assertEqual(0x20, sjcfg.getintvar_s(u"key3")) |
|
83d537f1dfbb
Implement sub-jails: allow to get a jailed configuration from a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
416
diff
changeset
|
1706 |
|
427
40be1d25ff1c
Test the base of sub-jails
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
419
diff
changeset
|
1707 self.assertTrue(sjcfg.base is cfg) |
|
40be1d25ff1c
Test the base of sub-jails
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
419
diff
changeset
|
1708 |
|
417
83d537f1dfbb
Implement sub-jails: allow to get a jailed configuration from a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
416
diff
changeset
|
1709 def test_subjail_from_root_empty(self): |
|
83d537f1dfbb
Implement sub-jails: allow to get a jailed configuration from a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
416
diff
changeset
|
1710 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
83d537f1dfbb
Implement sub-jails: allow to get a jailed configuration from a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
416
diff
changeset
|
1711 jcfg = cfg.jailed(root=u"") |
|
83d537f1dfbb
Implement sub-jails: allow to get a jailed configuration from a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
416
diff
changeset
|
1712 |
|
83d537f1dfbb
Implement sub-jails: allow to get a jailed configuration from a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
416
diff
changeset
|
1713 sjcfg = jcfg.jailed(root=u"tree1") |
|
83d537f1dfbb
Implement sub-jails: allow to get a jailed configuration from a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
416
diff
changeset
|
1714 |
|
83d537f1dfbb
Implement sub-jails: allow to get a jailed configuration from a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
416
diff
changeset
|
1715 self.assertTrue(sjcfg._path) |
|
83d537f1dfbb
Implement sub-jails: allow to get a jailed configuration from a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
416
diff
changeset
|
1716 self.assertTrue(sjcfg._pathstr) |
|
83d537f1dfbb
Implement sub-jails: allow to get a jailed configuration from a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
416
diff
changeset
|
1717 |
|
83d537f1dfbb
Implement sub-jails: allow to get a jailed configuration from a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
416
diff
changeset
|
1718 self.assertEqual(0x20, sjcfg.getintvar_s(u"key3")) |
|
83d537f1dfbb
Implement sub-jails: allow to get a jailed configuration from a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
416
diff
changeset
|
1719 |
|
427
40be1d25ff1c
Test the base of sub-jails
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
419
diff
changeset
|
1720 self.assertTrue(sjcfg.base is cfg) |
|
40be1d25ff1c
Test the base of sub-jails
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
419
diff
changeset
|
1721 |
|
418
bb5f11abd12a
Implement .getkeysl() and .getkeys() for configuration objects that iterate over all the keys of a configuration value
Franz Glasner <fzglas.hg@dom66.de>
parents:
417
diff
changeset
|
1722 def test_getkeys(self): |
|
bb5f11abd12a
Implement .getkeysl() and .getkeys() for configuration objects that iterate over all the keys of a configuration value
Franz Glasner <fzglas.hg@dom66.de>
parents:
417
diff
changeset
|
1723 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
bb5f11abd12a
Implement .getkeysl() and .getkeys() for configuration objects that iterate over all the keys of a configuration value
Franz Glasner <fzglas.hg@dom66.de>
parents:
417
diff
changeset
|
1724 jcfg = cfg.jailed(root=u"tree1") |
|
bb5f11abd12a
Implement .getkeysl() and .getkeys() for configuration objects that iterate over all the keys of a configuration value
Franz Glasner <fzglas.hg@dom66.de>
parents:
417
diff
changeset
|
1725 |
|
bb5f11abd12a
Implement .getkeysl() and .getkeys() for configuration objects that iterate over all the keys of a configuration value
Franz Glasner <fzglas.hg@dom66.de>
parents:
417
diff
changeset
|
1726 self.assertEqual( |
|
460
d22985d6806e
Proper boolean context for jailed configurations: __bool__()/__nonzero__()
Franz Glasner <fzglas.hg@dom66.de>
parents:
459
diff
changeset
|
1727 set([u"key4", u"key5", u"key6", u"key7", u"key8", u"key9"]), |
|
418
bb5f11abd12a
Implement .getkeysl() and .getkeys() for configuration objects that iterate over all the keys of a configuration value
Franz Glasner <fzglas.hg@dom66.de>
parents:
417
diff
changeset
|
1728 set(jcfg.getkeysl(u"tree2"))) |
|
bb5f11abd12a
Implement .getkeysl() and .getkeys() for configuration objects that iterate over all the keys of a configuration value
Franz Glasner <fzglas.hg@dom66.de>
parents:
417
diff
changeset
|
1729 |
|
bb5f11abd12a
Implement .getkeysl() and .getkeys() for configuration objects that iterate over all the keys of a configuration value
Franz Glasner <fzglas.hg@dom66.de>
parents:
417
diff
changeset
|
1730 self.assertEqual( |
|
460
d22985d6806e
Proper boolean context for jailed configurations: __bool__()/__nonzero__()
Franz Glasner <fzglas.hg@dom66.de>
parents:
459
diff
changeset
|
1731 set([u"key4", u"key5", u"key6", u"key7", u"key8", u"key9"]), |
|
418
bb5f11abd12a
Implement .getkeysl() and .getkeys() for configuration objects that iterate over all the keys of a configuration value
Franz Glasner <fzglas.hg@dom66.de>
parents:
417
diff
changeset
|
1732 set(jcfg.getkeys(u"tree2"))) |
|
bb5f11abd12a
Implement .getkeysl() and .getkeys() for configuration objects that iterate over all the keys of a configuration value
Franz Glasner <fzglas.hg@dom66.de>
parents:
417
diff
changeset
|
1733 |
|
bb5f11abd12a
Implement .getkeysl() and .getkeys() for configuration objects that iterate over all the keys of a configuration value
Franz Glasner <fzglas.hg@dom66.de>
parents:
417
diff
changeset
|
1734 self.assertEqual( |
|
bb5f11abd12a
Implement .getkeysl() and .getkeys() for configuration objects that iterate over all the keys of a configuration value
Franz Glasner <fzglas.hg@dom66.de>
parents:
417
diff
changeset
|
1735 set([u"key3", u"tree2"]), |
|
bb5f11abd12a
Implement .getkeysl() and .getkeys() for configuration objects that iterate over all the keys of a configuration value
Franz Glasner <fzglas.hg@dom66.de>
parents:
417
diff
changeset
|
1736 set(jcfg.getkeysl())) |
|
bb5f11abd12a
Implement .getkeysl() and .getkeys() for configuration objects that iterate over all the keys of a configuration value
Franz Glasner <fzglas.hg@dom66.de>
parents:
417
diff
changeset
|
1737 |
|
419
079a82129110
Allow the empty variable name to retrieve the root configuration object
Franz Glasner <fzglas.hg@dom66.de>
parents:
418
diff
changeset
|
1738 def test_getkeys_all_empty_paths(self): |
|
079a82129110
Allow the empty variable name to retrieve the root configuration object
Franz Glasner <fzglas.hg@dom66.de>
parents:
418
diff
changeset
|
1739 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
079a82129110
Allow the empty variable name to retrieve the root configuration object
Franz Glasner <fzglas.hg@dom66.de>
parents:
418
diff
changeset
|
1740 jcfg = cfg.jailed(rootpath=tuple()) |
|
079a82129110
Allow the empty variable name to retrieve the root configuration object
Franz Glasner <fzglas.hg@dom66.de>
parents:
418
diff
changeset
|
1741 |
|
079a82129110
Allow the empty variable name to retrieve the root configuration object
Franz Glasner <fzglas.hg@dom66.de>
parents:
418
diff
changeset
|
1742 self.assertEqual( |
|
079a82129110
Allow the empty variable name to retrieve the root configuration object
Franz Glasner <fzglas.hg@dom66.de>
parents:
418
diff
changeset
|
1743 set([u"key1", u"key2", u"tree1"]), |
|
079a82129110
Allow the empty variable name to retrieve the root configuration object
Franz Glasner <fzglas.hg@dom66.de>
parents:
418
diff
changeset
|
1744 set(jcfg.getkeysl())) |
|
079a82129110
Allow the empty variable name to retrieve the root configuration object
Franz Glasner <fzglas.hg@dom66.de>
parents:
418
diff
changeset
|
1745 |
|
079a82129110
Allow the empty variable name to retrieve the root configuration object
Franz Glasner <fzglas.hg@dom66.de>
parents:
418
diff
changeset
|
1746 self.assertEqual( |
|
079a82129110
Allow the empty variable name to retrieve the root configuration object
Franz Glasner <fzglas.hg@dom66.de>
parents:
418
diff
changeset
|
1747 set([u"key1", u"key2", u"tree1"]), |
|
079a82129110
Allow the empty variable name to retrieve the root configuration object
Franz Glasner <fzglas.hg@dom66.de>
parents:
418
diff
changeset
|
1748 set(jcfg.getkeys(u""))) |
|
079a82129110
Allow the empty variable name to retrieve the root configuration object
Franz Glasner <fzglas.hg@dom66.de>
parents:
418
diff
changeset
|
1749 |
|
432
b96f49c9c76b
Proper "repr()" for a jailed configuration: put the root path into the output
Franz Glasner <fzglas.hg@dom66.de>
parents:
427
diff
changeset
|
1750 def test_repr_empty_rootpath(self): |
|
b96f49c9c76b
Proper "repr()" for a jailed configuration: put the root path into the output
Franz Glasner <fzglas.hg@dom66.de>
parents:
427
diff
changeset
|
1751 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
b96f49c9c76b
Proper "repr()" for a jailed configuration: put the root path into the output
Franz Glasner <fzglas.hg@dom66.de>
parents:
427
diff
changeset
|
1752 jcfg = cfg.jailed(rootpath=tuple()) |
|
b96f49c9c76b
Proper "repr()" for a jailed configuration: put the root path into the output
Franz Glasner <fzglas.hg@dom66.de>
parents:
427
diff
changeset
|
1753 |
|
b96f49c9c76b
Proper "repr()" for a jailed configuration: put the root path into the output
Franz Glasner <fzglas.hg@dom66.de>
parents:
427
diff
changeset
|
1754 self.assertEqual( |
|
b96f49c9c76b
Proper "repr()" for a jailed configuration: put the root path into the output
Franz Glasner <fzglas.hg@dom66.de>
parents:
427
diff
changeset
|
1755 r"_JailedConfiguration(rootpath=())", |
|
b96f49c9c76b
Proper "repr()" for a jailed configuration: put the root path into the output
Franz Glasner <fzglas.hg@dom66.de>
parents:
427
diff
changeset
|
1756 repr(jcfg)) |
|
b96f49c9c76b
Proper "repr()" for a jailed configuration: put the root path into the output
Franz Glasner <fzglas.hg@dom66.de>
parents:
427
diff
changeset
|
1757 |
|
b96f49c9c76b
Proper "repr()" for a jailed configuration: put the root path into the output
Franz Glasner <fzglas.hg@dom66.de>
parents:
427
diff
changeset
|
1758 def test_repr_non_empty_rootpath(self): |
|
b96f49c9c76b
Proper "repr()" for a jailed configuration: put the root path into the output
Franz Glasner <fzglas.hg@dom66.de>
parents:
427
diff
changeset
|
1759 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
b96f49c9c76b
Proper "repr()" for a jailed configuration: put the root path into the output
Franz Glasner <fzglas.hg@dom66.de>
parents:
427
diff
changeset
|
1760 jcfg = cfg.jailed(rootpath=(u"tree1", u"tree2")) |
|
b96f49c9c76b
Proper "repr()" for a jailed configuration: put the root path into the output
Franz Glasner <fzglas.hg@dom66.de>
parents:
427
diff
changeset
|
1761 |
|
b96f49c9c76b
Proper "repr()" for a jailed configuration: put the root path into the output
Franz Glasner <fzglas.hg@dom66.de>
parents:
427
diff
changeset
|
1762 if PY2: |
|
b96f49c9c76b
Proper "repr()" for a jailed configuration: put the root path into the output
Franz Glasner <fzglas.hg@dom66.de>
parents:
427
diff
changeset
|
1763 self.assertEqual( |
|
b96f49c9c76b
Proper "repr()" for a jailed configuration: put the root path into the output
Franz Glasner <fzglas.hg@dom66.de>
parents:
427
diff
changeset
|
1764 r"_JailedConfiguration(rootpath=(u'tree1', u'tree2'))", |
|
b96f49c9c76b
Proper "repr()" for a jailed configuration: put the root path into the output
Franz Glasner <fzglas.hg@dom66.de>
parents:
427
diff
changeset
|
1765 repr(jcfg)) |
|
b96f49c9c76b
Proper "repr()" for a jailed configuration: put the root path into the output
Franz Glasner <fzglas.hg@dom66.de>
parents:
427
diff
changeset
|
1766 else: |
|
b96f49c9c76b
Proper "repr()" for a jailed configuration: put the root path into the output
Franz Glasner <fzglas.hg@dom66.de>
parents:
427
diff
changeset
|
1767 self.assertEqual( |
|
b96f49c9c76b
Proper "repr()" for a jailed configuration: put the root path into the output
Franz Glasner <fzglas.hg@dom66.de>
parents:
427
diff
changeset
|
1768 r"_JailedConfiguration(rootpath=('tree1', 'tree2'))", |
|
b96f49c9c76b
Proper "repr()" for a jailed configuration: put the root path into the output
Franz Glasner <fzglas.hg@dom66.de>
parents:
427
diff
changeset
|
1769 repr(jcfg)) |
|
b96f49c9c76b
Proper "repr()" for a jailed configuration: put the root path into the output
Franz Glasner <fzglas.hg@dom66.de>
parents:
427
diff
changeset
|
1770 |
|
437
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1771 def test_dict_level_access_with_single_key(self): |
|
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1772 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1773 jcfg = cfg.jailed(rootpath=(u"tree1", u"tree2")) |
|
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1774 self.assertEqual( |
|
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1775 u"off", |
|
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1776 jcfg[u"key6"]) |
|
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1777 try: |
|
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1778 jcfg[u"key3"] |
|
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1779 except KeyError: |
|
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1780 pass |
|
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1781 else: |
|
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1782 self.fail("KeyError expected") |
|
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1783 |
|
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1784 def test_dict_level_access_with_path(self): |
|
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1785 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1786 jcfg = cfg.jailed(rootpath=(u"tree1", u"tree2")) |
|
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1787 self.assertEqual( |
|
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1788 u"get this as `tree1.tree2.key4'", |
|
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1789 jcfg[(u"key4",)]) |
|
441
9d20fab53a19
FIX: Handle "list"-type keys in __contains__ and __getitem__ properly: convert to tuples for contatenation with tuple
Franz Glasner <fzglas.hg@dom66.de>
parents:
439
diff
changeset
|
1790 self.assertEqual( |
|
9d20fab53a19
FIX: Handle "list"-type keys in __contains__ and __getitem__ properly: convert to tuples for contatenation with tuple
Franz Glasner <fzglas.hg@dom66.de>
parents:
439
diff
changeset
|
1791 u"get this as `tree1.tree2.key4'", |
|
9d20fab53a19
FIX: Handle "list"-type keys in __contains__ and __getitem__ properly: convert to tuples for contatenation with tuple
Franz Glasner <fzglas.hg@dom66.de>
parents:
439
diff
changeset
|
1792 jcfg[[u"key4"]]) |
|
437
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1793 try: |
|
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1794 jcfg[(u"key3",)] |
|
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1795 except KeyError: |
|
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1796 pass |
|
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1797 else: |
|
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1798 self.fail("KeyError expected") |
|
441
9d20fab53a19
FIX: Handle "list"-type keys in __contains__ and __getitem__ properly: convert to tuples for contatenation with tuple
Franz Glasner <fzglas.hg@dom66.de>
parents:
439
diff
changeset
|
1799 try: |
|
9d20fab53a19
FIX: Handle "list"-type keys in __contains__ and __getitem__ properly: convert to tuples for contatenation with tuple
Franz Glasner <fzglas.hg@dom66.de>
parents:
439
diff
changeset
|
1800 jcfg[[u"key3"]] |
|
9d20fab53a19
FIX: Handle "list"-type keys in __contains__ and __getitem__ properly: convert to tuples for contatenation with tuple
Franz Glasner <fzglas.hg@dom66.de>
parents:
439
diff
changeset
|
1801 except KeyError: |
|
9d20fab53a19
FIX: Handle "list"-type keys in __contains__ and __getitem__ properly: convert to tuples for contatenation with tuple
Franz Glasner <fzglas.hg@dom66.de>
parents:
439
diff
changeset
|
1802 pass |
|
9d20fab53a19
FIX: Handle "list"-type keys in __contains__ and __getitem__ properly: convert to tuples for contatenation with tuple
Franz Glasner <fzglas.hg@dom66.de>
parents:
439
diff
changeset
|
1803 else: |
|
9d20fab53a19
FIX: Handle "list"-type keys in __contains__ and __getitem__ properly: convert to tuples for contatenation with tuple
Franz Glasner <fzglas.hg@dom66.de>
parents:
439
diff
changeset
|
1804 self.fail("KeyError expected") |
|
437
bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
1805 |
|
439
bd27da55483a
Optimized __contains__() implementation for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
437
diff
changeset
|
1806 def test_contains_with_string(self): |
|
bd27da55483a
Optimized __contains__() implementation for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
437
diff
changeset
|
1807 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
bd27da55483a
Optimized __contains__() implementation for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
437
diff
changeset
|
1808 jcfg = cfg.jailed(rootpath=(u"tree1",)) |
|
bd27da55483a
Optimized __contains__() implementation for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
437
diff
changeset
|
1809 |
|
bd27da55483a
Optimized __contains__() implementation for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
437
diff
changeset
|
1810 self.assertTrue(u"key3" in jcfg) |
|
bd27da55483a
Optimized __contains__() implementation for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
437
diff
changeset
|
1811 self.assertFalse(u"key3-not" in jcfg) |
|
bd27da55483a
Optimized __contains__() implementation for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
437
diff
changeset
|
1812 |
|
bd27da55483a
Optimized __contains__() implementation for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
437
diff
changeset
|
1813 def test_contains_with_path(self): |
|
bd27da55483a
Optimized __contains__() implementation for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
437
diff
changeset
|
1814 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
bd27da55483a
Optimized __contains__() implementation for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
437
diff
changeset
|
1815 jcfg = cfg.jailed(rootpath=(u"tree1",)) |
|
bd27da55483a
Optimized __contains__() implementation for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
437
diff
changeset
|
1816 |
|
bd27da55483a
Optimized __contains__() implementation for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
437
diff
changeset
|
1817 self.assertTrue((u"key3",) in jcfg) |
|
bd27da55483a
Optimized __contains__() implementation for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
437
diff
changeset
|
1818 self.assertFalse((u"key3-not",) in jcfg) |
|
bd27da55483a
Optimized __contains__() implementation for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
437
diff
changeset
|
1819 |
|
bd27da55483a
Optimized __contains__() implementation for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
437
diff
changeset
|
1820 self.assertTrue((u"tree2", u"key5") in jcfg) |
|
bd27da55483a
Optimized __contains__() implementation for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
437
diff
changeset
|
1821 self.assertFalse((u"tree2", u"no-key") in jcfg) |
|
bd27da55483a
Optimized __contains__() implementation for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
437
diff
changeset
|
1822 |
|
441
9d20fab53a19
FIX: Handle "list"-type keys in __contains__ and __getitem__ properly: convert to tuples for contatenation with tuple
Franz Glasner <fzglas.hg@dom66.de>
parents:
439
diff
changeset
|
1823 self.assertTrue([u"tree2", u"key5"] in jcfg) |
|
9d20fab53a19
FIX: Handle "list"-type keys in __contains__ and __getitem__ properly: convert to tuples for contatenation with tuple
Franz Glasner <fzglas.hg@dom66.de>
parents:
439
diff
changeset
|
1824 self.assertFalse([u"tree2", u"no-key"] in jcfg) |
|
9d20fab53a19
FIX: Handle "list"-type keys in __contains__ and __getitem__ properly: convert to tuples for contatenation with tuple
Franz Glasner <fzglas.hg@dom66.de>
parents:
439
diff
changeset
|
1825 |
|
442
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1826 def test_get_with_string(self): |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1827 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1828 jcfg = cfg.jailed(rootpath=(u"tree1",)) |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1829 |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1830 self.assertEqual( |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1831 0x20, |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1832 jcfg.get(u"key3")) |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1833 self.assertEqual( |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1834 0x2, |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1835 jcfg.get(u"no-key3", default=0x2)) |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1836 |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1837 def test_get_with_path(self): |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1838 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1839 jcfg = cfg.jailed(rootpath=(u"tree1",)) |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1840 |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1841 self.assertEqual( |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1842 0x20, |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1843 jcfg.get((u"key3",))) |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1844 self.assertEqual( |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1845 0x3, |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1846 jcfg.get((u"no-key",), default=0x3)) |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1847 self.assertEqual( |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1848 u"off", |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1849 jcfg.get((u"tree2", u"key6"))) |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1850 self.assertEqual( |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1851 u"the default", |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1852 jcfg.get((u"no", u"key"), default=u"the default")) |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1853 self.assertTrue( |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1854 jcfg.get((u"no", u"key")) is None) |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1855 |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1856 self.assertEqual( |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1857 u"off", |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1858 jcfg.get([u"tree2", u"key6"])) |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1859 self.assertEqual( |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1860 u"the default", |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1861 jcfg.get([u"no", u"key"], default=u"the default")) |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1862 self.assertTrue( |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1863 jcfg.get([u"no", u"key"]) is None) |
|
94cf5a8722d6
Add proper .get() support for jailed and unjailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
441
diff
changeset
|
1864 |
|
448
b95c12781497
Attribute-style access for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
442
diff
changeset
|
1865 def test_attribute_access(self): |
|
b95c12781497
Attribute-style access for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
442
diff
changeset
|
1866 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
b95c12781497
Attribute-style access for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
442
diff
changeset
|
1867 jcfg = cfg.jailed(rootpath=(u"tree1",)) |
|
b95c12781497
Attribute-style access for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
442
diff
changeset
|
1868 |
|
b95c12781497
Attribute-style access for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
442
diff
changeset
|
1869 self.assertEqual(0x20, jcfg.key3) |
|
b95c12781497
Attribute-style access for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
442
diff
changeset
|
1870 self.assertEqual(u"off", jcfg.tree2.key6) |
|
b95c12781497
Attribute-style access for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
442
diff
changeset
|
1871 |
|
711
6557cf9ecea5
FIX: When using attribute access for configurations the values are interpolated since long ago: fix the docu and add a test for that behaviour
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
710
diff
changeset
|
1872 def test_attribute_access_interpolates(self): |
|
6557cf9ecea5
FIX: When using attribute access for configurations the values are interpolated since long ago: fix the docu and add a test for that behaviour
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
710
diff
changeset
|
1873 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
6557cf9ecea5
FIX: When using attribute access for configurations the values are interpolated since long ago: fix the docu and add a test for that behaviour
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
710
diff
changeset
|
1874 self.assertEqual( |
|
6557cf9ecea5
FIX: When using attribute access for configurations the values are interpolated since long ago: fix the docu and add a test for that behaviour
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
710
diff
changeset
|
1875 [u"val1", u"val2", u"in the root namespace"], |
|
6557cf9ecea5
FIX: When using attribute access for configurations the values are interpolated since long ago: fix the docu and add a test for that behaviour
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
710
diff
changeset
|
1876 cfg.tree1.tree2.key8) |
|
6557cf9ecea5
FIX: When using attribute access for configurations the values are interpolated since long ago: fix the docu and add a test for that behaviour
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
710
diff
changeset
|
1877 |
|
448
b95c12781497
Attribute-style access for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
442
diff
changeset
|
1878 def test_attribute_access_non_existing(self): |
|
b95c12781497
Attribute-style access for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
442
diff
changeset
|
1879 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
b95c12781497
Attribute-style access for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
442
diff
changeset
|
1880 jcfg = cfg.jailed(rootpath=(u"tree1",)) |
|
b95c12781497
Attribute-style access for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
442
diff
changeset
|
1881 |
|
b95c12781497
Attribute-style access for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
442
diff
changeset
|
1882 try: |
|
b95c12781497
Attribute-style access for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
442
diff
changeset
|
1883 jcfg.non_existing |
|
b95c12781497
Attribute-style access for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
442
diff
changeset
|
1884 except AttributeError: |
|
b95c12781497
Attribute-style access for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
442
diff
changeset
|
1885 pass |
|
b95c12781497
Attribute-style access for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
442
diff
changeset
|
1886 else: |
|
b95c12781497
Attribute-style access for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
442
diff
changeset
|
1887 self.fail("AttributeError expected") |
|
b95c12781497
Attribute-style access for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
442
diff
changeset
|
1888 |
|
b95c12781497
Attribute-style access for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
442
diff
changeset
|
1889 try: |
|
b95c12781497
Attribute-style access for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
442
diff
changeset
|
1890 jcfg.tree2.non_existing |
|
b95c12781497
Attribute-style access for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
442
diff
changeset
|
1891 except AttributeError: |
|
b95c12781497
Attribute-style access for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
442
diff
changeset
|
1892 pass |
|
b95c12781497
Attribute-style access for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
442
diff
changeset
|
1893 else: |
|
b95c12781497
Attribute-style access for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
442
diff
changeset
|
1894 self.fail("AttributeError expected") |
|
b95c12781497
Attribute-style access for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
442
diff
changeset
|
1895 |
|
459
9dc9cef1b9cd
Implement proper iteration support for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
458
diff
changeset
|
1896 def test_iteration_dict(self): |
|
9dc9cef1b9cd
Implement proper iteration support for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
458
diff
changeset
|
1897 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
9dc9cef1b9cd
Implement proper iteration support for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
458
diff
changeset
|
1898 jcfg = cfg.jailed(rootpath=(u"tree1",)) |
|
9dc9cef1b9cd
Implement proper iteration support for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
458
diff
changeset
|
1899 s = [] |
|
9dc9cef1b9cd
Implement proper iteration support for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
458
diff
changeset
|
1900 for k in jcfg: |
|
9dc9cef1b9cd
Implement proper iteration support for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
458
diff
changeset
|
1901 s.append(k) |
|
9dc9cef1b9cd
Implement proper iteration support for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
458
diff
changeset
|
1902 s.sort() |
|
9dc9cef1b9cd
Implement proper iteration support for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
458
diff
changeset
|
1903 self.assertEqual([u"key3", u"tree2"], s) |
|
9dc9cef1b9cd
Implement proper iteration support for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
458
diff
changeset
|
1904 |
|
9dc9cef1b9cd
Implement proper iteration support for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
458
diff
changeset
|
1905 def test_iteration_list(self): |
|
9dc9cef1b9cd
Implement proper iteration support for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
458
diff
changeset
|
1906 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
9dc9cef1b9cd
Implement proper iteration support for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
458
diff
changeset
|
1907 jcfg = cfg.jailed(rootpath=(u"tree1", u"tree2", u"key8")) |
|
9dc9cef1b9cd
Implement proper iteration support for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
458
diff
changeset
|
1908 s = [] |
|
9dc9cef1b9cd
Implement proper iteration support for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
458
diff
changeset
|
1909 for k in jcfg: |
|
9dc9cef1b9cd
Implement proper iteration support for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
458
diff
changeset
|
1910 s.append(k) |
|
9dc9cef1b9cd
Implement proper iteration support for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
458
diff
changeset
|
1911 s.sort() |
|
9dc9cef1b9cd
Implement proper iteration support for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
458
diff
changeset
|
1912 self.assertEqual([u"in the root namespace", u"val1", u"val2"], s) |
|
9dc9cef1b9cd
Implement proper iteration support for jailed configurations
Franz Glasner <fzglas.hg@dom66.de>
parents:
458
diff
changeset
|
1913 |
|
460
d22985d6806e
Proper boolean context for jailed configurations: __bool__()/__nonzero__()
Franz Glasner <fzglas.hg@dom66.de>
parents:
459
diff
changeset
|
1914 def test_boolean_context_list_false(self): |
|
d22985d6806e
Proper boolean context for jailed configurations: __bool__()/__nonzero__()
Franz Glasner <fzglas.hg@dom66.de>
parents:
459
diff
changeset
|
1915 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
d22985d6806e
Proper boolean context for jailed configurations: __bool__()/__nonzero__()
Franz Glasner <fzglas.hg@dom66.de>
parents:
459
diff
changeset
|
1916 jcfg = cfg.jailed(rootpath=(u"tree1", u"tree2", u"key7")) |
|
d22985d6806e
Proper boolean context for jailed configurations: __bool__()/__nonzero__()
Franz Glasner <fzglas.hg@dom66.de>
parents:
459
diff
changeset
|
1917 self.assertFalse(jcfg) |
|
467
9fcdc42a0457
len-support for jailed configurations: implement a proper __len__() method
Franz Glasner <fzglas.hg@dom66.de>
parents:
461
diff
changeset
|
1918 self.assertEqual(0, len(jcfg)) |
|
460
d22985d6806e
Proper boolean context for jailed configurations: __bool__()/__nonzero__()
Franz Glasner <fzglas.hg@dom66.de>
parents:
459
diff
changeset
|
1919 |
|
d22985d6806e
Proper boolean context for jailed configurations: __bool__()/__nonzero__()
Franz Glasner <fzglas.hg@dom66.de>
parents:
459
diff
changeset
|
1920 def test_boolean_context_list_true(self): |
|
d22985d6806e
Proper boolean context for jailed configurations: __bool__()/__nonzero__()
Franz Glasner <fzglas.hg@dom66.de>
parents:
459
diff
changeset
|
1921 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
d22985d6806e
Proper boolean context for jailed configurations: __bool__()/__nonzero__()
Franz Glasner <fzglas.hg@dom66.de>
parents:
459
diff
changeset
|
1922 jcfg = cfg.jailed(rootpath=(u"tree1", u"tree2", u"key8")) |
|
d22985d6806e
Proper boolean context for jailed configurations: __bool__()/__nonzero__()
Franz Glasner <fzglas.hg@dom66.de>
parents:
459
diff
changeset
|
1923 self.assertTrue(jcfg) |
|
467
9fcdc42a0457
len-support for jailed configurations: implement a proper __len__() method
Franz Glasner <fzglas.hg@dom66.de>
parents:
461
diff
changeset
|
1924 self.assertEqual(3, len(jcfg)) |
|
460
d22985d6806e
Proper boolean context for jailed configurations: __bool__()/__nonzero__()
Franz Glasner <fzglas.hg@dom66.de>
parents:
459
diff
changeset
|
1925 |
|
d22985d6806e
Proper boolean context for jailed configurations: __bool__()/__nonzero__()
Franz Glasner <fzglas.hg@dom66.de>
parents:
459
diff
changeset
|
1926 def test_boolean_context_dict_false(self): |
|
d22985d6806e
Proper boolean context for jailed configurations: __bool__()/__nonzero__()
Franz Glasner <fzglas.hg@dom66.de>
parents:
459
diff
changeset
|
1927 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
d22985d6806e
Proper boolean context for jailed configurations: __bool__()/__nonzero__()
Franz Glasner <fzglas.hg@dom66.de>
parents:
459
diff
changeset
|
1928 jcfg = cfg.jailed(rootpath=(u"tree1", u"tree2", u"key9")) |
|
d22985d6806e
Proper boolean context for jailed configurations: __bool__()/__nonzero__()
Franz Glasner <fzglas.hg@dom66.de>
parents:
459
diff
changeset
|
1929 self.assertFalse(jcfg) |
|
467
9fcdc42a0457
len-support for jailed configurations: implement a proper __len__() method
Franz Glasner <fzglas.hg@dom66.de>
parents:
461
diff
changeset
|
1930 self.assertEqual(0, len(jcfg)) |
|
460
d22985d6806e
Proper boolean context for jailed configurations: __bool__()/__nonzero__()
Franz Glasner <fzglas.hg@dom66.de>
parents:
459
diff
changeset
|
1931 |
|
d22985d6806e
Proper boolean context for jailed configurations: __bool__()/__nonzero__()
Franz Glasner <fzglas.hg@dom66.de>
parents:
459
diff
changeset
|
1932 def test_boolean_context_dict_true(self): |
|
d22985d6806e
Proper boolean context for jailed configurations: __bool__()/__nonzero__()
Franz Glasner <fzglas.hg@dom66.de>
parents:
459
diff
changeset
|
1933 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
d22985d6806e
Proper boolean context for jailed configurations: __bool__()/__nonzero__()
Franz Glasner <fzglas.hg@dom66.de>
parents:
459
diff
changeset
|
1934 jcfg = cfg.jailed(rootpath=(u"tree1", u"tree2")) |
|
461
5de1a6f213a5
Tests for index-based list-style access for jails that are lists and not dicts
Franz Glasner <fzglas.hg@dom66.de>
parents:
460
diff
changeset
|
1935 self.assertTrue(jcfg) |
|
467
9fcdc42a0457
len-support for jailed configurations: implement a proper __len__() method
Franz Glasner <fzglas.hg@dom66.de>
parents:
461
diff
changeset
|
1936 self.assertEqual(6, len(jcfg)) |
|
461
5de1a6f213a5
Tests for index-based list-style access for jails that are lists and not dicts
Franz Glasner <fzglas.hg@dom66.de>
parents:
460
diff
changeset
|
1937 |
|
5de1a6f213a5
Tests for index-based list-style access for jails that are lists and not dicts
Franz Glasner <fzglas.hg@dom66.de>
parents:
460
diff
changeset
|
1938 def test_list_by_index(self): |
|
5de1a6f213a5
Tests for index-based list-style access for jails that are lists and not dicts
Franz Glasner <fzglas.hg@dom66.de>
parents:
460
diff
changeset
|
1939 cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py")) |
|
5de1a6f213a5
Tests for index-based list-style access for jails that are lists and not dicts
Franz Glasner <fzglas.hg@dom66.de>
parents:
460
diff
changeset
|
1940 jcfg = cfg.jailed(rootpath=(u"tree1", u"tree2", u"key8")) |
|
5de1a6f213a5
Tests for index-based list-style access for jails that are lists and not dicts
Franz Glasner <fzglas.hg@dom66.de>
parents:
460
diff
changeset
|
1941 self.assertEqual(u"val1", jcfg[0]) |
|
5de1a6f213a5
Tests for index-based list-style access for jails that are lists and not dicts
Franz Glasner <fzglas.hg@dom66.de>
parents:
460
diff
changeset
|
1942 self.assertEqual(u"val2", jcfg[1]) |
|
5de1a6f213a5
Tests for index-based list-style access for jails that are lists and not dicts
Franz Glasner <fzglas.hg@dom66.de>
parents:
460
diff
changeset
|
1943 self.assertEqual(u"in the root namespace", jcfg[2]) |
|
5de1a6f213a5
Tests for index-based list-style access for jails that are lists and not dicts
Franz Glasner <fzglas.hg@dom66.de>
parents:
460
diff
changeset
|
1944 |
|
651
fe1299825a9a
Tests for indexed accesses (jail and non-jail)
Franz Glasner <fzglas.hg@dom66.de>
parents:
647
diff
changeset
|
1945 def test_index_jail_access(self): |
|
fe1299825a9a
Tests for indexed accesses (jail and non-jail)
Franz Glasner <fzglas.hg@dom66.de>
parents:
647
diff
changeset
|
1946 cfg = configmix.load(os.path.join( |
|
fe1299825a9a
Tests for indexed accesses (jail and non-jail)
Franz Glasner <fzglas.hg@dom66.de>
parents:
647
diff
changeset
|
1947 TESTDATADIR, "index-access-for-jails.yml")) |
|
fe1299825a9a
Tests for indexed accesses (jail and non-jail)
Franz Glasner <fzglas.hg@dom66.de>
parents:
647
diff
changeset
|
1948 for idx in range(len(cfg.getvarl(u"the-list"))): |
|
fe1299825a9a
Tests for indexed accesses (jail and non-jail)
Franz Glasner <fzglas.hg@dom66.de>
parents:
647
diff
changeset
|
1949 jcfg = cfg.jailed(rootpath=(u"the-list", idx)) |
|
fe1299825a9a
Tests for indexed accesses (jail and non-jail)
Franz Glasner <fzglas.hg@dom66.de>
parents:
647
diff
changeset
|
1950 self.assertEqual(1, len(jcfg)) |
|
fe1299825a9a
Tests for indexed accesses (jail and non-jail)
Franz Glasner <fzglas.hg@dom66.de>
parents:
647
diff
changeset
|
1951 self.assertEqual(idx, jcfg.getvarl_s(u"entry")) |
|
656
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
1952 self.assertEqual((u"the-list", idx), jcfg._path) |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
1953 self.assertEqual(u"the-list.~%d~." % (idx, ), jcfg._pathstr) |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
1954 |
|
665
9f0842a942b2
Tests for index sub-jail accesses
Franz Glasner <fzglas.hg@dom66.de>
parents:
659
diff
changeset
|
1955 def test_index_subjail_access(self): |
|
9f0842a942b2
Tests for index sub-jail accesses
Franz Glasner <fzglas.hg@dom66.de>
parents:
659
diff
changeset
|
1956 cfg = configmix.load(os.path.join( |
|
9f0842a942b2
Tests for index sub-jail accesses
Franz Glasner <fzglas.hg@dom66.de>
parents:
659
diff
changeset
|
1957 TESTDATADIR, "index-access-for-jails.yml")) |
|
9f0842a942b2
Tests for index sub-jail accesses
Franz Glasner <fzglas.hg@dom66.de>
parents:
659
diff
changeset
|
1958 jcfg = cfg.jailed(rootpath=(u"the-list",)) |
|
9f0842a942b2
Tests for index sub-jail accesses
Franz Glasner <fzglas.hg@dom66.de>
parents:
659
diff
changeset
|
1959 for idx in range(len(jcfg)): |
|
9f0842a942b2
Tests for index sub-jail accesses
Franz Glasner <fzglas.hg@dom66.de>
parents:
659
diff
changeset
|
1960 jcfg2 = jcfg.jailed(rootpath=(idx,)) |
|
9f0842a942b2
Tests for index sub-jail accesses
Franz Glasner <fzglas.hg@dom66.de>
parents:
659
diff
changeset
|
1961 self.assertEqual(1, len(jcfg2)) |
|
9f0842a942b2
Tests for index sub-jail accesses
Franz Glasner <fzglas.hg@dom66.de>
parents:
659
diff
changeset
|
1962 self.assertEqual(idx, jcfg2.getvarl_s(u"entry")) |
|
9f0842a942b2
Tests for index sub-jail accesses
Franz Glasner <fzglas.hg@dom66.de>
parents:
659
diff
changeset
|
1963 self.assertEqual((u"the-list", idx), jcfg2._path) |
|
9f0842a942b2
Tests for index sub-jail accesses
Franz Glasner <fzglas.hg@dom66.de>
parents:
659
diff
changeset
|
1964 self.assertEqual(u"the-list.~%d~." % (idx, ), jcfg2._pathstr) |
|
9f0842a942b2
Tests for index sub-jail accesses
Franz Glasner <fzglas.hg@dom66.de>
parents:
659
diff
changeset
|
1965 |
|
666
0eff8441c4b9
Implement iteration support that yields properly jailed configurations for each container item
Franz Glasner <fzglas.hg@dom66.de>
parents:
665
diff
changeset
|
1966 def test_direct_iter_jailed(self): |
|
0eff8441c4b9
Implement iteration support that yields properly jailed configurations for each container item
Franz Glasner <fzglas.hg@dom66.de>
parents:
665
diff
changeset
|
1967 cfg = configmix.load(os.path.join( |
|
0eff8441c4b9
Implement iteration support that yields properly jailed configurations for each container item
Franz Glasner <fzglas.hg@dom66.de>
parents:
665
diff
changeset
|
1968 TESTDATADIR, "index-access-for-jails.yml")) |
|
0eff8441c4b9
Implement iteration support that yields properly jailed configurations for each container item
Franz Glasner <fzglas.hg@dom66.de>
parents:
665
diff
changeset
|
1969 testidx = -1 |
|
0eff8441c4b9
Implement iteration support that yields properly jailed configurations for each container item
Franz Glasner <fzglas.hg@dom66.de>
parents:
665
diff
changeset
|
1970 for jcfg2 in cfg.iter_jailed(rootpath=(u"the-list", )): |
|
0eff8441c4b9
Implement iteration support that yields properly jailed configurations for each container item
Franz Glasner <fzglas.hg@dom66.de>
parents:
665
diff
changeset
|
1971 testidx += 1 |
|
0eff8441c4b9
Implement iteration support that yields properly jailed configurations for each container item
Franz Glasner <fzglas.hg@dom66.de>
parents:
665
diff
changeset
|
1972 self.assertEqual(1, len(jcfg2)) |
|
0eff8441c4b9
Implement iteration support that yields properly jailed configurations for each container item
Franz Glasner <fzglas.hg@dom66.de>
parents:
665
diff
changeset
|
1973 self.assertEqual(testidx, jcfg2.getvarl_s(u"entry")) |
|
0eff8441c4b9
Implement iteration support that yields properly jailed configurations for each container item
Franz Glasner <fzglas.hg@dom66.de>
parents:
665
diff
changeset
|
1974 self.assertEqual((u"the-list", testidx), jcfg2._path) |
|
0eff8441c4b9
Implement iteration support that yields properly jailed configurations for each container item
Franz Glasner <fzglas.hg@dom66.de>
parents:
665
diff
changeset
|
1975 self.assertEqual(u"the-list.~%d~." % (testidx, ), jcfg2._pathstr) |
|
0eff8441c4b9
Implement iteration support that yields properly jailed configurations for each container item
Franz Glasner <fzglas.hg@dom66.de>
parents:
665
diff
changeset
|
1976 |
|
0eff8441c4b9
Implement iteration support that yields properly jailed configurations for each container item
Franz Glasner <fzglas.hg@dom66.de>
parents:
665
diff
changeset
|
1977 def test_iter_jailed(self): |
|
0eff8441c4b9
Implement iteration support that yields properly jailed configurations for each container item
Franz Glasner <fzglas.hg@dom66.de>
parents:
665
diff
changeset
|
1978 cfg = configmix.load(os.path.join( |
|
0eff8441c4b9
Implement iteration support that yields properly jailed configurations for each container item
Franz Glasner <fzglas.hg@dom66.de>
parents:
665
diff
changeset
|
1979 TESTDATADIR, "index-access-for-jails.yml")) |
|
0eff8441c4b9
Implement iteration support that yields properly jailed configurations for each container item
Franz Glasner <fzglas.hg@dom66.de>
parents:
665
diff
changeset
|
1980 jcfg = cfg.jailed(rootpath=(u"the-list",)) |
|
0eff8441c4b9
Implement iteration support that yields properly jailed configurations for each container item
Franz Glasner <fzglas.hg@dom66.de>
parents:
665
diff
changeset
|
1981 testidx = -1 |
|
0eff8441c4b9
Implement iteration support that yields properly jailed configurations for each container item
Franz Glasner <fzglas.hg@dom66.de>
parents:
665
diff
changeset
|
1982 for jcfg2 in jcfg.iter_jailed(): |
|
0eff8441c4b9
Implement iteration support that yields properly jailed configurations for each container item
Franz Glasner <fzglas.hg@dom66.de>
parents:
665
diff
changeset
|
1983 testidx += 1 |
|
0eff8441c4b9
Implement iteration support that yields properly jailed configurations for each container item
Franz Glasner <fzglas.hg@dom66.de>
parents:
665
diff
changeset
|
1984 self.assertEqual(1, len(jcfg2)) |
|
0eff8441c4b9
Implement iteration support that yields properly jailed configurations for each container item
Franz Glasner <fzglas.hg@dom66.de>
parents:
665
diff
changeset
|
1985 self.assertEqual(testidx, jcfg2.getvarl_s(u"entry")) |
|
0eff8441c4b9
Implement iteration support that yields properly jailed configurations for each container item
Franz Glasner <fzglas.hg@dom66.de>
parents:
665
diff
changeset
|
1986 self.assertEqual((u"the-list", testidx), jcfg2._path) |
|
0eff8441c4b9
Implement iteration support that yields properly jailed configurations for each container item
Franz Glasner <fzglas.hg@dom66.de>
parents:
665
diff
changeset
|
1987 self.assertEqual(u"the-list.~%d~." % (testidx, ), jcfg2._pathstr) |
|
0eff8441c4b9
Implement iteration support that yields properly jailed configurations for each container item
Franz Glasner <fzglas.hg@dom66.de>
parents:
665
diff
changeset
|
1988 |
|
657
213f0ec3bbbc
Test list access with negative indexes
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
656
diff
changeset
|
1989 def test_negative_index_jail_access(self): |
|
213f0ec3bbbc
Test list access with negative indexes
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
656
diff
changeset
|
1990 cfg = configmix.load(os.path.join( |
|
213f0ec3bbbc
Test list access with negative indexes
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
656
diff
changeset
|
1991 TESTDATADIR, "index-access-for-jails.yml")) |
|
213f0ec3bbbc
Test list access with negative indexes
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
656
diff
changeset
|
1992 jcfg = cfg.jailed(rootpath=(u"the-list", -1)) |
|
213f0ec3bbbc
Test list access with negative indexes
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
656
diff
changeset
|
1993 self.assertEqual(2, jcfg.getvarl_s("entry")) |
|
213f0ec3bbbc
Test list access with negative indexes
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
656
diff
changeset
|
1994 self.assertEqual((u"the-list", -1), jcfg._path) |
|
213f0ec3bbbc
Test list access with negative indexes
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
656
diff
changeset
|
1995 self.assertEqual(u"the-list.~-1~.", jcfg._pathstr) |
|
213f0ec3bbbc
Test list access with negative indexes
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
656
diff
changeset
|
1996 |
|
656
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
1997 def test_index_jail_access_with_strpath(self): |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
1998 cfg = configmix.load(os.path.join( |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
1999 TESTDATADIR, "index-access-for-jails.yml")) |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2000 for idx in range(len(cfg.getvarl(u"the-list"))): |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2001 jcfg = cfg.jailed(root=u"the-list.~%d~" % (idx, )) |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2002 self.assertEqual(1, len(jcfg)) |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2003 self.assertEqual(idx, jcfg.getvarl_s(u"entry")) |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2004 self.assertEqual((u"the-list", idx), jcfg._path) |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2005 self.assertEqual(u"the-list.~%d~." % (idx, ), jcfg._pathstr) |
|
651
fe1299825a9a
Tests for indexed accesses (jail and non-jail)
Franz Glasner <fzglas.hg@dom66.de>
parents:
647
diff
changeset
|
2006 |
|
665
9f0842a942b2
Tests for index sub-jail accesses
Franz Glasner <fzglas.hg@dom66.de>
parents:
659
diff
changeset
|
2007 def test_index_subjail_access_with_strpath(self): |
|
9f0842a942b2
Tests for index sub-jail accesses
Franz Glasner <fzglas.hg@dom66.de>
parents:
659
diff
changeset
|
2008 cfg = configmix.load(os.path.join( |
|
9f0842a942b2
Tests for index sub-jail accesses
Franz Glasner <fzglas.hg@dom66.de>
parents:
659
diff
changeset
|
2009 TESTDATADIR, "index-access-for-jails.yml")) |
|
9f0842a942b2
Tests for index sub-jail accesses
Franz Glasner <fzglas.hg@dom66.de>
parents:
659
diff
changeset
|
2010 jcfg = cfg.jailed(root=u"the-list") |
|
9f0842a942b2
Tests for index sub-jail accesses
Franz Glasner <fzglas.hg@dom66.de>
parents:
659
diff
changeset
|
2011 for idx in range(len(jcfg)): |
|
9f0842a942b2
Tests for index sub-jail accesses
Franz Glasner <fzglas.hg@dom66.de>
parents:
659
diff
changeset
|
2012 jcfg2 = jcfg.jailed(root=u"~%d~" % (idx, )) |
|
9f0842a942b2
Tests for index sub-jail accesses
Franz Glasner <fzglas.hg@dom66.de>
parents:
659
diff
changeset
|
2013 self.assertEqual(1, len(jcfg2)) |
|
9f0842a942b2
Tests for index sub-jail accesses
Franz Glasner <fzglas.hg@dom66.de>
parents:
659
diff
changeset
|
2014 self.assertEqual(idx, jcfg2.getvarl_s(u"entry")) |
|
9f0842a942b2
Tests for index sub-jail accesses
Franz Glasner <fzglas.hg@dom66.de>
parents:
659
diff
changeset
|
2015 self.assertEqual((u"the-list", idx), jcfg2._path) |
|
9f0842a942b2
Tests for index sub-jail accesses
Franz Glasner <fzglas.hg@dom66.de>
parents:
659
diff
changeset
|
2016 self.assertEqual(u"the-list.~%d~." % (idx, ), jcfg2._pathstr) |
|
9f0842a942b2
Tests for index sub-jail accesses
Franz Glasner <fzglas.hg@dom66.de>
parents:
659
diff
changeset
|
2017 |
|
680
e71f8bd50342
Tests for the new feature that resolves references at jail roots
Franz Glasner <fzglas.hg@dom66.de>
parents:
666
diff
changeset
|
2018 def test_referenced_root(self): |
|
e71f8bd50342
Tests for the new feature that resolves references at jail roots
Franz Glasner <fzglas.hg@dom66.de>
parents:
666
diff
changeset
|
2019 cfg = configmix.load(os.path.join( |
|
e71f8bd50342
Tests for the new feature that resolves references at jail roots
Franz Glasner <fzglas.hg@dom66.de>
parents:
666
diff
changeset
|
2020 TESTDATADIR, "jail-root-ref.yml")) |
|
e71f8bd50342
Tests for the new feature that resolves references at jail roots
Franz Glasner <fzglas.hg@dom66.de>
parents:
666
diff
changeset
|
2021 jcfg = cfg.jailed(rootpath=("the-root", "ref1")) |
|
e71f8bd50342
Tests for the new feature that resolves references at jail roots
Franz Glasner <fzglas.hg@dom66.de>
parents:
666
diff
changeset
|
2022 print(repr(jcfg.getvarl_s())) |
|
e71f8bd50342
Tests for the new feature that resolves references at jail roots
Franz Glasner <fzglas.hg@dom66.de>
parents:
666
diff
changeset
|
2023 self.assertEqual("v3", jcfg.getvarl_s("ks")) |
|
e71f8bd50342
Tests for the new feature that resolves references at jail roots
Franz Glasner <fzglas.hg@dom66.de>
parents:
666
diff
changeset
|
2024 |
|
e71f8bd50342
Tests for the new feature that resolves references at jail roots
Franz Glasner <fzglas.hg@dom66.de>
parents:
666
diff
changeset
|
2025 |
|
e71f8bd50342
Tests for the new feature that resolves references at jail roots
Franz Glasner <fzglas.hg@dom66.de>
parents:
666
diff
changeset
|
2026 def test_referenced_root(self): |
|
e71f8bd50342
Tests for the new feature that resolves references at jail roots
Franz Glasner <fzglas.hg@dom66.de>
parents:
666
diff
changeset
|
2027 cfg = configmix.load(os.path.join( |
|
e71f8bd50342
Tests for the new feature that resolves references at jail roots
Franz Glasner <fzglas.hg@dom66.de>
parents:
666
diff
changeset
|
2028 TESTDATADIR, "jail-root-ref.yml")) |
|
e71f8bd50342
Tests for the new feature that resolves references at jail roots
Franz Glasner <fzglas.hg@dom66.de>
parents:
666
diff
changeset
|
2029 jcfg = cfg.jailed(rootpath=("the-root", "ref1")) |
|
e71f8bd50342
Tests for the new feature that resolves references at jail roots
Franz Glasner <fzglas.hg@dom66.de>
parents:
666
diff
changeset
|
2030 print(repr(jcfg.getvarl_s())) |
|
e71f8bd50342
Tests for the new feature that resolves references at jail roots
Franz Glasner <fzglas.hg@dom66.de>
parents:
666
diff
changeset
|
2031 self.assertEqual("v3", jcfg.getvarl_s("ks")) |
|
e71f8bd50342
Tests for the new feature that resolves references at jail roots
Franz Glasner <fzglas.hg@dom66.de>
parents:
666
diff
changeset
|
2032 self.assertEqual("v1", jcfg.getvarl_s("k1")) |
|
e71f8bd50342
Tests for the new feature that resolves references at jail roots
Franz Glasner <fzglas.hg@dom66.de>
parents:
666
diff
changeset
|
2033 |
|
e71f8bd50342
Tests for the new feature that resolves references at jail roots
Franz Glasner <fzglas.hg@dom66.de>
parents:
666
diff
changeset
|
2034 def test_referenced_root_in_subjail(self): |
|
e71f8bd50342
Tests for the new feature that resolves references at jail roots
Franz Glasner <fzglas.hg@dom66.de>
parents:
666
diff
changeset
|
2035 cfg = configmix.load(os.path.join( |
|
e71f8bd50342
Tests for the new feature that resolves references at jail roots
Franz Glasner <fzglas.hg@dom66.de>
parents:
666
diff
changeset
|
2036 TESTDATADIR, "jail-root-ref.yml")) |
|
e71f8bd50342
Tests for the new feature that resolves references at jail roots
Franz Glasner <fzglas.hg@dom66.de>
parents:
666
diff
changeset
|
2037 jcfg = cfg.jailed(rootpath=("the-root", "ref2")) |
|
e71f8bd50342
Tests for the new feature that resolves references at jail roots
Franz Glasner <fzglas.hg@dom66.de>
parents:
666
diff
changeset
|
2038 jcfg2 = jcfg.jailed(rootpath=("sub-tree1",)) |
|
e71f8bd50342
Tests for the new feature that resolves references at jail roots
Franz Glasner <fzglas.hg@dom66.de>
parents:
666
diff
changeset
|
2039 self.assertEqual("v6", jcfg2.getvarl_s("k6")) |
|
e71f8bd50342
Tests for the new feature that resolves references at jail roots
Franz Glasner <fzglas.hg@dom66.de>
parents:
666
diff
changeset
|
2040 self.assertEqual("v3", jcfg2.getvarl_s("ks")) |
|
e71f8bd50342
Tests for the new feature that resolves references at jail roots
Franz Glasner <fzglas.hg@dom66.de>
parents:
666
diff
changeset
|
2041 |
|
692
db764da37cd2
Add a test with a "real-world" config structure with regard to references and jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
680
diff
changeset
|
2042 def test_jails_and_refs_tree(self): |
|
db764da37cd2
Add a test with a "real-world" config structure with regard to references and jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
680
diff
changeset
|
2043 cfg = configmix.load(os.path.join( |
|
db764da37cd2
Add a test with a "real-world" config structure with regard to references and jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
680
diff
changeset
|
2044 TESTDATADIR, "jail-root-ref.yml")) |
|
db764da37cd2
Add a test with a "real-world" config structure with regard to references and jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
680
diff
changeset
|
2045 for flavour in ("access", "job"): |
|
db764da37cd2
Add a test with a "real-world" config structure with regard to references and jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
680
diff
changeset
|
2046 tokcfg = cfg.jailed(rootpath=("realworld", "token", flavour)) |
|
db764da37cd2
Add a test with a "real-world" config structure with regard to references and jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
680
diff
changeset
|
2047 self.assertEqual(-2, tokcfg.getintvar_s("nbf")) |
|
db764da37cd2
Add a test with a "real-world" config structure with regard to references and jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
680
diff
changeset
|
2048 for idx, keysetcfg in enumerate( |
|
db764da37cd2
Add a test with a "real-world" config structure with regard to references and jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
680
diff
changeset
|
2049 tokcfg.jailed(rootpath=("sign",)).iter_jailed()): |
|
db764da37cd2
Add a test with a "real-world" config structure with regard to references and jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
680
diff
changeset
|
2050 self.assertEqual("key-%d" % (idx+1,), |
|
db764da37cd2
Add a test with a "real-world" config structure with regard to references and jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
680
diff
changeset
|
2051 keysetcfg.getvarl_s("name")) |
|
db764da37cd2
Add a test with a "real-world" config structure with regard to references and jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
680
diff
changeset
|
2052 self.assertEqual("something%d" % (idx+1,), |
|
db764da37cd2
Add a test with a "real-world" config structure with regard to references and jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
680
diff
changeset
|
2053 keysetcfg.getvarl_s("type")) |
|
db764da37cd2
Add a test with a "real-world" config structure with regard to references and jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
680
diff
changeset
|
2054 self.assertIsNone(keysetcfg.getvarl_s("data")) |
|
db764da37cd2
Add a test with a "real-world" config structure with regard to references and jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
680
diff
changeset
|
2055 |
|
395
0b3ffc34fa5c
Begin a jailed configuration with access to a sub-tree of the original configuration
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
390
diff
changeset
|
2056 |
|
542
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2057 class _TParserMixin: |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2058 def test_quote_and_unquote_empty(self): |
|
550
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2059 e = self.quote(u"") |
|
542
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2060 self.assertEqual(u"", e) |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2061 self.assertEqual(u"", self.unquote(e)) |
|
543
491413368c7c
Added also a fast C-implementation of configmix.config._split_ns
Franz Glasner <fzglas.hg@dom66.de>
parents:
542
diff
changeset
|
2062 |
|
542
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2063 def test_quoting_and_unquoting_are_inverse(self): |
|
656
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2064 for c in u"""%.:#|"'{}[]~""": |
|
550
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2065 qc = self.quote(c) |
|
542
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2066 self.assertTrue(qc.startswith(u"%x") and len(qc) == 4) |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2067 self.assertEqual(c, self.unquote(qc)) |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2068 |
|
550
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2069 def test_quoting_and_unquoting_are_inverse_all(self): |
|
656
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2070 c = u"""%.:#|"'{}[]~""" |
|
550
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2071 qc = self.quote(c) |
|
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2072 self.assertEqual(len(c)*4, len(qc)) |
|
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2073 self.assertEqual(c, self.unquote(qc)) |
|
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2074 |
|
542
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2075 def test_quoting_and_unquoting_are_identical(self): |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2076 # other characters |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2077 for c in configmix.config._QUOTE_SAFE: |
|
550
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2078 qc = self.quote(c) |
|
542
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2079 self.assertEqual(c, qc) |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2080 self.assertEqual(c, self.unquote(qc)) |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2081 |
|
550
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2082 def test_quoting_and_unquoting_are_identical_all(self): |
|
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2083 # other characters |
|
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2084 qc = self.quote(configmix.config._QUOTE_SAFE) |
|
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2085 self.assertEqual(configmix.config._QUOTE_SAFE, qc) |
|
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2086 self.assertEqual(configmix.config._QUOTE_SAFE, self.unquote(qc)) |
|
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2087 |
|
656
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2088 def test_quote_index_to_tilde(self): |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2089 self.assertEqual(u"~4~", self.quote(4)) |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2090 |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2091 def test_unquote_index_with_tilde(self): |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2092 self.assertEqual(4, self.unquote(u"~4~")) |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2093 |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2094 def test_unquote_empty_tilde(self): |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2095 self.assertEqual(u"~~", self.unquote(u"~~")) |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2096 |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2097 def test_unquote_invalid_number_tilde(self): |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2098 self.assertEqual(u"~0x4~", self.unquote(u"~0x4~")) |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2099 |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2100 def test_unquote_invalid_number_tilde_2(self): |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2101 self.assertEqual(u"~\U00019001~", self.unquote(u"~%U00019001~")) |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2102 |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2103 def test_quote_unquote_indexes(self): |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2104 for idx in range(0, 10000): |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2105 self.assertEqual(idx, self.unquote(self.quote(idx))) |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2106 |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2107 def test_quote_unquote_negative_index(self): |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2108 for idx in (-1, -2, -3): |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2109 self.assertEqual(idx, self.unquote(self.quote(idx))) |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2110 |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2111 def test_index_overflow_border(self): |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2112 self.assertEqual(32759, self.unquote(u"~32759~")) |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2113 self.assertEqual(u"~32760~", self.unquote(u"~32760~")) |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2114 |
|
542
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2115 def test_unquote_unimax(self): |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2116 self.assertEqual(u"\U00019001", self.unquote(u"%U00019001")) |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2117 self.assertEqual(u"X\U00019AF1Z", self.unquote(u"X%U00019aF1Z")) |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2118 |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2119 def test_unquote_base_plane(self): |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2120 self.assertEqual(u"\uFFFF", self.unquote(u"%uffff")) |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2121 self.assertEqual(u"X\uFFFFZ", self.unquote(u"X%uffffZ")) |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2122 |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2123 def test_unquote_latin(self): |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2124 self.assertEqual(u"\xFF", self.unquote(u"%xff")) |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2125 self.assertEqual(u"X\xFFZ", self.unquote(u"X%xffZ")) |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2126 |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2127 def test_unquote_zero(self): |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2128 self.assertEqual(u"\x00", self.unquote(u"%x00")) |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2129 self.assertEqual(u"X\x00Z", self.unquote(u"X%x00Z")) |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2130 |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2131 def test_unquote_adjacent_x(self): |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2132 self.assertEqual(u"\x00\x01\xA0\xB0\xFF", |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2133 self.unquote(u"%x00%x01%xA0%xB0%xFF")) |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2134 |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2135 def test_unquote_adjacent_u(self): |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2136 self.assertEqual(u"\u0000\u0001\u00A0\uABCD\uFEFE", |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2137 self.unquote(u"%u0000%u0001%u00A0%uabCD%ufeFE")) |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2138 |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2139 def test_unquote_adjacent_U(self): |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2140 self.assertEqual( |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2141 u"\U00000000\U00000001\U000000A0\U0001ABCD\U0001FEFE", |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2142 self.unquote(u"%U00000000%U00000001%U000000A0%U0001abCD%U0001feFE")) |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2143 |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2144 def test_invalid_hex_digits(self): |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2145 self.assertRaises( |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2146 ValueError, |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2147 self.unquote, |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2148 u"%xgG") |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2149 self.assertRaises( |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2150 ValueError, |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2151 self.unquote, |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2152 u"%ugGGG") |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2153 self.assertRaises( |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2154 ValueError, |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2155 self.unquote, |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2156 u"%UgGGGgGGG") |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2157 |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2158 def test_invalid_too_short(self): |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2159 self.assertRaises( |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2160 ValueError, |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2161 self.unquote, |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2162 u"%x0") |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2163 self.assertRaises( |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2164 ValueError, |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2165 self.unquote, |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2166 u"%u000") |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2167 self.assertRaises( |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2168 ValueError, |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2169 self.unquote, |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2170 u"%U0000000") |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2171 |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2172 def test_invalid_too_short_no_sigil(self): |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2173 self.assertRaises( |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2174 ValueError, |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2175 self.unquote, |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2176 u"%") |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2177 |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2178 def test_empty_pathstr(self): |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2179 # an empty path string returns an empty path tuple |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2180 self.assertEqual(tuple(), self.pathstr2path(u"")) |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2181 |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2182 def test_split(self): |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2183 p = self.pathstr2path(u"abc.def.hik.jkl") |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2184 self.assertEqual((u"abc", u"def", u"hik", u"jkl"), p) |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2185 |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2186 def test_split_all_empty_parts(self): |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2187 p = self.pathstr2path(u"....") |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2188 self.assertEqual((u"", u"", u"", u"", u""), p) |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2189 |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2190 def test_split_all_empty_tail(self): |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2191 p = self.pathstr2path(u"1.2.") |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2192 self.assertEqual((u"1", u"2", u""), p) |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2193 |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2194 def test_split_unquote(self): |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2195 p = self.pathstr2path(u"a%x2Eb.c%u002Ed.e%U0000002Ef") |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2196 self.assertEqual((u"a.b", u"c.d", u"e.f"), p) |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2197 |
|
656
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2198 def test_split_unquote_with_index(self): |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2199 p = self.pathstr2path(u"a%x2Eb.~555~.c%u002Ed.e%U0000002Ef.~6~") |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2200 self.assertEqual((u"a.b", 555, u"c.d", u"e.f", 6), p) |
|
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2201 |
|
543
491413368c7c
Added also a fast C-implementation of configmix.config._split_ns
Franz Glasner <fzglas.hg@dom66.de>
parents:
542
diff
changeset
|
2202 def test_split_ns_empty(self): |
|
491413368c7c
Added also a fast C-implementation of configmix.config._split_ns
Franz Glasner <fzglas.hg@dom66.de>
parents:
542
diff
changeset
|
2203 self.assertEqual((None, u""), self.split_ns(u"")) |
|
491413368c7c
Added also a fast C-implementation of configmix.config._split_ns
Franz Glasner <fzglas.hg@dom66.de>
parents:
542
diff
changeset
|
2204 |
|
491413368c7c
Added also a fast C-implementation of configmix.config._split_ns
Franz Glasner <fzglas.hg@dom66.de>
parents:
542
diff
changeset
|
2205 def test_split_ns_empty_parts(self): |
|
491413368c7c
Added also a fast C-implementation of configmix.config._split_ns
Franz Glasner <fzglas.hg@dom66.de>
parents:
542
diff
changeset
|
2206 self.assertEqual((u"", u""), self.split_ns(u":")) |
|
491413368c7c
Added also a fast C-implementation of configmix.config._split_ns
Franz Glasner <fzglas.hg@dom66.de>
parents:
542
diff
changeset
|
2207 |
|
491413368c7c
Added also a fast C-implementation of configmix.config._split_ns
Franz Glasner <fzglas.hg@dom66.de>
parents:
542
diff
changeset
|
2208 def test_split_ns_no_ns(self): |
|
491413368c7c
Added also a fast C-implementation of configmix.config._split_ns
Franz Glasner <fzglas.hg@dom66.de>
parents:
542
diff
changeset
|
2209 self.assertEqual((None, u"the-varname"), self.split_ns(u"the-varname")) |
|
491413368c7c
Added also a fast C-implementation of configmix.config._split_ns
Franz Glasner <fzglas.hg@dom66.de>
parents:
542
diff
changeset
|
2210 |
|
491413368c7c
Added also a fast C-implementation of configmix.config._split_ns
Franz Glasner <fzglas.hg@dom66.de>
parents:
542
diff
changeset
|
2211 def test_split_ns_non_quoted(self): |
|
491413368c7c
Added also a fast C-implementation of configmix.config._split_ns
Franz Glasner <fzglas.hg@dom66.de>
parents:
542
diff
changeset
|
2212 self.assertEqual( |
|
491413368c7c
Added also a fast C-implementation of configmix.config._split_ns
Franz Glasner <fzglas.hg@dom66.de>
parents:
542
diff
changeset
|
2213 (u"the-ns", "the-rest:with:colons|filter1|filter2"), |
|
491413368c7c
Added also a fast C-implementation of configmix.config._split_ns
Franz Glasner <fzglas.hg@dom66.de>
parents:
542
diff
changeset
|
2214 self.split_ns(u"the-ns:the-rest:with:colons|filter1|filter2")) |
|
491413368c7c
Added also a fast C-implementation of configmix.config._split_ns
Franz Glasner <fzglas.hg@dom66.de>
parents:
542
diff
changeset
|
2215 |
|
491413368c7c
Added also a fast C-implementation of configmix.config._split_ns
Franz Glasner <fzglas.hg@dom66.de>
parents:
542
diff
changeset
|
2216 def test_split_ns_quoting(self): |
|
491413368c7c
Added also a fast C-implementation of configmix.config._split_ns
Franz Glasner <fzglas.hg@dom66.de>
parents:
542
diff
changeset
|
2217 self.assertEqual((u":", u"%x3a"), self.split_ns(u"%x3a:%x3a")) |
|
491413368c7c
Added also a fast C-implementation of configmix.config._split_ns
Franz Glasner <fzglas.hg@dom66.de>
parents:
542
diff
changeset
|
2218 |
|
552
39e5d07d8dbc
Provide a C implementation of configmix.config._split_filters.
Franz Glasner <fzglas.hg@dom66.de>
parents:
550
diff
changeset
|
2219 def test_split_filters_empty(self): |
|
705
0485a033c95d
FIX: Parsing a filter chain for the new filter-only expansions: parse them backwards and use "," as filter-chain separator here.
Franz Glasner <fzglas.hg@dom66.de>
parents:
703
diff
changeset
|
2220 self.assertEqual((u"", []), self.split_filters(u"", 1)) |
|
552
39e5d07d8dbc
Provide a C implementation of configmix.config._split_filters.
Franz Glasner <fzglas.hg@dom66.de>
parents:
550
diff
changeset
|
2221 |
|
553
9d2bd411f5c5
Do not rstrip() the remaining variable name when parsing out filters from variable names
Franz Glasner <fzglas.hg@dom66.de>
parents:
552
diff
changeset
|
2222 def test_split_filters_varname_only_no_stripping(self): |
|
705
0485a033c95d
FIX: Parsing a filter chain for the new filter-only expansions: parse them backwards and use "," as filter-chain separator here.
Franz Glasner <fzglas.hg@dom66.de>
parents:
703
diff
changeset
|
2223 self.assertEqual((u" varname ", []), |
|
0485a033c95d
FIX: Parsing a filter chain for the new filter-only expansions: parse them backwards and use "," as filter-chain separator here.
Franz Glasner <fzglas.hg@dom66.de>
parents:
703
diff
changeset
|
2224 self.split_filters(u" varname ", 1)) |
|
552
39e5d07d8dbc
Provide a C implementation of configmix.config._split_filters.
Franz Glasner <fzglas.hg@dom66.de>
parents:
550
diff
changeset
|
2225 |
|
553
9d2bd411f5c5
Do not rstrip() the remaining variable name when parsing out filters from variable names
Franz Glasner <fzglas.hg@dom66.de>
parents:
552
diff
changeset
|
2226 def test_split_filters_single_no_stripping(self): |
|
9d2bd411f5c5
Do not rstrip() the remaining variable name when parsing out filters from variable names
Franz Glasner <fzglas.hg@dom66.de>
parents:
552
diff
changeset
|
2227 self.assertEqual((u" the-varname ", []), |
|
705
0485a033c95d
FIX: Parsing a filter chain for the new filter-only expansions: parse them backwards and use "," as filter-chain separator here.
Franz Glasner <fzglas.hg@dom66.de>
parents:
703
diff
changeset
|
2228 self.split_filters(u" the-varname | ", 1)) |
|
552
39e5d07d8dbc
Provide a C implementation of configmix.config._split_filters.
Franz Glasner <fzglas.hg@dom66.de>
parents:
550
diff
changeset
|
2229 |
|
39e5d07d8dbc
Provide a C implementation of configmix.config._split_filters.
Franz Glasner <fzglas.hg@dom66.de>
parents:
550
diff
changeset
|
2230 def test_split_filters_one(self): |
|
39e5d07d8dbc
Provide a C implementation of configmix.config._split_filters.
Franz Glasner <fzglas.hg@dom66.de>
parents:
550
diff
changeset
|
2231 self.assertEqual((u"the-varname", [u"None"]), |
|
705
0485a033c95d
FIX: Parsing a filter chain for the new filter-only expansions: parse them backwards and use "," as filter-chain separator here.
Franz Glasner <fzglas.hg@dom66.de>
parents:
703
diff
changeset
|
2232 self.split_filters(u"the-varname|None", 1)) |
|
552
39e5d07d8dbc
Provide a C implementation of configmix.config._split_filters.
Franz Glasner <fzglas.hg@dom66.de>
parents:
550
diff
changeset
|
2233 |
|
39e5d07d8dbc
Provide a C implementation of configmix.config._split_filters.
Franz Glasner <fzglas.hg@dom66.de>
parents:
550
diff
changeset
|
2234 def test_split_filters_many(self): |
|
39e5d07d8dbc
Provide a C implementation of configmix.config._split_filters.
Franz Glasner <fzglas.hg@dom66.de>
parents:
550
diff
changeset
|
2235 self.assertEqual((u"the-varname", [u"Empty", u"None"]), |
|
705
0485a033c95d
FIX: Parsing a filter chain for the new filter-only expansions: parse them backwards and use "," as filter-chain separator here.
Franz Glasner <fzglas.hg@dom66.de>
parents:
703
diff
changeset
|
2236 self.split_filters(u"the-varname|Empty|None", 1)) |
|
554
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2237 |
|
708
e692216f8756
Allow also "," characters to act as a separator within a filter-chain.
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
705
diff
changeset
|
2238 def test_split_filters_many_alt(self): |
|
e692216f8756
Allow also "," characters to act as a separator within a filter-chain.
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
705
diff
changeset
|
2239 self.assertEqual((u"the-varname", [u"Empty", u"None"]), |
|
e692216f8756
Allow also "," characters to act as a separator within a filter-chain.
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
705
diff
changeset
|
2240 self.split_filters(u"the-varname|Empty,None", 1)) |
|
e692216f8756
Allow also "," characters to act as a separator within a filter-chain.
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
705
diff
changeset
|
2241 |
|
710
ff0de14493f1
Test that "," is preferred over "|"
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
708
diff
changeset
|
2242 def test_split_filters_many_alt_preferred(self): |
|
ff0de14493f1
Test that "," is preferred over "|"
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
708
diff
changeset
|
2243 # "," is preferred |
|
ff0de14493f1
Test that "," is preferred over "|"
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
708
diff
changeset
|
2244 self.assertEqual((u"the-varname", [u"Empty|", u"None"]), |
|
ff0de14493f1
Test that "," is preferred over "|"
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
708
diff
changeset
|
2245 self.split_filters(u"the-varname|Empty|,None", 1)) |
|
ff0de14493f1
Test that "," is preferred over "|"
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
708
diff
changeset
|
2246 |
|
554
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2247 def test_None_filter_single(self): |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2248 cfg = configmix.load() |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2249 x = getattr(cfg, self.interpolate_meth)(u"{{non-existing|None}}") |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2250 self.assertIsNone(x) |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2251 # caching should have no effect |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2252 y = getattr(cfg, self.interpolate_meth)(u"{{non-existing|None}}") |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2253 self.assertIsNone(y) |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2254 |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2255 def test_None_filter_embedded(self): |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2256 cfg = configmix.load() |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2257 x = getattr(cfg, self.interpolate_meth)(u"A{{non-existing|None}}Z") |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2258 self.assertEqual(u"AZ", x) |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2259 # caching should have no effect |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2260 y = getattr(cfg, self.interpolate_meth)(u"A{{non-existing|None}}Z") |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2261 self.assertEqual(u"AZ", y) |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2262 |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2263 def test_Empty_filtersingle(self): |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2264 cfg = configmix.load() |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2265 x = getattr(cfg, self.interpolate_meth)(u"{{non-existing|Empty}}") |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2266 self.assertEqual("", x) |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2267 # caching should have no effect |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2268 y = getattr(cfg, self.interpolate_meth)(u"{{non-existing|Empty}}") |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2269 self.assertEqual("", y) |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2270 |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2271 def test_None_filter_pass_through(self): |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2272 cfg = configmix.load(os.path.join(TESTDATADIR, "conf20.yml"), |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2273 os.path.join(TESTDATADIR, "conf21.yml"), |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2274 os.path.join(TESTDATADIR, "conf22.ini"), |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2275 os.path.join(TESTDATADIR, "conf23.json"), |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2276 os.path.join(TESTDATADIR, "conf24.toml")) |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2277 x = getattr(cfg, self.interpolate_meth)(u"{{intl.cache.items|None}}") |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2278 self.assertEqual(10, x) |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2279 # caching should have no effect |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2280 y = getattr(cfg, self.interpolate_meth)(u"{{intl.cache.items|None}}") |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2281 self.assertEqual(10, y) |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2282 |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2283 def test_Empty_filter_pass_through(self): |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2284 cfg = configmix.load(os.path.join(TESTDATADIR, "conf20.yml"), |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2285 os.path.join(TESTDATADIR, "conf21.yml"), |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2286 os.path.join(TESTDATADIR, "conf22.ini"), |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2287 os.path.join(TESTDATADIR, "conf23.json"), |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2288 os.path.join(TESTDATADIR, "conf24.toml")) |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2289 x = getattr(cfg, self.interpolate_meth)(u"{{intl.cache.items|Empty}}") |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2290 self.assertEqual(10, x) |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2291 # caching should have no effect |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2292 y = getattr(cfg, self.interpolate_meth)(u"{{intl.cache.items|Empty}}") |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2293 self.assertEqual(10, y) |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2294 |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2295 def test_Empty_filter_no_pass_through_2(self): |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2296 cfg = configmix.load(os.path.join(TESTDATADIR, "conf20.yml"), |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2297 os.path.join(TESTDATADIR, "conf21.yml"), |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2298 os.path.join(TESTDATADIR, "conf22.ini"), |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2299 os.path.join(TESTDATADIR, "conf23.json"), |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2300 os.path.join(TESTDATADIR, "conf24.toml")) |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2301 x = getattr(cfg, self.interpolate_meth)(u"{{intl.cache.items|Empty}}{{intl.cache.items}}") |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2302 self.assertEqual(u"1010", x) |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2303 # caching should have no effect |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2304 y = getattr(cfg, self.interpolate_meth)(u"{{intl.cache.items|Empty}}{{intl.cache.items}}") |
|
642
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2305 self.assertEqual(u"1010", y) |
|
554
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2306 |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2307 def test_interpolate_wrong_syntax(self): |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2308 cfg = configmix.load() |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2309 x1 = getattr(cfg, self.interpolate_meth)(u"{{the-variable}") |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2310 self.assertEqual(u"{{the-variable}", x1) |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2311 x2 = getattr(cfg, self.interpolate_meth)(u"A{{the-variable}Z") |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2312 self.assertEqual(u"A{{the-variable}Z", x2) |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2313 x3 = getattr(cfg, self.interpolate_meth)(u"A{{1{{2{{3}Z") |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2314 self.assertEqual(u"A{{1{{2{{3}Z", x3) |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2315 # caching should have no effect |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2316 y1 = getattr(cfg, self.interpolate_meth)(u"{{the-variable}") |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2317 self.assertEqual(u"{{the-variable}", y1) |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2318 y2 = getattr(cfg, self.interpolate_meth)(u"A{{the-variable}Z") |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2319 self.assertEqual(u"A{{the-variable}Z", y2) |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2320 y3 = getattr(cfg, self.interpolate_meth)(u"A{{1{{2{{3}Z") |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2321 self.assertEqual(u"A{{1{{2{{3}Z", y3) |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2322 |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2323 def test_interpolate_empty_str(self): |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2324 cfg = configmix.load() |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2325 x = getattr(cfg, self.interpolate_meth)(u"") |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2326 self.assertEqual(u"", x) |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2327 # caching should have no effect |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2328 y = getattr(cfg, self.interpolate_meth)(u"") |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2329 self.assertEqual(u"", y) |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2330 |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2331 def test_interpolate_no_interpolation(self): |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2332 cfg = configmix.load() |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2333 x = getattr(cfg, self.interpolate_meth)(u"no-interpolation-here") |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2334 self.assertEqual(u"no-interpolation-here", x) |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2335 # caching should have no effect |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2336 y = getattr(cfg, self.interpolate_meth)(u"no-interpolation-here") |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2337 self.assertEqual(u"no-interpolation-here", y) |
|
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2338 |
|
642
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2339 def test_single_load_removes_DEL_VALUE(self): |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2340 cfg = configmix.load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2341 self.assertRaises( |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2342 KeyError, |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2343 cfg.getvar, |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2344 u("not-deleted")) |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2345 |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2346 def test_single_safeload_removes_DEL_VALUE(self): |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2347 cfg = configmix.safe_load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2348 self.assertRaises( |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2349 KeyError, |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2350 cfg.getvar, |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2351 u("not-deleted")) |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2352 |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2353 def test_never_expanding_lone_DEL_VALUE(self): |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2354 cfg = { |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2355 u("key1"): u("{{::DEL::}}"), |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2356 u("subkey2"): { |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2357 u("key3"): u("{{::DEL::}}") |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2358 } |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2359 } |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2360 cfg = configmix.config.Configuration(cfg) |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2361 print(repr(cfg)) |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2362 self.assertEqual(u("{{::DEL::}}"), cfg.getvar_s(u("key1"))) |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2363 self.assertEqual(u("{{::DEL::}}"), cfg.getvar_s(u("subkey2.key3"))) |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2364 |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2365 def test_merge_does_never_expand(self): |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2366 cfg1 = configmix.load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2367 self.assertEqual(u("{{appdir}}/locale"), cfg1.getvar(u("intl.localedir"))) |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2368 self.assertRaises( |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2369 KeyError, |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2370 cfg1.getvar_s, |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2371 u("intl.localedir")) |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2372 |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2373 cfg2 = { |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2374 u("process"): u("{{::DEL::}}"), |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2375 u("intl"): { |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2376 u("localedir"): u("{{appdir}}/other-locale"), |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2377 u("cache"): u("{{::DEL::}}") |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2378 } |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2379 } |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2380 cfg = configmix.merge(configmix.config.Configuration(cfg2), cfg1) |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2381 self.assertEqual( |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2382 u("{{appdir}}/other-locale"), |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2383 cfg.getvar(u("intl.localedir"))) |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2384 self.assertRaises( |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2385 KeyError, |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2386 cfg.getvar, |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2387 u("process")) |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2388 self.assertRaises( |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2389 KeyError, |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2390 cfg.getvar, |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2391 u("intl.cache")) |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2392 |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2393 def test_safemerge_does_never_expand(self): |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2394 cfg1 = configmix.safe_load(os.path.join(TESTDATADIR, "conf20.yml")) |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2395 self.assertEqual(u("{{appdir}}/locale"), cfg1.getvar(u("intl.localedir"))) |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2396 self.assertRaises( |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2397 KeyError, |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2398 cfg1.getvar_s, |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2399 u("intl.localedir")) |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2400 |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2401 cfg2 = { |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2402 u("process"): u("{{::DEL::}}"), |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2403 u("intl"): { |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2404 u("localedir"): u("{{appdir}}/other-locale"), |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2405 u("cache"): u("{{::DEL::}}") |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2406 } |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2407 } |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2408 cfg = configmix.safe_merge(configmix.config.Configuration(cfg2), cfg1) |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2409 self.assertEqual( |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2410 u("{{appdir}}/other-locale"), |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2411 cfg.getvar(u("intl.localedir"))) |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2412 self.assertRaises( |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2413 KeyError, |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2414 cfg.getvar, |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2415 u("process")) |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2416 self.assertRaises( |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2417 KeyError, |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2418 cfg.getvar, |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2419 u("intl.cache")) |
|
db3ff4fbb4ce
More unittests concerning merging and variable interpolation
Franz Glasner <fzglas.hg@dom66.de>
parents:
629
diff
changeset
|
2420 |
|
723
c17a4e30ebbf
Docs for nested filters
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
720
diff
changeset
|
2421 def test_nested_filter_wrong_syntax(self): |
|
703
193a616e0b3c
Begin implementation of filter-only expansions (recursive with respect to expansion)
Franz Glasner <fzglas.hg@dom66.de>
parents:
698
diff
changeset
|
2422 cfg = configmix.load() |
|
193a616e0b3c
Begin implementation of filter-only expansions (recursive with respect to expansion)
Franz Glasner <fzglas.hg@dom66.de>
parents:
698
diff
changeset
|
2423 try: |
|
193a616e0b3c
Begin implementation of filter-only expansions (recursive with respect to expansion)
Franz Glasner <fzglas.hg@dom66.de>
parents:
698
diff
changeset
|
2424 y = getattr(cfg, self.interpolate_meth)(u"{{|{{not-existing}}|None}}") |
|
193a616e0b3c
Begin implementation of filter-only expansions (recursive with respect to expansion)
Franz Glasner <fzglas.hg@dom66.de>
parents:
698
diff
changeset
|
2425 except ValueError: |
|
193a616e0b3c
Begin implementation of filter-only expansions (recursive with respect to expansion)
Franz Glasner <fzglas.hg@dom66.de>
parents:
698
diff
changeset
|
2426 pass |
|
193a616e0b3c
Begin implementation of filter-only expansions (recursive with respect to expansion)
Franz Glasner <fzglas.hg@dom66.de>
parents:
698
diff
changeset
|
2427 else: |
|
193a616e0b3c
Begin implementation of filter-only expansions (recursive with respect to expansion)
Franz Glasner <fzglas.hg@dom66.de>
parents:
698
diff
changeset
|
2428 self.fail("`ValueError' should have been raised") |
|
193a616e0b3c
Begin implementation of filter-only expansions (recursive with respect to expansion)
Franz Glasner <fzglas.hg@dom66.de>
parents:
698
diff
changeset
|
2429 |
|
723
c17a4e30ebbf
Docs for nested filters
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
720
diff
changeset
|
2430 def test_nested_filter_None(self): |
|
703
193a616e0b3c
Begin implementation of filter-only expansions (recursive with respect to expansion)
Franz Glasner <fzglas.hg@dom66.de>
parents:
698
diff
changeset
|
2431 cfg = configmix.load() |
|
193a616e0b3c
Begin implementation of filter-only expansions (recursive with respect to expansion)
Franz Glasner <fzglas.hg@dom66.de>
parents:
698
diff
changeset
|
2432 y = getattr(cfg, self.interpolate_meth)(u"{{|{{not-existing}}|None|}}") |
|
193a616e0b3c
Begin implementation of filter-only expansions (recursive with respect to expansion)
Franz Glasner <fzglas.hg@dom66.de>
parents:
698
diff
changeset
|
2433 self.assertTrue(y is None) |
|
193a616e0b3c
Begin implementation of filter-only expansions (recursive with respect to expansion)
Franz Glasner <fzglas.hg@dom66.de>
parents:
698
diff
changeset
|
2434 |
|
723
c17a4e30ebbf
Docs for nested filters
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
720
diff
changeset
|
2435 def test_nested_filter_empty(self): |
|
703
193a616e0b3c
Begin implementation of filter-only expansions (recursive with respect to expansion)
Franz Glasner <fzglas.hg@dom66.de>
parents:
698
diff
changeset
|
2436 cfg = configmix.load() |
|
193a616e0b3c
Begin implementation of filter-only expansions (recursive with respect to expansion)
Franz Glasner <fzglas.hg@dom66.de>
parents:
698
diff
changeset
|
2437 y = getattr(cfg, self.interpolate_meth)(u"{{|{{not-existing}}|Empty|}}") |
|
193a616e0b3c
Begin implementation of filter-only expansions (recursive with respect to expansion)
Franz Glasner <fzglas.hg@dom66.de>
parents:
698
diff
changeset
|
2438 self.assertEqual(u(""), y) |
|
193a616e0b3c
Begin implementation of filter-only expansions (recursive with respect to expansion)
Franz Glasner <fzglas.hg@dom66.de>
parents:
698
diff
changeset
|
2439 |
|
723
c17a4e30ebbf
Docs for nested filters
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
720
diff
changeset
|
2440 def test_nested_nested_filter_empty(self): |
|
705
0485a033c95d
FIX: Parsing a filter chain for the new filter-only expansions: parse them backwards and use "," as filter-chain separator here.
Franz Glasner <fzglas.hg@dom66.de>
parents:
703
diff
changeset
|
2441 cfg = configmix.load() |
|
0485a033c95d
FIX: Parsing a filter chain for the new filter-only expansions: parse them backwards and use "," as filter-chain separator here.
Franz Glasner <fzglas.hg@dom66.de>
parents:
703
diff
changeset
|
2442 y = getattr(cfg, self.interpolate_meth)(u"{{|pre-{{not-existing|Empty}}-post|upper|}}") |
|
0485a033c95d
FIX: Parsing a filter chain for the new filter-only expansions: parse them backwards and use "," as filter-chain separator here.
Franz Glasner <fzglas.hg@dom66.de>
parents:
703
diff
changeset
|
2443 self.assertEqual(u("PRE--POST"), y) |
|
0485a033c95d
FIX: Parsing a filter chain for the new filter-only expansions: parse them backwards and use "," as filter-chain separator here.
Franz Glasner <fzglas.hg@dom66.de>
parents:
703
diff
changeset
|
2444 |
|
723
c17a4e30ebbf
Docs for nested filters
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
720
diff
changeset
|
2445 def test_nested_filter_upper(self): |
|
703
193a616e0b3c
Begin implementation of filter-only expansions (recursive with respect to expansion)
Franz Glasner <fzglas.hg@dom66.de>
parents:
698
diff
changeset
|
2446 cfg1 = { |
|
705
0485a033c95d
FIX: Parsing a filter chain for the new filter-only expansions: parse them backwards and use "," as filter-chain separator here.
Franz Glasner <fzglas.hg@dom66.de>
parents:
703
diff
changeset
|
2447 u("key-1"): u("Value for key-1") |
|
703
193a616e0b3c
Begin implementation of filter-only expansions (recursive with respect to expansion)
Franz Glasner <fzglas.hg@dom66.de>
parents:
698
diff
changeset
|
2448 } |
|
193a616e0b3c
Begin implementation of filter-only expansions (recursive with respect to expansion)
Franz Glasner <fzglas.hg@dom66.de>
parents:
698
diff
changeset
|
2449 cfg = cfg = configmix.config.Configuration(cfg1) |
|
193a616e0b3c
Begin implementation of filter-only expansions (recursive with respect to expansion)
Franz Glasner <fzglas.hg@dom66.de>
parents:
698
diff
changeset
|
2450 y = getattr(cfg, self.interpolate_meth)(u"{{|pre_{{key-1}}_post|upper|}}") |
|
193a616e0b3c
Begin implementation of filter-only expansions (recursive with respect to expansion)
Franz Glasner <fzglas.hg@dom66.de>
parents:
698
diff
changeset
|
2451 self.assertEqual(u("PRE_VALUE FOR KEY-1_POST"), y) |
|
193a616e0b3c
Begin implementation of filter-only expansions (recursive with respect to expansion)
Franz Glasner <fzglas.hg@dom66.de>
parents:
698
diff
changeset
|
2452 |
|
723
c17a4e30ebbf
Docs for nested filters
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
720
diff
changeset
|
2453 def test_nested_filter_normpath(self): |
|
737
282c8e64d7b1
FIX: tests on non-Windows
Franz Glasner <fzglas.hg@dom66.de>
parents:
724
diff
changeset
|
2454 p1 = u(os.path.join("a", "b", "c")) |
|
720
6d9552eb7e4d
Further test of filter-only expansions: with "normpath"
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
711
diff
changeset
|
2455 cfg1 = { |
|
737
282c8e64d7b1
FIX: tests on non-Windows
Franz Glasner <fzglas.hg@dom66.de>
parents:
724
diff
changeset
|
2456 u("path1"): p1, |
|
720
6d9552eb7e4d
Further test of filter-only expansions: with "normpath"
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
711
diff
changeset
|
2457 u("path2"): u("{{|{{path1}}/../d|normpath|}}") |
|
6d9552eb7e4d
Further test of filter-only expansions: with "normpath"
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
711
diff
changeset
|
2458 } |
|
6d9552eb7e4d
Further test of filter-only expansions: with "normpath"
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
711
diff
changeset
|
2459 cfg = cfg = configmix.config.Configuration(cfg1) |
|
6d9552eb7e4d
Further test of filter-only expansions: with "normpath"
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
711
diff
changeset
|
2460 np = cfg.getvarl_s(u("path2")) |
|
6d9552eb7e4d
Further test of filter-only expansions: with "normpath"
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
711
diff
changeset
|
2461 self.assertEqual( |
|
737
282c8e64d7b1
FIX: tests on non-Windows
Franz Glasner <fzglas.hg@dom66.de>
parents:
724
diff
changeset
|
2462 os.path.normpath(u(os.path.join("a", "b", "d"))), |
|
720
6d9552eb7e4d
Further test of filter-only expansions: with "normpath"
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
711
diff
changeset
|
2463 np) |
|
6d9552eb7e4d
Further test of filter-only expansions: with "normpath"
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
711
diff
changeset
|
2464 |
|
724
ef7bee8b54e1
Another test with chaining nested filter interpolation
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
723
diff
changeset
|
2465 def test_nested_filter_normpath_posixpath(self): |
|
737
282c8e64d7b1
FIX: tests on non-Windows
Franz Glasner <fzglas.hg@dom66.de>
parents:
724
diff
changeset
|
2466 p1 = u(os.path.join("a", "b", "c")) |
|
724
ef7bee8b54e1
Another test with chaining nested filter interpolation
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
723
diff
changeset
|
2467 cfg1 = { |
|
737
282c8e64d7b1
FIX: tests on non-Windows
Franz Glasner <fzglas.hg@dom66.de>
parents:
724
diff
changeset
|
2468 u("path1"): p1, |
|
724
ef7bee8b54e1
Another test with chaining nested filter interpolation
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
723
diff
changeset
|
2469 u("path2"): u("{{|{{path1}}/../d|normpath,posixpath|}}") |
|
ef7bee8b54e1
Another test with chaining nested filter interpolation
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
723
diff
changeset
|
2470 } |
|
ef7bee8b54e1
Another test with chaining nested filter interpolation
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
723
diff
changeset
|
2471 cfg = cfg = configmix.config.Configuration(cfg1) |
|
ef7bee8b54e1
Another test with chaining nested filter interpolation
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
723
diff
changeset
|
2472 np = cfg.getvarl_s(u("path2")) |
|
ef7bee8b54e1
Another test with chaining nested filter interpolation
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
723
diff
changeset
|
2473 self.assertEqual( |
|
737
282c8e64d7b1
FIX: tests on non-Windows
Franz Glasner <fzglas.hg@dom66.de>
parents:
724
diff
changeset
|
2474 u(os.path.join("a", "b", "d")), |
|
724
ef7bee8b54e1
Another test with chaining nested filter interpolation
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
723
diff
changeset
|
2475 np) |
|
ef7bee8b54e1
Another test with chaining nested filter interpolation
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
723
diff
changeset
|
2476 |
|
542
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2477 |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2478 class T09Parser(_TParserMixin, unittest.TestCase): |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2479 |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2480 def setUp(self): |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2481 self.unquote = configmix.config.py_unquote |
|
550
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2482 self.quote = configmix.config.py_quote |
|
542
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2483 self.pathstr2path = configmix.config.py_pathstr2path |
|
543
491413368c7c
Added also a fast C-implementation of configmix.config._split_ns
Franz Glasner <fzglas.hg@dom66.de>
parents:
542
diff
changeset
|
2484 self.split_ns = configmix.config._py_split_ns |
|
552
39e5d07d8dbc
Provide a C implementation of configmix.config._split_filters.
Franz Glasner <fzglas.hg@dom66.de>
parents:
550
diff
changeset
|
2485 self.split_filters = configmix.config._py_split_filters |
|
554
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2486 self.interpolate_meth = "py_interpolate_variables" |
|
543
491413368c7c
Added also a fast C-implementation of configmix.config._split_ns
Franz Glasner <fzglas.hg@dom66.de>
parents:
542
diff
changeset
|
2487 |
|
491413368c7c
Added also a fast C-implementation of configmix.config._split_ns
Franz Glasner <fzglas.hg@dom66.de>
parents:
542
diff
changeset
|
2488 def test_split_ns_wrong_type(self): |
|
491413368c7c
Added also a fast C-implementation of configmix.config._split_ns
Franz Glasner <fzglas.hg@dom66.de>
parents:
542
diff
changeset
|
2489 self.assertRaises( |
|
491413368c7c
Added also a fast C-implementation of configmix.config._split_ns
Franz Glasner <fzglas.hg@dom66.de>
parents:
542
diff
changeset
|
2490 AttributeError, # no .partition |
|
491413368c7c
Added also a fast C-implementation of configmix.config._split_ns
Franz Glasner <fzglas.hg@dom66.de>
parents:
542
diff
changeset
|
2491 self.split_ns, |
|
491413368c7c
Added also a fast C-implementation of configmix.config._split_ns
Franz Glasner <fzglas.hg@dom66.de>
parents:
542
diff
changeset
|
2492 1) |
|
542
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2493 |
|
550
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2494 def test_quote_wrong_type(self): |
|
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2495 self.assertRaises( |
|
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2496 AttributeError, # no .lstrip |
|
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2497 self.quote, |
|
656
2b1c7a68f913
Enable indexed access to lists in the configuration using an access path string representation like "~NNN~"
Franz Glasner <fzglas.hg@dom66.de>
parents:
651
diff
changeset
|
2498 1.0) |
|
550
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2499 |
|
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2500 def test_unquote_wrong_type(self): |
|
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2501 self.assertRaises( |
|
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2502 TypeError, # argument of type "int" is not iterable |
|
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2503 self.unquote, |
|
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2504 1) |
|
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2505 |
|
542
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2506 |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2507 if configmix.config.fast_unquote is not None: |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2508 class T10FastParser(_TParserMixin, unittest.TestCase): |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2509 |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2510 def setUp(self): |
|
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2511 self.unquote = configmix.config.fast_unquote |
|
550
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2512 self.quote = configmix.config.fast_quote |
|
542
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2513 self.pathstr2path = configmix.config.fast_pathstr2path |
|
543
491413368c7c
Added also a fast C-implementation of configmix.config._split_ns
Franz Glasner <fzglas.hg@dom66.de>
parents:
542
diff
changeset
|
2514 self.split_ns = configmix.config._fast_split_ns |
|
552
39e5d07d8dbc
Provide a C implementation of configmix.config._split_filters.
Franz Glasner <fzglas.hg@dom66.de>
parents:
550
diff
changeset
|
2515 self.split_filters = configmix.config._fast_split_filters |
|
554
36d7aa000435
Implement a C-version of Configuration.interpolate_variables
Franz Glasner <fzglas.hg@dom66.de>
parents:
553
diff
changeset
|
2516 self.interpolate_meth = "fast_interpolate_variables" |
|
543
491413368c7c
Added also a fast C-implementation of configmix.config._split_ns
Franz Glasner <fzglas.hg@dom66.de>
parents:
542
diff
changeset
|
2517 |
|
491413368c7c
Added also a fast C-implementation of configmix.config._split_ns
Franz Glasner <fzglas.hg@dom66.de>
parents:
542
diff
changeset
|
2518 def test_split_ns_wrong_type(self): |
|
491413368c7c
Added also a fast C-implementation of configmix.config._split_ns
Franz Glasner <fzglas.hg@dom66.de>
parents:
542
diff
changeset
|
2519 self.assertRaises( |
|
491413368c7c
Added also a fast C-implementation of configmix.config._split_ns
Franz Glasner <fzglas.hg@dom66.de>
parents:
542
diff
changeset
|
2520 TypeError, |
|
491413368c7c
Added also a fast C-implementation of configmix.config._split_ns
Franz Glasner <fzglas.hg@dom66.de>
parents:
542
diff
changeset
|
2521 self.split_ns, |
|
491413368c7c
Added also a fast C-implementation of configmix.config._split_ns
Franz Glasner <fzglas.hg@dom66.de>
parents:
542
diff
changeset
|
2522 b":") |
|
542
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2523 |
|
550
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2524 def test_quote_wrong_type(self): |
|
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2525 self.assertRaises( |
|
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2526 TypeError, |
|
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2527 self.quote, |
|
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2528 b":") |
|
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2529 |
|
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2530 def test_unquote_wrong_type(self): |
|
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2531 self.assertRaises( |
|
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2532 TypeError, |
|
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2533 self.unquote, |
|
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2534 b":") |
|
79db28e879f8
Provide a C-implementation of configmix.config.quote() also: fast_quote
Franz Glasner <fzglas.hg@dom66.de>
parents:
543
diff
changeset
|
2535 |
|
542
f71d34dda19f
Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents:
525
diff
changeset
|
2536 |
| 93 | 2537 if __name__ == "__main__": |
| 2538 unittest.main() |
