use tmp db for tests. (fixes #2672)

This commit is contained in:
Faik Uygur
2006-05-05 09:07:02 +00:00
parent 2496a27bd4
commit 5f9a78f62f
+29 -15
View File
@@ -10,6 +10,7 @@
# Author: Faik Uygur <faik@pardus.org.tr>
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)