File 0008-Fix-pkgrepo.managed-gpgkey-argument-bsc-979448.patch of Package salt.4202
From 7764ba4fcb456ed8840f235a27d5d5421dfa01fc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mihai=20Dinc=C4=83?= <dincamihai@users.noreply.github.com>
Date: Mon, 23 May 2016 23:15:29 +0200
Subject: [PATCH 08/38] Fix pkgrepo.managed gpgkey argument (bsc#979448)
* Call zypper refresh after adding/modifying a repository
* Calling `zypper --gpg-auto-import-keys refresh` is required after
adding/modifying a repository because `--gpg-auto-import-keys` doesn't
do anything when called with `zypper ar` or `zypper mr`.
Without calling `zypper --gpg-auto-import-keys refresh` here, calling
`zypper ref` after adding/removing would still ask for
accepting/rejecting the gpg key.
* Update test method names to pass pylint
* Reduce dicts and lists to one line where possible
* Reverse if conditions and rename variable
* Assert only gpgautoimport: True works
* Improve zypper_patcher_config looks
* DRY test
---
salt/modules/zypper.py | 1 +
tests/unit/modules/zypper_test.py | 13 +++++++++++--
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/salt/modules/zypper.py b/salt/modules/zypper.py
index a1c2bdb..50d3b8d 100644
--- a/salt/modules/zypper.py
+++ b/salt/modules/zypper.py
@@ -833,6 +833,7 @@ def mod_repo(repo, **kwargs):
__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
diff --git a/tests/unit/modules/zypper_test.py b/tests/unit/modules/zypper_test.py
index 8eb2a4f..3f6a39d 100644
--- a/tests/unit/modules/zypper_test.py
+++ b/tests/unit/modules/zypper_test.py
@@ -500,8 +500,17 @@ class ZypperTestCase(TestCase):
'salt.modules.zypper', **self.zypper_patcher_config)
with zypper_patcher:
- self.assertEqual(zypper.mod_repo(name, **{'url': url}),
- {'comment': 'Specified arguments did not result in modification of repo'})
+ 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'})
+
zypper.__zypper__.xml.call.assert_not_called()
zypper.__zypper__.refreshable.xml.call.assert_not_called()
--
2.10.2