def setUp(self): """ Called at the start of each test. """ _DepsolveTestsBase.setUp(self) self.tsInfo = transactioninfo.TransactionData() self.tsInfo.debug = 1 self.rpmdb = FakeRpmDb() self.xsack = packageSack.PackageSack() self.repo = FakeRepo("installed") # XXX this side-affect is hacky: self.tsInfo.setDatabases(self.rpmdb, self.xsack)
def runOperation(self, args, installed=[], available=[], confs={}, multi_cmds=False): """Sets up and runs the depsolver. args[0] must be a valid yum command ("install", "update", ...). It might be followed by pkg names as on the yum command line. The pkg objects in installed are added to self.rpmdb and those in available to self.xsack which is the repository to resolve requirements from. """ depsolver = YumBaseCli() depsolver.save_ts = save_ts depsolver.arch.setup_arch('x86_64') self.rpmdb = depsolver.rpmdb = FakeRpmDb() self.xsack = depsolver._pkgSack = packageSack.PackageSack() self.repo = depsolver.repo = FakeRepo("installed") depsolver.conf = FakeConf() for conf in confs: setattr(depsolver.conf, conf, confs[conf]) # We are running nosetest, so we want to see some yum output # if a testcase if failing depsolver.doLoggingSetup(9, 9) self.depsolver = depsolver for po in installed: po.repoid = po.repo.id = "installed" self.depsolver.rpmdb.addPackage(po) for po in available: if po.repo.id is None: po.repo.id = "TestRepository" po.repoid = po.repo.id self.depsolver._pkgSack.addPackage(po) if not multi_cmds: self.depsolver.basecmd = args[0] self.depsolver.extcmds = args[1:] res, msg = self.depsolver.doCommands() else: for nargs in args: self.depsolver.basecmd = nargs[0] self.depsolver.extcmds = nargs[1:] res, msg = self.depsolver.doCommands() if res != 2: return res, msg self.tsInfo = depsolver.tsInfo if res != 2: return res, msg res, msg = self.depsolver.buildTransaction() return self.res[res], msg