SHA256
1
0
forked from pool/salt
salt/fix-wrong-test_mod_del_repo_multiline_values-test-af.patch

83 lines
3.7 KiB
Diff

From e3ef9165b66c3d74a3c3dbfe82ba58f7fa1613e2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?=
<psuarezhernandez@suse.com>
Date: Thu, 12 Mar 2020 13:26:51 +0000
Subject: [PATCH] Fix wrong test_mod_del_repo_multiline_values test after
rebase
---
tests/integration/modules/test_pkg.py | 34 +++++++++++++++++++++------
1 file changed, 27 insertions(+), 7 deletions(-)
diff --git a/tests/integration/modules/test_pkg.py b/tests/integration/modules/test_pkg.py
index ccf69998fc..6a84ea0bc3 100644
--- a/tests/integration/modules/test_pkg.py
+++ b/tests/integration/modules/test_pkg.py
@@ -138,6 +138,10 @@ class PkgModuleTest(ModuleCase, SaltReturnAssertsMixin):
self.run_function("pkg.del_repo", [repo])
@pytest.mark.slow_test
+ @pytest.mark.destructive_test
+ @pytest.mark.requires_salt_modules("pkg.mod_repo", "pkg.del_repo", "pkg.get_repo")
+ @pytest.mark.requires_network()
+ @requires_system_grains
def test_mod_del_repo_multiline_values(self):
"""
test modifying and deleting a software repository defined with multiline values
@@ -145,10 +149,13 @@ class PkgModuleTest(ModuleCase, SaltReturnAssertsMixin):
os_grain = self.run_function("grains.item", ["os"])["os"]
repo = None
try:
- if os_grain in ["CentOS", "RedHat", "VMware Photon OS"]:
+ if os_grain in ["CentOS", "RedHat", "VMware Photon OS", "SUSE"]:
my_baseurl = (
"http://my.fake.repo/foo/bar/\n http://my.fake.repo.alt/foo/bar/"
)
+ expected_get_repo_baseurl_zypp = (
+ "http://my.fake.repo/foo/bar/%0A%20http://my.fake.repo.alt/foo/bar/"
+ )
expected_get_repo_baseurl = (
"http://my.fake.repo/foo/bar/\nhttp://my.fake.repo.alt/foo/bar/"
)
@@ -174,17 +181,30 @@ class PkgModuleTest(ModuleCase, SaltReturnAssertsMixin):
enabled=enabled,
failovermethod=failovermethod,
)
- # return data from pkg.mod_repo contains the file modified at
- # the top level, so use next(iter(ret)) to get that key
self.assertNotEqual(ret, {})
- repo_info = ret[next(iter(ret))]
+ repo_info = {repo: ret}
self.assertIn(repo, repo_info)
- self.assertEqual(repo_info[repo]["baseurl"], my_baseurl)
+ if os_grain == "SUSE":
+ self.assertEqual(
+ repo_info[repo]["baseurl"], expected_get_repo_baseurl_zypp
+ )
+ else:
+ self.assertEqual(repo_info[repo]["baseurl"], my_baseurl)
ret = self.run_function("pkg.get_repo", [repo])
- self.assertEqual(ret["baseurl"], expected_get_repo_baseurl)
+ if os_grain == "SUSE":
+ self.assertEqual(
+ repo_info[repo]["baseurl"], expected_get_repo_baseurl_zypp
+ )
+ else:
+ self.assertEqual(ret["baseurl"], expected_get_repo_baseurl)
self.run_function("pkg.mod_repo", [repo])
ret = self.run_function("pkg.get_repo", [repo])
- self.assertEqual(ret["baseurl"], expected_get_repo_baseurl)
+ if os_grain == "SUSE":
+ self.assertEqual(
+ repo_info[repo]["baseurl"], expected_get_repo_baseurl_zypp
+ )
+ else:
+ self.assertEqual(ret["baseurl"], expected_get_repo_baseurl)
finally:
if repo is not None:
self.run_function("pkg.del_repo", [repo])
--
2.33.0