config: Keep known options defined on CLI

If the validation or dumping script is given some options, they should
only be removed if they are not valid. We have to remove the invalid
ones, otherwise that would cause a warning about unknown options.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2019-06-25 15:13:16 +02:00
parent d063217d6f
commit 32a6415e58
4 changed files with 22 additions and 4 deletions

View file

@ -35,3 +35,13 @@ class TestDefineHelpers(unittest.TestCase):
def test_validate_define_incorrect(self, value):
with self.assertRaises(argparse.ArgumentTypeError):
config_utils.validate_definition(value)
def test_remove_unknown(self):
conf = {"foo": "bar"}
config_utils.remove_unknown(conf, ["foo"])
self.assertEqual(conf, {})
def test_remove_known(self):
conf = {"release_name": "bar"}
config_utils.remove_unknown(conf, ["release_name"])
self.assertEqual(conf, {"release_name": "bar"})