From 44174fd6b45db12e5b5e0620106c7df9f53cbc73 Mon Sep 17 00:00:00 2001 From: Tim Lauridsen <timlau@fedoraproject.org> Date: Wed, 15 Apr 2015 19:06:20 +0200 Subject: [PATCH] fix: use same cachedir as dnf cli cleanup some unit tests and removed some debug printing --- python/dnfdaemon/server/__init__.py | 2 +- python/dnfdaemon/server/backend.py | 16 ++-------------- test/test_common.py | 15 +++++++-------- test/test_data/repos/main.repo | 4 ++-- 4 files changed, 12 insertions(+), 25 deletions(-) diff --git a/python/dnfdaemon/server/__init__.py b/python/dnfdaemon/server/__init__.py index 98863b9..e0091bf 100644 --- a/python/dnfdaemon/server/__init__.py +++ b/python/dnfdaemon/server/__init__.py @@ -741,7 +741,7 @@ class DnfDaemonBase(dbus.service.Object, DownloadCallback): output = e.value.split('. ') if rc: for tsi in self.base.transaction: - print(tsi.op_type, tsi.installed, tsi.erased, tsi.obsoleted) + #print(tsi.op_type, tsi.installed, tsi.erased, tsi.obsoleted) if tsi.op_type == dnf.transaction.DOWNGRADE: b['downgrade'].append(tsi) elif tsi.op_type == dnf.transaction.ERASE: diff --git a/python/dnfdaemon/server/backend.py b/python/dnfdaemon/server/backend.py index 51a8282..8529e5c 100644 --- a/python/dnfdaemon/server/backend.py +++ b/python/dnfdaemon/server/backend.py @@ -44,7 +44,8 @@ class DnfBase(dnf.Base): super(DnfBase, self).__init__() self.parent = parent self.md_progress = MDProgress(parent) - self.setup_cache() + RELEASEVER = dnf.rpm.detect_releasever(self.conf.installroot) + self.conf.substitutions['releasever'] = RELEASEVER self.read_all_repos() self.progress = Progress(parent, max_err=100) self.repos.all().set_progress_bar(self.md_progress) @@ -64,19 +65,6 @@ class DnfBase(dnf.Base): def packages(self): return self._packages - def cachedir_fit(self, conf): - subst = conf.substitutions - # this is not public API, same procedure as dnf cli - suffix = dnf.conf.parser.substitute(dnf.const.CACHEDIR_SUFFIX, subst) - cli_cache = dnf.conf.CliCache(conf.cachedir, suffix) - return cli_cache.cachedir, cli_cache.system_cachedir - - def setup_cache(self): - """Setup the dnf cache, same as dnf cli""" - conf = self.conf - conf.cachedir, self._system_cachedir = self.cachedir_fit(conf) - logger.debug("cachedir: %s", conf.cachedir) - def set_max_error(self, max_err): """Setup a new progress object with a new max number of download errors. diff --git a/test/test_common.py b/test/test_common.py index cf402a6..c67d2d8 100644 --- a/test/test_common.py +++ b/test/test_common.py @@ -47,7 +47,6 @@ class TestPackages(support.TestCase): pkgs = backend.Packages(base) inst = list(map(str, pkgs.installed)) print - print(inst) self.assertEqual(inst, ['bar-1.0-1.noarch', 'foo-2.0-1.noarch', 'bar-old-1.0-1.noarch', @@ -104,7 +103,7 @@ class TestDnfBase(support.TestCase): """Test search (dups)""" found = self.base.search(['name'], ['foo'], showdups=True) res = list(map(str, found)) - print(res) + #print(res) self.assertEqual(res, ['foo-2.0-1.noarch', 'foo-2.0-1.noarch', @@ -142,7 +141,7 @@ class TestBrokenDeps(TestCommonBase): self.assertEqual(res, ['broken,0,1.0,1,noarch,broken', 'dep01,0,1.0,1,noarch,broken']) rc, msgs = json.loads(self.daemon.install('broken')) - print(rc, msgs) + #print(rc, msgs) self.assertEqual(False, rc) self.assertEqual(['nothing provides not-found-dep01 >= ' '1-0 needed by dep01-1.0-1.noarch'], msgs) @@ -275,7 +274,7 @@ class TestCommonGroups(TestCommonBase): def test_get_groups(self): res = self.daemon.get_groups() - print(json.loads(res)) + #print(json.loads(res)) self.assertEqual(json.loads(res), [[["Base System", "Base System", "Various core pieces of the system."], @@ -316,13 +315,13 @@ class TestCommonGroups(TestCommonBase): """Test group_remove""" cmds = "inst-grp" prst = self.daemon.base.group_persistor - print(json.dumps(prst.db.dct)) + #print(json.dumps(prst.db.dct)) p_grp = prst.group(cmds) self.assertTrue(p_grp.installed) res = self.daemon.group_remove(cmds) - print(json.loads(res)) + #print(json.loads(res)) self.assertFalse(p_grp.installed) - print(json.dumps(prst.db.dct)) + #print(json.dumps(prst.db.dct)) class TestCommonInstall(TestCommonBase): @@ -457,7 +456,7 @@ class TestCommonTransaction(TestCommonBase): [True, [['install', [['petzoo,0,1.0,1,noarch,main', 0.0, []]]]]]) # test _get_transaction() trans = self.daemon.build_transaction() - print(json.loads(trans)) + #print(json.loads(trans)) self.assertEqual(json.loads(trans), [True, [['install', [['petzoo,0,1.0,1,noarch,main', 0.0, []]]]]]) diff --git a/test/test_data/repos/main.repo b/test/test_data/repos/main.repo index c716159..ccb9fcf 100644 --- a/test/test_data/repos/main.repo +++ b/test/test_data/repos/main.repo @@ -14,7 +14,7 @@ =Pkg: bar-dep-err 1.0 1 noarch =Req: not-found-dep >= 1-0 =Pkg: bar-new 2.0 1 noarch -=Obs: bar-old 1.0 1 noarch -=Obs: old-bar 1.0 1 noarch +=Obs: bar-old +=Obs: old-bar =Pkg: petzoo 1.0 1 noarch -- GitLab