79 lines
2.9 KiB
Diff
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
|
||
|
|