summaryrefslogtreecommitdiffstats
path: root/testsuite
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2014-11-10 11:42:42 -0600
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2014-11-10 17:35:44 -0600
commitaae0bafb03ee6e986c51436ec749bbadd97a2f7f (patch)
tree387f66dacb7931c1e54a88df02869f6fb4b09cde /testsuite
parent669a8fce985164632b41bcac8fef3f52223bac0e (diff)
downloadbcfg2-aae0bafb03ee6e986c51436ec749bbadd97a2f7f.tar.gz
bcfg2-aae0bafb03ee6e986c51436ec749bbadd97a2f7f.tar.bz2
bcfg2-aae0bafb03ee6e986c51436ec749bbadd97a2f7f.zip
Options: Fixed non-path database name parsing
The database name is sometimes a path (SQLite) and sometimes not (MySQL, PostgreSQL). This introduces a new Option type, RepositoryMacroOption, that expands <repository> macros without canonicalizing the path, so SQLite users can use <repository> in their settings but MySQL users' database name settings will not be destroyed by path canonicalization. The unfortunate downside is that SQLite users can't use ~ in their database name.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/Testsrc/Testlib/TestOptions/TestOptions.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/testsuite/Testsrc/Testlib/TestOptions/TestOptions.py b/testsuite/Testsrc/Testlib/TestOptions/TestOptions.py
index a3190f2ca..a2dc8ffe2 100644
--- a/testsuite/Testsrc/Testlib/TestOptions/TestOptions.py
+++ b/testsuite/Testsrc/Testlib/TestOptions/TestOptions.py
@@ -7,8 +7,9 @@ import tempfile
import mock
from Bcfg2.Compat import ConfigParser
-from Bcfg2.Options import Option, PathOption, BooleanOption, Parser, \
- PositionalArgument, OptionParserException, Common, new_parser, get_parser
+from Bcfg2.Options import Option, PathOption, RepositoryMacroOption, \
+ BooleanOption, Parser, PositionalArgument, OptionParserException, \
+ Common, new_parser, get_parser
from testsuite.Testsrc.Testlib.TestOptions import OptionTestCase, \
make_config, clean_environment
@@ -382,16 +383,21 @@ class TestBasicOptions(OptionTestCase):
parser.add_options,
[Option(cf=("test", "option"))])
- @make_config({"test": {"test_path": "<repository>/test"}})
+ @make_config({"test": {"test_path": "<repository>/test",
+ "test_macro": "<repository>"}})
def test_repository_macro(self, config_file):
"""fix up <repository> macros."""
result = argparse.Namespace()
parser = Parser(namespace=result)
parser.add_options([PathOption("--test1"),
- PathOption("--test2"),
+ RepositoryMacroOption("--test2"),
PathOption(cf=("test", "test_path")),
PathOption(cf=("test", "test_path_default"),
default="<repository>/test/default"),
+ RepositoryMacroOption(cf=("test", "test_macro")),
+ RepositoryMacroOption(
+ cf=("test", "test_macro_default"),
+ default="<repository>"),
Common.repository])
parser.parse(["-C", config_file, "-Q", "/foo/bar",
"--test1", "<repository>/test1",
@@ -399,6 +405,8 @@ class TestBasicOptions(OptionTestCase):
self.assertEqual(result.repository, "/foo/bar")
self.assertEqual(result.test1, "/foo/bar/test1")
self.assertEqual(result.test2, "/foo/bar/foo/bar")
+ self.assertEqual(result.test_macro, "/foo/bar")
+ self.assertEqual(result.test_macro_default, "/foo/bar")
self.assertEqual(result.test_path, "/foo/bar/test")
self.assertEqual(result.test_path_default, "/foo/bar/test/default")