Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Step:15-SP1
salt.26880
do-not-crash-when-unexpected-cmd-output-at-list...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File do-not-crash-when-unexpected-cmd-output-at-listing-p.patch of Package salt.26880
From b151f2c1c6b6599b6387ec6e2d32a56e031e3d48 Mon Sep 17 00:00:00 2001 From: Alexander Graul <agraul@suse.com> Date: Tue, 18 Jan 2022 19:12:25 +0100 Subject: [PATCH] Do not crash when unexpected cmd output at listing patches (bsc#1181290) Add unit tests to cover unexpected output when listing patches --- tests/pytests/unit/modules/test_yumpkg.py | 53 +++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/tests/pytests/unit/modules/test_yumpkg.py b/tests/pytests/unit/modules/test_yumpkg.py index 475e1d6094..3b35272550 100644 --- a/tests/pytests/unit/modules/test_yumpkg.py +++ b/tests/pytests/unit/modules/test_yumpkg.py @@ -433,6 +433,59 @@ def test_list_patches(): assert _patch in patches["my-fake-patch-installed-1234"]["summary"] +def test_list_patches_with_unexpected_output(): + """ + Test patches listin with unexpected output from updateinfo list + + :return: + """ + yum_out = [ + "Update notice RHBA-2014:0722 (from rhel7-dev-rhel7-rpm-x86_64) is broken, or a bad duplicate, skipping.", + "You should report this problem to the owner of the rhel7-dev-rhel7-rpm-x86_64 repository.", + 'To help pinpoint the issue, please attach the output of "yum updateinfo --verbose" to the report.', + "Update notice RHSA-2014:1971 (from rhel7-dev-rhel7-rpm-x86_64) is broken, or a bad duplicate, skipping.", + "Update notice RHSA-2015:1981 (from rhel7-dev-rhel7-rpm-x86_64) is broken, or a bad duplicate, skipping.", + "Update notice RHSA-2015:0067 (from rhel7-dev-rhel7-rpm-x86_64) is broken, or a bad duplicate, skipping", + "i my-fake-patch-not-installed-1234 recommended spacewalk-usix-2.7.5.2-2.2.noarch", + " my-fake-patch-not-installed-1234 recommended spacewalksd-5.0.26.2-21.2.x86_64", + "i my-fake-patch-not-installed-1234 recommended suseRegisterInfo-3.1.1-18.2.x86_64", + "i my-fake-patch-installed-1234 recommended my-package-one-1.1-0.1.x86_64", + "i my-fake-patch-installed-1234 recommended my-package-two-1.1-0.1.x86_64", + ] + + expected_patches = { + "my-fake-patch-not-installed-1234": { + "installed": False, + "summary": [ + "spacewalk-usix-2.7.5.2-2.2.noarch", + "spacewalksd-5.0.26.2-21.2.x86_64", + "suseRegisterInfo-3.1.1-18.2.x86_64", + ], + }, + "my-fake-patch-installed-1234": { + "installed": True, + "summary": [ + "my-package-one-1.1-0.1.x86_64", + "my-package-two-1.1-0.1.x86_64", + ], + }, + } + + with patch.dict(yumpkg.__grains__, {"osarch": "x86_64"}), patch.dict( + yumpkg.__salt__, + {"cmd.run_stdout": MagicMock(return_value=os.linesep.join(yum_out))}, + ): + patches = yumpkg.list_patches() + assert not patches["my-fake-patch-not-installed-1234"]["installed"] + assert len(patches["my-fake-patch-not-installed-1234"]["summary"]) == 3 + for _patch in expected_patches["my-fake-patch-not-installed-1234"]["summary"]: + assert _patch in patches["my-fake-patch-not-installed-1234"]["summary"] + assert patches["my-fake-patch-installed-1234"]["installed"] + assert len(patches["my-fake-patch-installed-1234"]["summary"]) == 2 + for _patch in expected_patches["my-fake-patch-installed-1234"]["summary"]: + assert _patch in patches["my-fake-patch-installed-1234"]["summary"] + + def test_latest_version_with_options(): with patch.object(yumpkg, "list_pkgs", MagicMock(return_value={})): -- 2.34.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor