From e86f4f9a366f56dffb2b35fc86b2096d7a44113a Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Wed, 2 May 2018 09:58:29 -0700 Subject: [PATCH] Update dnfbase (formerly yumbase) for DNF support And adjust tests to match. --- src/pylorax/api/dnfbase.py | 2 ++ tests/pylorax/test_dnfbase.py | 29 +++++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/pylorax/api/dnfbase.py b/src/pylorax/api/dnfbase.py index 7392041c..d7f3e200 100644 --- a/src/pylorax/api/dnfbase.py +++ b/src/pylorax/api/dnfbase.py @@ -47,6 +47,8 @@ def get_base_object(conf): dbc.installroot = dnfroot if not os.path.isdir(dnfroot): os.makedirs(dnfroot) + if not os.path.isdir(repodir): + os.makedirs(repodir) dbc.cachedir = cachedir dbc.reposdir = [repodir] diff --git a/tests/pylorax/test_dnfbase.py b/tests/pylorax/test_dnfbase.py index 8793836f..698985ac 100644 --- a/tests/pylorax/test_dnfbase.py +++ b/tests/pylorax/test_dnfbase.py @@ -25,7 +25,7 @@ from pylorax.api.config import configure, make_dnf_dirs from pylorax.api.dnfbase import get_base_object -class YumbaseTest(unittest.TestCase): +class DnfbaseNoSystemReposTest(unittest.TestCase): @classmethod def setUpClass(self): self.tmp_dir = tempfile.mkdtemp(prefix="lorax.test.dnfbase.") @@ -69,7 +69,32 @@ use_system_repos = False self.assertEqual({}, self.dbo.repos) -class CreateYumDirsTest(unittest.TestCase): +class DnfbaseSystemReposTest(unittest.TestCase): + @classmethod + def setUpClass(self): + self.tmp_dir = tempfile.mkdtemp(prefix="lorax.test.dnfbase.") + + # will read the above configuration + config = configure(root_dir=self.tmp_dir) + make_dnf_dirs(config) + + # will read composer config and store a dnf config file + self.dbo = get_base_object(config) + + # will read the stored dnf config file + self.dnfconf = configparser.ConfigParser() + self.dnfconf.read([config.get("composer", "dnf_conf")]) + + @classmethod + def tearDownClass(self): + shutil.rmtree(self.tmp_dir) + + def test_uses_system_repos(self): + # no other repos defined for this test + self.assertTrue(len(self.dbo.repos) > 0) + + +class CreateDnfDirsTest(unittest.TestCase): @classmethod def setUpClass(self): self.tmp_dir = tempfile.mkdtemp(prefix="lorax.test.dnfbase.")