Install priorities of CentOS7 only on CentOS7 host

Change-Id: I29ffd3caa481fc94995ae0ba4c914ebee219aa89
This commit is contained in:
Sagi Shnaidman 2021-12-15 14:23:52 +02:00
parent 5ee86bdd9a
commit c27cd26535
2 changed files with 5 additions and 8 deletions

View File

@ -547,7 +547,7 @@ def main():
args = _parse_args(distro_id, distro_major_version_id)
_validate_args(args, distro_name, distro_major_version_id)
base_path = _get_base_path(args)
if args.distro in ['centos7']:
if (distro_name.lower(), distro_major_version_id) == ("centos", "7"):
_install_priorities()
_remove_existing(args)
_install_repos(args, base_path)

View File

@ -25,14 +25,13 @@ from tripleo_repos import main
@ddt.ddt
class TestTripleORepos(testtools.TestCase):
@mock.patch('tripleo_repos.main._get_distro')
@mock.patch('sys.argv', ['tripleo-repos', 'current', '-d', 'centos7'])
@mock.patch('sys.argv', ['tripleo-repos', 'current', '-d', 'centos8'])
@mock.patch('tripleo_repos.main._run_pkg_clean')
@mock.patch('tripleo_repos.main._validate_args')
@mock.patch('tripleo_repos.main._get_base_path')
@mock.patch('tripleo_repos.main._install_priorities')
@mock.patch('tripleo_repos.main._remove_existing')
@mock.patch('tripleo_repos.main._install_repos')
def test_main(self, mock_install, mock_remove, mock_ip, mock_gbp,
def test_main_centos8(self, mock_install, mock_remove, mock_gbp,
mock_validate, mock_clean, mock_distro):
mock_distro.return_value = ('centos', '8', 'CentOS 8')
args = main._parse_args('centos', '8')
@ -41,10 +40,8 @@ class TestTripleORepos(testtools.TestCase):
main.main()
mock_validate.assert_called_once_with(args, 'CentOS 8', '8')
mock_gbp.assert_called_once_with(args)
mock_ip.assert_called_once_with()
mock_remove.assert_called_once_with(args)
mock_install.assert_called_once_with(args, mock_path)
mock_clean.assert_called_once_with('centos7')
mock_clean.assert_called_once_with('centos8')
@mock.patch('tripleo_repos.main._get_distro')
@mock.patch('sys.argv', ['tripleo-repos', 'current', '-d', 'fedora'])