Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP1:GA
salt.3314
0069-Remove-zypper-s-raise-exception-if-mod_rep...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0069-Remove-zypper-s-raise-exception-if-mod_repo-has-no-a.patch of Package salt.3314
From 506ac8f820e681b276725a5385b11c4f12e4f809 Mon Sep 17 00:00:00 2001 From: Bo Maryniuk <bo@suse.de> Date: Mon, 15 Aug 2016 17:35:01 +0200 Subject: [PATCH 69/69] 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 8c3b78b..fa803ac 100644 --- a/salt/modules/zypper.py +++ b/salt/modules/zypper.py @@ -795,6 +795,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 @@ -802,11 +803,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
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