diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2015-07-28 13:58:00 -0500 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2015-07-28 13:58:00 -0500 |
commit | b4d9cf0759854af521d67c237df01e07c66bd73c (patch) | |
tree | 1548e0fffd96357d086247095770266df92db274 /testsuite | |
parent | 724a1228490336ac26e3edb2c115da6db1b049fd (diff) | |
parent | 2bbafa1499094a98a03fb5e84e5dff9b4b9a7aad (diff) | |
download | bcfg2-b4d9cf0759854af521d67c237df01e07c66bd73c.tar.gz bcfg2-b4d9cf0759854af521d67c237df01e07c66bd73c.tar.bz2 bcfg2-b4d9cf0759854af521d67c237df01e07c66bd73c.zip |
Merge pull request #292 from AlexanderS/fix-options-default
Options: Set default values from config, right after adding a new option
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/Testsrc/Testlib/TestOptions/TestComponents.py | 10 | ||||
-rw-r--r-- | testsuite/Testsrc/Testlib/TestOptions/Two.py | 3 |
2 files changed, 11 insertions, 2 deletions
diff --git a/testsuite/Testsrc/Testlib/TestOptions/TestComponents.py b/testsuite/Testsrc/Testlib/TestOptions/TestComponents.py index 61b87de2a..b1ed4cb2b 100644 --- a/testsuite/Testsrc/Testlib/TestOptions/TestComponents.py +++ b/testsuite/Testsrc/Testlib/TestOptions/TestComponents.py @@ -182,7 +182,8 @@ class TestImportComponentOptions(OptionTestCase): """test cases for component loading.""" def setUp(self): - self.options = [Option("--cls", action=ImportComponentAction), + self.options = [Option("--cls", cf=("config", "cls"), + action=ImportComponentAction), Option("--module", action=ImportModuleAction)] self.result = argparse.Namespace() @@ -227,3 +228,10 @@ class TestImportComponentOptions(OptionTestCase): self.assertRaises(SystemExit, self.parser.parse, ["-C", config_file, "--cls", "Bcfg2.No.Such.Thing"]) + + @make_config({"config": {"test": "foo", "cls": "Two"}}) + def test_default_from_config_for_component_options(self, config_file): + """use default value from config file for options added by dynamic loaded component.""" + self.parser.parse(["-C", config_file]) + self.assertEqual(self.result.cls, Two.Two) + self.assertEqual(self.result.test, "foo") diff --git a/testsuite/Testsrc/Testlib/TestOptions/Two.py b/testsuite/Testsrc/Testlib/TestOptions/Two.py index 189e0817f..0120e8b77 100644 --- a/testsuite/Testsrc/Testlib/TestOptions/Two.py +++ b/testsuite/Testsrc/Testlib/TestOptions/Two.py @@ -1,6 +1,7 @@ """Test module for component loading.""" +from Bcfg2.Options import Option class Two(object): """Test class for component loading.""" - pass + options = [Option('--test', cf=("config", "test"), dest="test", default="bar")] |