Blame SOURCES/0017-Set-persistdir-for-fill-sack-from-repos-in-cache-tests-RhBug-1865803.patch

4f4af9
From 40e762da5cd2d876b6424f4c25b77e8dc2422a0f Mon Sep 17 00:00:00 2001
4f4af9
From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
4f4af9
Date: Mon, 8 Feb 2021 08:25:46 +0100
4f4af9
Subject: [PATCH] Set persistdir and substitutions for
4f4af9
 fill_sack_from_repos_in_cache tests (RhBug:1865803)
4f4af9
4f4af9
Setting just installroot is not enough because persistdir is not
4f4af9
automatically prepended with installroot if set via API.
4f4af9
4f4af9
Also assert exact package names which is more useful output in case the
4f4af9
test fails.
4f4af9
4f4af9
https://bugzilla.redhat.com/show_bug.cgi?id=1865803
4f4af9
---
4f4af9
 tests/test_fill_sack_from_repos_in_cache.py | 19 +++++++++++++++----
4f4af9
 1 file changed, 15 insertions(+), 4 deletions(-)
4f4af9
4f4af9
diff --git a/tests/test_fill_sack_from_repos_in_cache.py b/tests/test_fill_sack_from_repos_in_cache.py
4f4af9
index f27235bf84..23fd2a4337 100644
4f4af9
--- a/tests/test_fill_sack_from_repos_in_cache.py
4f4af9
+++ b/tests/test_fill_sack_from_repos_in_cache.py
4f4af9
@@ -42,7 +42,10 @@ class FillSackFromReposInCacheTest(unittest.TestCase):
4f4af9
     def _create_cache_for_repo(self, repopath, tmpdir):
4f4af9
         conf = dnf.conf.MainConf()
4f4af9
         conf.cachedir = os.path.join(tmpdir, "cache")
4f4af9
-        conf.installroot = os.path.join(tmpdir)
4f4af9
+        conf.installroot = tmpdir
4f4af9
+        conf.persistdir = os.path.join(conf.installroot, conf.persistdir.lstrip("/"))
4f4af9
+        conf.substitutions["arch"] = "x86_64"
4f4af9
+        conf.substitutions["basearch"] = dnf.rpm.basearch(conf.substitutions["arch"])
4f4af9
 
4f4af9
         base = dnf.Base(conf=conf)
4f4af9
 
4f4af9
@@ -69,7 +72,10 @@ def _setUp_from_repo_path(self, original_repo_path):
4f4af9
         # Prepare base for the actual test
4f4af9
         conf = dnf.conf.MainConf()
4f4af9
         conf.cachedir = os.path.join(self.tmpdir, "cache")
4f4af9
-        conf.installroot = os.path.join(self.tmpdir)
4f4af9
+        conf.installroot = self.tmpdir
4f4af9
+        conf.persistdir = os.path.join(conf.installroot, conf.persistdir.lstrip("/"))
4f4af9
+        conf.substitutions["arch"] = "x86_64"
4f4af9
+        conf.substitutions["basearch"] = dnf.rpm.basearch(conf.substitutions["arch"])
4f4af9
         self.test_base = dnf.Base(conf=conf)
4f4af9
         repoconf = dnf.repo.Repo(TEST_REPO_NAME, conf)
4f4af9
         repoconf.baseurl = self.repo_copy_path
4f4af9
@@ -231,8 +237,13 @@ def test_with_modules_yaml(self):
4f4af9
 
4f4af9
         q = self.test_base.sack.query()
4f4af9
         packages = q.run()
4f4af9
-        self.assertEqual(len(packages), 8)
4f4af9
-        self.assertEqual(packages[0].evr, "2.02-0.40")
4f4af9
+
4f4af9
+        pkg_names = []
4f4af9
+        for pkg in packages:
4f4af9
+            pkg_names.append(pkg.name)
4f4af9
+
4f4af9
+        self.assertEqual(pkg_names, ['grub2', 'httpd', 'httpd', 'httpd-doc', 'httpd-doc', 'httpd-provides-name-doc',
4f4af9
+                                     'httpd-provides-name-version-release-doc', 'libnghttp2'])
4f4af9
 
4f4af9
         self.module_base = dnf.module.module_base.ModuleBase(self.test_base)
4f4af9
         modules, _ = self.module_base._get_modules("base-runtime*")