diff --git a/scripts/preconversion_assessment_script.py b/scripts/preconversion_assessment_script.py index 506a9a5..fd06937 100644 --- a/scripts/preconversion_assessment_script.py +++ b/scripts/preconversion_assessment_script.py @@ -244,7 +244,7 @@ def install_convert2rhel(pkgs_to_cleanup): """Install the convert2rhel tool to the system.""" print("Installing & updating Convert2RHEL package.") - c2r_pkg_name = 'convert2rhel' + c2r_pkg_name = "convert2rhel" c2r_installed = _check_if_package_installed(c2r_pkg_name) if not c2r_installed: @@ -259,9 +259,7 @@ def install_convert2rhel(pkgs_to_cleanup): ) pkgs_to_cleanup.append(pkgs_to_cleanup) - output, returncode = run_subprocess( - ["/usr/bin/yum", "update", c2r_pkg_name, "-y"] - ) + output, returncode = run_subprocess(["/usr/bin/yum", "update", c2r_pkg_name, "-y"]) if returncode: raise ProcessError( message="Failed to update convert2rhel RPM.", diff --git a/tests/preconversion_assessment/test_install.py b/tests/preconversion_assessment/test_install.py index 2ab2fe1..c3bd8e9 100644 --- a/tests/preconversion_assessment/test_install.py +++ b/tests/preconversion_assessment/test_install.py @@ -10,8 +10,8 @@ @pytest.mark.parametrize( ("subprocess_mock", "pkg_installed_mock", "pkg_removal_len"), ( - ([(b"output", 0), (b"output", 0)], False , 1), - ([(b"output", 0)], True , 0), # just update with no removed packages + ([(b"output", 0), (b"output", 0)], False, 1), + ([(b"output", 0)], True, 0), # just update with no removed packages ), ) def test_install_convert2rhel(subprocess_mock, pkg_installed_mock, pkg_removal_len): @@ -33,13 +33,21 @@ def test_install_convert2rhel(subprocess_mock, pkg_installed_mock, pkg_removal_l ["/usr/bin/yum", "update", "convert2rhel", "-y"], ] if pkg_removal_len > 0: - expected_calls = [["/usr/bin/yum", "install", "convert2rhel", "-y"]] + expected_calls + expected_calls = [ + ["/usr/bin/yum", "install", "convert2rhel", "-y"] + ] + expected_calls assert mock_run_subprocess.call_args_list == [call(args) for args in expected_calls] -@patch("scripts.preconversion_assessment_script._check_if_package_installed", return_value=False) -@patch("scripts.preconversion_assessment_script.run_subprocess", return_value=(b"failed", 1)) +@patch( + "scripts.preconversion_assessment_script._check_if_package_installed", + return_value=False, +) +@patch( + "scripts.preconversion_assessment_script.run_subprocess", + return_value=(b"failed", 1), +) def test_install_convert2rhel_raise_exception(mock_run_subprocess, mock_pkg_check): with pytest.raises( ProcessError, @@ -52,8 +60,15 @@ def test_install_convert2rhel_raise_exception(mock_run_subprocess, mock_pkg_chec mock_pkg_check.assert_called_once() assert mock_run_subprocess.call_args_list == [call(args) for args in expected_calls] -@patch("scripts.preconversion_assessment_script._check_if_package_installed", return_value=False) -@patch("scripts.preconversion_assessment_script.run_subprocess", side_effect=[(b"output", 0), (b"failed", 1)]) + +@patch( + "scripts.preconversion_assessment_script._check_if_package_installed", + return_value=False, +) +@patch( + "scripts.preconversion_assessment_script.run_subprocess", + side_effect=[(b"output", 0), (b"failed", 1)], +) def test_update_convert2rhel_raise_exception(mock_run_subprocess, mock_pkg_check): with pytest.raises( ProcessError,