From 5f9a78f62f9a15033d67addc84e6bba8fbeb8abc Mon Sep 17 00:00:00 2001 From: Faik Uygur Date: Fri, 5 May 2006 09:07:02 +0000 Subject: [PATCH] use tmp db for tests. (fixes #2672) --- tests/conflicttests.py | 44 ++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/tests/conflicttests.py b/tests/conflicttests.py index 6504b869..0976f28b 100644 --- a/tests/conflicttests.py +++ b/tests/conflicttests.py @@ -10,6 +10,7 @@ # Author: Faik Uygur import unittest +import pisi.context as ctx import pisi.api import pisi @@ -20,15 +21,30 @@ class ConflictTestCase(testcase.TestCase): testcase.TestCase.setUp(self) d_t = {} - packages = {"a": ["z", "t", "d"], + + # instx are the conflicting packages that are installed on the system. + # notinstx are conflicting packages that are not installed on the system. + # a-j are the packages to be installed. + packages = {"a": ["notinst1", "notinst2", "b"], "b": ["a", "e", "f"], "c": ["g", "h"], "d": [], "e": ["j"], - "amigo" : ["pciutils", "agimo", "libpng", "ncurses", "soniga"], - "imago" : ["less"], - "gomia" : ["hede", "hodo", "libpng"], - "omiga" : []} + "f" : ["inst1", "notinst2", "f", "inst3", "notinst3"], + "g" : ["inst4", "notinst1"], + "h" : ["inst2", "inst3", "inst4", "notinst2"], + "i" : ["notinst2", "inst1"], + "j" : []} + + # packages that are installed on the system + ctx.installdb.purge('inst1') + ctx.installdb.purge('inst2') + ctx.installdb.purge('inst3') + ctx.installdb.purge('inst4') + ctx.installdb.install('inst1', '1.2', '2', '3') + ctx.installdb.install('inst2', '2.4', '2', '3') + ctx.installdb.install('inst3', '5.2', '2', '3') + ctx.installdb.install('inst4', '2.1', '2', '3') for name in packages.keys(): pkg = pisi.specfile.Package() @@ -48,22 +64,20 @@ class ConflictTestCase(testcase.TestCase): def testConflictWithEachOther(self): packages = ["a", "b", "c", "d", "e"] (C, D, pkg_conflicts) = pisi.operations.calculate_conflicts(packages, self.packagedb) - self.assert_(['a', 'b', 'e', 'd'] == list(D)) + self.assert_(set(['a', 'b', 'e']) == D) def testConflictWithInstalled(self): - packages = ["amigo", "imago", "omiga"] + packages = ["g", "h", "i"] (C, D, pkg_conflicts) = pisi.operations.calculate_conflicts(packages, self.packagedb) self.assert_(not D) - self.assert_(['libpng', 'ncurses', 'less', 'pciutils'] == list(C)) - self.assert_(['libpng', 'ncurses', 'pciutils'] == list(pkg_conflicts["amigo"])) - self.assert_("agimo" not in list(pkg_conflicts["amigo"])) + self.assert_(set(['inst1', 'inst2', 'inst3', 'inst4']) == C) + self.assert_("notinst1" not in pkg_conflicts["g"]) def testConflictWithEachOtherAndInstalled(self): - packages = ["amigo", "imago", "a", "b", "c"] + packages = ["a", "b", "g", "h", "i"] (C, D, pkg_conflicts) = pisi.operations.calculate_conflicts(packages, self.packagedb) - self.assert_(['a', 'b'] == list(D)) - self.assert_(['libpng', 'ncurses', 'less', 'pciutils'] == list(C)) - self.assert_(['libpng', 'ncurses', 'pciutils'] == list(pkg_conflicts["amigo"])) - self.assert_("agimo" not in list(pkg_conflicts["amigo"])) + self.assert_(set(['a', 'b']) == D) + self.assert_(set(['inst1', 'inst2', 'inst3', 'inst4']) == C) + self.assert_(set(['inst2', 'inst3', 'inst4']) == pkg_conflicts["h"]) suite = unittest.makeSuite(ConflictTestCase)