salt/0015-Remove-zypper-s-raise-exception-if-mod_repo-has-no-a.patch
Klaus Kämpf 14ef6d2b51 Accepting request 430691 from systemsmanagement:saltstack:testing
- splitting out the susemanager integration plugins into their own
  subpackages. ATM this only contains the zypp plugin to tell
  susemanager about manually installed packages.

- Unit and integration tests fixes for 2016.3.2
  Add:
  * 0018-Unit-tests-fixes-for-2016.3.2.patch
  * 0019-Fix-snapper_test-for-python26.patch
  * 0020-Integration-tests-fixes-for-2016.3.2.patch

- Prevent pkg.install failure for expired keys (bsc#996455)
  Add:
  * 0017-Check-for-single-quote-before-splitting-on-single-qu.patch

- Required D-Bus and generating machine ID where it is missing

- Fix sphinx crashes when documentation is being generated
  Add script for documentation update.
  Add:
  * 0016-Improve-Mock-to-be-flexible-and-able-to-mock-methods.patch
  * update-documentation.sh

- Fix pkg.installed refresh repo failure (bsc#993549)
  Fix salt.states.pkgrepo.management no change failure (bsc#990440)
  Add:
  * 0014-Add-ignore_repo_failure-option-to-suppress-zypper-s-.patch
  * 0015-Remove-zypper-s-raise-exception-if-mod_repo-has-no-a.patch

- Deprecate status.uptime one version later
  Add:

OBS-URL: https://build.opensuse.org/request/show/430691
OBS-URL: https://build.opensuse.org/package/show/systemsmanagement:saltstack/salt?expand=0&rev=77
2016-09-28 07:49:13 +00:00

79 lines
2.9 KiB
Diff

From 0809c60c693eb5d2e9569c24d995818097c6920d Mon Sep 17 00:00:00 2001
From: Bo Maryniuk <bo@suse.de>
Date: Mon, 15 Aug 2016 17:35:01 +0200
Subject: [PATCH 15/15] Remove zypper's raise exception if mod_repo has no
arguments and/or no changes
* Fix Unit test for suppressing the exception removal on non-modified repos
---
salt/modules/zypper.py | 11 +++++++----
tests/unit/modules/zypper_test.py | 15 +++------------
2 files changed, 10 insertions(+), 16 deletions(-)
diff --git a/salt/modules/zypper.py b/salt/modules/zypper.py
index 1c60f0f..1ec903e 100644
--- a/salt/modules/zypper.py
+++ b/salt/modules/zypper.py
@@ -824,6 +824,7 @@ def mod_repo(repo, **kwargs):
cmd_opt = global_cmd_opt + ['mr'] + cmd_opt + [repo]
__zypper__.refreshable.xml.call(*cmd_opt)
+ comment = None
if call_refresh:
# when used with "zypper ar --refresh" or "zypper mr --refresh"
# --gpg-auto-import-keys is not doing anything
@@ -831,11 +832,13 @@ def mod_repo(repo, **kwargs):
refresh_opts = global_cmd_opt + ['refresh'] + [repo]
__zypper__.xml.call(*refresh_opts)
elif not added and not cmd_opt:
- raise CommandExecutionError(
- 'Specified arguments did not result in modification of repo'
- )
+ comment = 'Specified arguments did not result in modification of repo'
+
+ repo = get_repo(repo)
+ if comment:
+ repo['comment'] = comment
- return get_repo(repo)
+ return repo
def refresh_db():
diff --git a/tests/unit/modules/zypper_test.py b/tests/unit/modules/zypper_test.py
index 2f2b323..7caa707 100644
--- a/tests/unit/modules/zypper_test.py
+++ b/tests/unit/modules/zypper_test.py
@@ -73,7 +73,7 @@ class ZypperTestCase(TestCase):
self.zypper_patcher_config = {
'_get_configured_repos': Mock(side_effect=side_effect),
'__zypper__': Mock(),
- 'get_repo': Mock()
+ 'get_repo': Mock(return_value={})
}
def test_list_upgrades(self):
@@ -493,17 +493,8 @@ class ZypperTestCase(TestCase):
'salt.modules.zypper', **self.zypper_patcher_config)
with zypper_patcher:
- with self.assertRaisesRegexp(
- Exception,
- 'Specified arguments did not result in modification of repo'
- ):
- zypper.mod_repo(name, **{'url': url})
- with self.assertRaisesRegexp(
- Exception,
- 'Specified arguments did not result in modification of repo'
- ):
- zypper.mod_repo(name, **{'url': url, 'gpgautoimport': 'a'})
-
+ self.assertEqual(zypper.mod_repo(name, **{'url': url}),
+ {'comment': 'Specified arguments did not result in modification of repo'})
zypper.__zypper__.xml.call.assert_not_called()
zypper.__zypper__.refreshable.xml.call.assert_not_called()
--
2.9.3