use tmp db for tests. (fixes #2672)
This commit is contained in:
+29
-15
@@ -10,6 +10,7 @@
|
|||||||
# Author: Faik Uygur <faik@pardus.org.tr>
|
# Author: Faik Uygur <faik@pardus.org.tr>
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
import pisi.context as ctx
|
||||||
import pisi.api
|
import pisi.api
|
||||||
import pisi
|
import pisi
|
||||||
|
|
||||||
@@ -20,15 +21,30 @@ class ConflictTestCase(testcase.TestCase):
|
|||||||
testcase.TestCase.setUp(self)
|
testcase.TestCase.setUp(self)
|
||||||
|
|
||||||
d_t = {}
|
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"],
|
"b": ["a", "e", "f"],
|
||||||
"c": ["g", "h"],
|
"c": ["g", "h"],
|
||||||
"d": [],
|
"d": [],
|
||||||
"e": ["j"],
|
"e": ["j"],
|
||||||
"amigo" : ["pciutils", "agimo", "libpng", "ncurses", "soniga"],
|
"f" : ["inst1", "notinst2", "f", "inst3", "notinst3"],
|
||||||
"imago" : ["less"],
|
"g" : ["inst4", "notinst1"],
|
||||||
"gomia" : ["hede", "hodo", "libpng"],
|
"h" : ["inst2", "inst3", "inst4", "notinst2"],
|
||||||
"omiga" : []}
|
"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():
|
for name in packages.keys():
|
||||||
pkg = pisi.specfile.Package()
|
pkg = pisi.specfile.Package()
|
||||||
@@ -48,22 +64,20 @@ class ConflictTestCase(testcase.TestCase):
|
|||||||
def testConflictWithEachOther(self):
|
def testConflictWithEachOther(self):
|
||||||
packages = ["a", "b", "c", "d", "e"]
|
packages = ["a", "b", "c", "d", "e"]
|
||||||
(C, D, pkg_conflicts) = pisi.operations.calculate_conflicts(packages, self.packagedb)
|
(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):
|
def testConflictWithInstalled(self):
|
||||||
packages = ["amigo", "imago", "omiga"]
|
packages = ["g", "h", "i"]
|
||||||
(C, D, pkg_conflicts) = pisi.operations.calculate_conflicts(packages, self.packagedb)
|
(C, D, pkg_conflicts) = pisi.operations.calculate_conflicts(packages, self.packagedb)
|
||||||
self.assert_(not D)
|
self.assert_(not D)
|
||||||
self.assert_(['libpng', 'ncurses', 'less', 'pciutils'] == list(C))
|
self.assert_(set(['inst1', 'inst2', 'inst3', 'inst4']) == C)
|
||||||
self.assert_(['libpng', 'ncurses', 'pciutils'] == list(pkg_conflicts["amigo"]))
|
self.assert_("notinst1" not in pkg_conflicts["g"])
|
||||||
self.assert_("agimo" not in list(pkg_conflicts["amigo"]))
|
|
||||||
|
|
||||||
def testConflictWithEachOtherAndInstalled(self):
|
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)
|
(C, D, pkg_conflicts) = pisi.operations.calculate_conflicts(packages, self.packagedb)
|
||||||
self.assert_(['a', 'b'] == list(D))
|
self.assert_(set(['a', 'b']) == D)
|
||||||
self.assert_(['libpng', 'ncurses', 'less', 'pciutils'] == list(C))
|
self.assert_(set(['inst1', 'inst2', 'inst3', 'inst4']) == C)
|
||||||
self.assert_(['libpng', 'ncurses', 'pciutils'] == list(pkg_conflicts["amigo"]))
|
self.assert_(set(['inst2', 'inst3', 'inst4']) == pkg_conflicts["h"])
|
||||||
self.assert_("agimo" not in list(pkg_conflicts["amigo"]))
|
|
||||||
|
|
||||||
suite = unittest.makeSuite(ConflictTestCase)
|
suite = unittest.makeSuite(ConflictTestCase)
|
||||||
|
|||||||
Reference in New Issue
Block a user