Reject yum gather backend on Python 3
It will not run, and having a nice error message is better than a cryptic crash. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
f3806f7c77
commit
daf162503c
@ -575,10 +575,12 @@ Options
|
||||
* With ``greedy_method = "build" ``pkg-b-provider-1`` and
|
||||
``pkg-b-provider-2`` will be pulled in.
|
||||
|
||||
**gather_backend** = ``yum``
|
||||
(*str*) -- Either ``yum`` or ``dnf``. This changes the entire codebase
|
||||
doing dependency solving, so it can change the result in unpredictable
|
||||
ways.
|
||||
**gather_backend**
|
||||
(*str*) --This changes the entire codebase doing dependency solving, so it
|
||||
can change the result in unpredictable ways.
|
||||
|
||||
On Python 2, the choice is between ``yum`` or ``dnf`` and defaults to
|
||||
``yum``. On Python 3 ``dnf`` is the only option and default.
|
||||
|
||||
Particularly the multilib work is performed differently by using
|
||||
``python-multilib`` library. Please refer to ``multilib`` option to see the
|
||||
|
@ -581,8 +581,8 @@ def make_schema():
|
||||
"gather_source_mapping": {"type": "string"},
|
||||
"gather_backend": {
|
||||
"type": "string",
|
||||
"enum": ["yum", "dnf"],
|
||||
"default": "yum",
|
||||
"enum": _get_gather_backends(),
|
||||
"default": _get_default_gather_backend(),
|
||||
},
|
||||
"gather_profiler": {
|
||||
"type": "boolean",
|
||||
@ -1203,3 +1203,13 @@ CONFIG_DEPS = {
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def _get_gather_backends():
|
||||
if six.PY2:
|
||||
return ['yum', 'dnf']
|
||||
return ['dnf']
|
||||
|
||||
|
||||
def _get_default_gather_backend():
|
||||
return 'yum' if six.PY2 else 'dnf'
|
||||
|
@ -10,6 +10,7 @@ except ImportError:
|
||||
import os
|
||||
import six
|
||||
import sys
|
||||
import mock
|
||||
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
|
||||
|
||||
@ -250,6 +251,38 @@ class GatherConfigTestCase(ConfigTestCase):
|
||||
cfg,
|
||||
[checks.REQUIRES.format('gather_source', 'json', 'gather_source_mapping')])
|
||||
|
||||
def test_dnf_backend_is_default_on_py3(self):
|
||||
cfg = load_config(
|
||||
pkgset_source='koji',
|
||||
pkgset_koji_tag='f27',
|
||||
)
|
||||
|
||||
with mock.patch('six.PY2', new=False):
|
||||
self.assertValidation(cfg, [])
|
||||
self.assertEqual(cfg['gather_backend'], 'dnf')
|
||||
|
||||
def test_yum_backend_is_default_on_py2(self):
|
||||
cfg = load_config(
|
||||
pkgset_source='koji',
|
||||
pkgset_koji_tag='f27',
|
||||
)
|
||||
|
||||
with mock.patch('six.PY2', new=True):
|
||||
self.assertValidation(cfg, [])
|
||||
self.assertEqual(cfg['gather_backend'], 'yum')
|
||||
|
||||
def test_yum_backend_is_rejected_on_py3(self):
|
||||
cfg = load_config(
|
||||
pkgset_source='koji',
|
||||
pkgset_koji_tag='f27',
|
||||
gather_backend='yum',
|
||||
)
|
||||
|
||||
with mock.patch('six.PY2', new=False):
|
||||
self.assertValidation(
|
||||
cfg,
|
||||
["Failed validation in gather_backend: 'yum' is not one of ['dnf']"])
|
||||
|
||||
|
||||
class OSBSConfigTestCase(ConfigTestCase):
|
||||
def test_validate(self):
|
||||
|
Loading…
Reference in New Issue
Block a user