summaryrefslogtreecommitdiffstats
path: root/testsuite/Testsrc/Testlib/TestOptions/TestOptions.py
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 11:42:42 -0600
commit0e133c157755908d05c44c3a36b1dc0668e1d111 (patch)
treeea130b60114ade926462cb1516eb1a16fbd7c013 /testsuite/Testsrc/Testlib/TestOptions/TestOptions.py
parentca78be11051dab7421a414fc3ae4104c82f1f9e7 (diff)
downloadbcfg2-0e133c157755908d05c44c3a36b1dc0668e1d111.tar.gz
bcfg2-0e133c157755908d05c44c3a36b1dc0668e1d111.tar.bz2
bcfg2-0e133c157755908d05c44c3a36b1dc0668e1d111.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/Testsrc/Testlib/TestOptions/TestOptions.py')
-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")