Skip to content

Commit

Permalink
Fix incorrect test mock in unit tests (oamg#1201)
Browse files Browse the repository at this point in the history
There was an incorrect assigment in the test mock that caused one of the
unit_tests to take a lot of time to finish.
  • Loading branch information
r0x0d authored Apr 29, 2024
1 parent 018c1f9 commit 3c02999
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions convert2rhel/unit_tests/backup/packages_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,20 +190,20 @@ def test_install_local_rpms_package_install_warning(self, monkeypatch, caplog):
)
)
monkeypatch.setattr(utils, "run_subprocess", value=run_subprocess_mock)

rp = RestorablePackage(pkgs=[pkg_name])
rp._backedup_pkgs_paths = pkg_name
pkgs = [pkg_name]
rp = RestorablePackage(pkgs=pkgs)
rp._backedup_pkgs_paths = pkgs
result = rp._install_local_rpms(replace=False, critical=False)

assert result == False
assert run_subprocess_mock.call_count == 1
assert "Couldn't install %s packages." % pkg_name in caplog.records[-1].message

def test_test_install_local_rpms_system_exit(self, monkeypatch, caplog):
pkg_name = "pkg-1"
pkg_name = ["pkg-1"]
run_subprocess_mock = RunSubprocessMocked(
side_effect=unit_tests.run_subprocess_side_effect(
(("rpm", "-i", pkg_name), ("test", 1)),
(("rpm", "-i", " ".join(pkg_name)), ("test", 1)),
)
)
monkeypatch.setattr(
Expand All @@ -212,13 +212,13 @@ def test_test_install_local_rpms_system_exit(self, monkeypatch, caplog):
value=run_subprocess_mock,
)

rp = RestorablePackage(pkgs=[pkg_name])
rp = RestorablePackage(pkgs=pkg_name)
rp._backedup_pkgs_paths = pkg_name
with pytest.raises(exceptions.CriticalError):
rp._install_local_rpms(replace=False, critical=True)

assert run_subprocess_mock.call_count == 1
assert "Error: Couldn't install %s packages." % pkg_name in caplog.records[-1].message
assert "Error: Couldn't install %s packages." % "".join(pkg_name) in caplog.records[-1].message


class TestRestorablePackageSet:
Expand Down

0 comments on commit 3c02999

Please sign in to comment.