checks.py: show warning message for alias option
Show warning message for any alias option find in config instance.
Example warning message:
WARNING: Config option 'product_name' is deprecated and now an alias to
'release_name', please use 'release_name' instead. In:
{'release_name': 'dummy product', 'product_name': 'dummy product'}
Signed-off-by: Qixiang Wan <qwan@redhat.com>
This commit is contained in:
parent
9784961568
commit
2aacefd9cd
3 changed files with 62 additions and 45 deletions
|
|
@ -238,7 +238,8 @@ class TestSchemaValidator(unittest.TestCase):
|
|||
config = self._load_conf_from_string(string)
|
||||
errors, warnings = checks.validate(config)
|
||||
self.assertEqual(len(errors), 0)
|
||||
self.assertEqual(len(warnings), 0)
|
||||
self.assertEqual(len(warnings), 1)
|
||||
self.assertRegexpMatches(warnings[0], r"^WARNING: Config option 'product_name' is deprecated and now an alias to 'release_name'.*")
|
||||
self.assertEqual(config.get("release_name", None), "dummy product")
|
||||
|
||||
@mock.patch('pungi.checks._make_schema')
|
||||
|
|
@ -285,7 +286,8 @@ class TestSchemaValidator(unittest.TestCase):
|
|||
config = self._load_conf_from_string(string)
|
||||
errors, warnings = checks.validate(config)
|
||||
self.assertEqual(len(errors), 0)
|
||||
self.assertEqual(len(warnings), 0)
|
||||
self.assertEqual(len(warnings), 1)
|
||||
self.assertRegexpMatches(warnings[0], r"^WARNING: Config option 'product_name' is deprecated and now an alias to 'release_name'.*")
|
||||
self.assertEqual(config.get("release_name", None), "dummy product")
|
||||
|
||||
@mock.patch('pungi.checks._make_schema')
|
||||
|
|
@ -309,8 +311,9 @@ class TestSchemaValidator(unittest.TestCase):
|
|||
config = self._load_conf_from_string(string)
|
||||
errors, warnings = checks.validate(config)
|
||||
self.assertEqual(len(errors), 1)
|
||||
self.assertIn('Failed validation in : product_name is an alias of release_name, only one can be used.', errors)
|
||||
self.assertEqual(len(warnings), 0)
|
||||
self.assertRegexpMatches(errors[0], r"^ERROR: Config option 'product_name' is an alias of 'release_name', only one can be used.*")
|
||||
self.assertEqual(len(warnings), 1)
|
||||
self.assertRegexpMatches(warnings[0], r"^WARNING: Config option 'product_name' is deprecated and now an alias to 'release_name'.*")
|
||||
self.assertEqual(config.get("release_name", None), "dummy product")
|
||||
|
||||
@mock.patch('pungi.checks._make_schema')
|
||||
|
|
@ -348,7 +351,9 @@ class TestSchemaValidator(unittest.TestCase):
|
|||
config = self._load_conf_from_string(string)
|
||||
errors, warnings = checks.validate(config)
|
||||
self.assertEqual(len(errors), 0)
|
||||
self.assertEqual(len(warnings), 0)
|
||||
self.assertEqual(len(warnings), 2)
|
||||
self.assertRegexpMatches(warnings[0], r"^WARNING: Config option '.+' is deprecated and now an alias to '.+'.*")
|
||||
self.assertRegexpMatches(warnings[1], r"^WARNING: Config option '.+' is deprecated and now an alias to '.+'.*")
|
||||
self.assertEqual(config.get("release_name", None), "dummy product")
|
||||
self.assertEqual(config.get("foophase", {}).get("repo", None), "http://www.exampe.com/os")
|
||||
|
||||
|
|
|
|||
|
|
@ -273,7 +273,7 @@ class OstreeConfigTestCase(ConfigTestCase):
|
|||
"x86_64": {
|
||||
"treefile": "fedora-atomic-docker-host.json",
|
||||
"config_url": "https://git.fedorahosted.org/git/fedora-atomic.git",
|
||||
"source_repo_from": "Everything",
|
||||
"repo_from": "Everything",
|
||||
"ostree_repo": "/mnt/koji/compose/atomic/Rawhide/"
|
||||
}
|
||||
})
|
||||
|
|
@ -298,7 +298,7 @@ class OstreeInstallerConfigTestCase(ConfigTestCase):
|
|||
ostree_installer=[
|
||||
("^Atomic$", {
|
||||
"x86_64": {
|
||||
"source_repo_from": "Everything",
|
||||
"repo_from": "Everything",
|
||||
"release": None,
|
||||
"installpkgs": ["fedora-productimg-atomic"],
|
||||
"add_template": ["/spin-kickstarts/atomic-installer/lorax-configure-repo.tmpl"],
|
||||
|
|
@ -326,7 +326,7 @@ class OstreeInstallerConfigTestCase(ConfigTestCase):
|
|||
ostree_installer=[
|
||||
("^Atomic$", {
|
||||
"x86_64": {
|
||||
"source_repo_from": "Everything",
|
||||
"repo_from": "Everything",
|
||||
"release": None,
|
||||
"installpkgs": ["fedora-productimg-atomic"],
|
||||
"add_template": ["/spin-kickstarts/atomic-installer/lorax-configure-repo.tmpl"],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue