-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RHELC-1332] Port PkgManagerConf() to the Action framework (#1321)
* [RHELC-1332] Port PkgManagerConf() to the Action framework * Add pkg manager config and unit test * Apply suggestions from code review Co-authored-by: Adam Hošek <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Draft PkgManagerConf changes * Updated PkgManagerConfig structure to use instance variable * Apply suggestions from code review Co-authored-by: Freya Gustavsson <[email protected]> Co-authored-by: Rodolfo Olivieri <[email protected]> * Update class name * Add dependency * Add mocks for write_altered_pkg_manager_conf * Remove PosixPath from unit test * Remove sys import * Update convert2rhel/redhatrelease.py Co-authored-by: Rodolfo Olivieri <[email protected]> * Fix changed-yum int test. --------- Co-authored-by: Adam Hošek <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Freya Gustavsson <[email protected]> Co-authored-by: Rodolfo Olivieri <[email protected]> Co-authored-by: Rodolfo Olivieri <[email protected]>
- Loading branch information
1 parent
80333d9
commit 7c12aa8
Showing
7 changed files
with
149 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Copyright(C) 2024 Red Hat, Inc. | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
__metaclass__ = type | ||
|
||
import logging | ||
|
||
from convert2rhel import actions, redhatrelease | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class ConfigurePkgManager(actions.Action): | ||
id = "CONFIGURE_PKG_MANAGER" | ||
dependencies = ("CONVERT_SYSTEM_PACKAGES",) | ||
|
||
def run(self): | ||
""" | ||
Check if the distroverpkg tag inside the package manager config has been modified before the conversion and if so | ||
comment it out and write to the file. | ||
""" | ||
super(ConfigurePkgManager, self).run() | ||
|
||
logger.task("Convert: Patch package manager configuration file") | ||
pmc = redhatrelease.PkgManagerConf() | ||
pmc.patch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
convert2rhel/unit_tests/actions/conversion/pkg_manager_config_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Copyright(C) 2024 Red Hat, Inc. | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
__metaclass__ = type | ||
import pytest | ||
import six | ||
|
||
from convert2rhel import redhatrelease | ||
from convert2rhel.actions.conversion import pkg_manager_config | ||
|
||
|
||
six.add_move(six.MovedModule("mock", "mock", "unittest.mock")) | ||
from six.moves import mock | ||
|
||
|
||
@pytest.fixture | ||
def pkg_manager_config_instance(): | ||
return pkg_manager_config.ConfigurePkgManager() | ||
|
||
|
||
def test_pkg_manager_config(pkg_manager_config_instance, monkeypatch): | ||
redhat_release_mock = mock.Mock() | ||
monkeypatch.setattr(redhatrelease.PkgManagerConf, "patch", redhat_release_mock) | ||
pkg_manager_config_instance.run() | ||
|
||
assert redhat_release_mock.call_count == 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters