mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
call refresh_db function from mod_repo
This commit is contained in:
parent
e546bd7461
commit
c899e7a4b0
2 changed files with 35 additions and 20 deletions
|
@ -1374,7 +1374,6 @@ def mod_repo(repo, **kwargs):
|
|||
cmd_opt.append(kwargs.get("name"))
|
||||
|
||||
if kwargs.get("gpgautoimport") is True:
|
||||
global_cmd_opt.append("--gpg-auto-import-keys")
|
||||
call_refresh = True
|
||||
|
||||
if cmd_opt:
|
||||
|
@ -1386,8 +1385,8 @@ def mod_repo(repo, **kwargs):
|
|||
# when used with "zypper ar --refresh" or "zypper mr --refresh"
|
||||
# --gpg-auto-import-keys is not doing anything
|
||||
# so we need to specifically refresh here with --gpg-auto-import-keys
|
||||
refresh_opts = global_cmd_opt + ["refresh"] + [repo]
|
||||
__zypper__(root=root).xml.call(*refresh_opts)
|
||||
kwargs.update({"repos": repo})
|
||||
refresh_db(root=root, **kwargs)
|
||||
elif not added and not cmd_opt:
|
||||
comment = "Specified arguments did not result in modification of repo"
|
||||
|
||||
|
|
|
@ -1617,18 +1617,23 @@ class ZypperTestCase(TestCase, LoaderModuleMockMixin):
|
|||
|
||||
url = self.new_repo_config["url"]
|
||||
name = self.new_repo_config["name"]
|
||||
with zypper_patcher:
|
||||
with zypper_patcher, patch.object(zypper, "refresh_db", Mock()) as refreshmock:
|
||||
zypper.mod_repo(name, **{"url": url, "gpgautoimport": True})
|
||||
self.assertEqual(
|
||||
zypper.__zypper__(root=None).xml.call.call_args_list,
|
||||
[
|
||||
call("ar", url, name),
|
||||
call("--gpg-auto-import-keys", "refresh", name),
|
||||
],
|
||||
)
|
||||
self.assertTrue(
|
||||
zypper.__zypper__(root=None).refreshable.xml.call.call_count == 0
|
||||
)
|
||||
refreshmock.assert_called_once_with(
|
||||
gpgautoimport=True,
|
||||
repos=name,
|
||||
root=None,
|
||||
url="http://repo.url/some/path",
|
||||
)
|
||||
|
||||
def test_repo_noadd_nomod_ref(self):
|
||||
"""
|
||||
|
@ -1647,15 +1652,17 @@ class ZypperTestCase(TestCase, LoaderModuleMockMixin):
|
|||
"salt.modules.zypperpkg", **self.zypper_patcher_config
|
||||
)
|
||||
|
||||
with zypper_patcher:
|
||||
with zypper_patcher, patch.object(zypper, "refresh_db", Mock()) as refreshmock:
|
||||
zypper.mod_repo(name, **{"url": url, "gpgautoimport": True})
|
||||
self.assertEqual(
|
||||
zypper.__zypper__(root=None).xml.call.call_args_list,
|
||||
[call("--gpg-auto-import-keys", "refresh", name)],
|
||||
)
|
||||
self.assertTrue(
|
||||
zypper.__zypper__(root=None).refreshable.xml.call.call_count == 0
|
||||
)
|
||||
refreshmock.assert_called_once_with(
|
||||
gpgautoimport=True,
|
||||
repos=name,
|
||||
root=None,
|
||||
url="http://repo.url/some/path",
|
||||
)
|
||||
|
||||
def test_repo_add_mod_ref(self):
|
||||
"""
|
||||
|
@ -1668,10 +1675,10 @@ class ZypperTestCase(TestCase, LoaderModuleMockMixin):
|
|||
zypper_patcher = patch.multiple(
|
||||
"salt.modules.zypperpkg", **self.zypper_patcher_config
|
||||
)
|
||||
|
||||
url = self.new_repo_config["url"]
|
||||
name = self.new_repo_config["name"]
|
||||
with zypper_patcher:
|
||||
|
||||
with zypper_patcher, patch.object(zypper, "refresh_db", Mock()) as refreshmock:
|
||||
zypper.mod_repo(
|
||||
name, **{"url": url, "refresh": True, "gpgautoimport": True}
|
||||
)
|
||||
|
@ -1679,11 +1686,17 @@ class ZypperTestCase(TestCase, LoaderModuleMockMixin):
|
|||
zypper.__zypper__(root=None).xml.call.call_args_list,
|
||||
[
|
||||
call("ar", url, name),
|
||||
call("--gpg-auto-import-keys", "refresh", name),
|
||||
],
|
||||
)
|
||||
zypper.__zypper__(root=None).refreshable.xml.call.assert_called_once_with(
|
||||
"--gpg-auto-import-keys", "mr", "--refresh", name
|
||||
"mr", "--refresh", name
|
||||
)
|
||||
refreshmock.assert_called_once_with(
|
||||
gpgautoimport=True,
|
||||
refresh=True,
|
||||
repos=name,
|
||||
root=None,
|
||||
url="http://repo.url/some/path",
|
||||
)
|
||||
|
||||
def test_repo_noadd_mod_ref(self):
|
||||
|
@ -1703,16 +1716,19 @@ class ZypperTestCase(TestCase, LoaderModuleMockMixin):
|
|||
"salt.modules.zypperpkg", **self.zypper_patcher_config
|
||||
)
|
||||
|
||||
with zypper_patcher:
|
||||
with zypper_patcher, patch.object(zypper, "refresh_db", Mock()) as refreshmock:
|
||||
zypper.mod_repo(
|
||||
name, **{"url": url, "refresh": True, "gpgautoimport": True}
|
||||
)
|
||||
self.assertEqual(
|
||||
zypper.__zypper__(root=None).xml.call.call_args_list,
|
||||
[call("--gpg-auto-import-keys", "refresh", name)],
|
||||
)
|
||||
zypper.__zypper__(root=None).refreshable.xml.call.assert_called_once_with(
|
||||
"--gpg-auto-import-keys", "mr", "--refresh", name
|
||||
"mr", "--refresh", name
|
||||
)
|
||||
refreshmock.assert_called_once_with(
|
||||
gpgautoimport=True,
|
||||
refresh=True,
|
||||
repos=name,
|
||||
root=None,
|
||||
url="http://repo.url/some/path",
|
||||
)
|
||||
|
||||
def test_wildcard_to_query_match_all(self):
|
||||
|
|
Loading…
Add table
Reference in a new issue