testbase.save_ts(*args, **kwargs)


class testbase.FakeConf

Bases: object


class testbase.FakeSack

Fake PackageSack to use with FakeRepository


class testbase.FakeRepo(id=None, sack=None)

Bases: object


class testbase.FakeYumDBInfo(conf=None, pkgdir=None, yumdb_cache=None)

Bases: object

Simulate some functionality of RPMAdditionalDataPackage


class testbase.FakePackage(name, version='1.0', release='1', epoch='0', arch='noarch', repo=None)

Bases: yum.packages.YumAvailablePackage


class testbase._Container

Bases: object


class testbase.DepSolveProgressCallBack

provides text output callback functions for Dependency Solver callback


class testbase._DepsolveTestsBase(methodName='runTest')

Bases: unittest.case.TestCase

assertResult(pkgs, optional_pkgs=[])

Check if “system” contains the given pkgs. pkgs must be present, optional_pkgs may be. Any other pkgs result in an error. Pkgs are present if they are in the rpmdb and are not REMOVEd or they are INSTALLed.

static buildPkgs(pkgs, *args)

Overload this staticmethod to create pkpgs that are used in several test cases. It gets called from __init__ with self.pkgs as first parameter. It is a staticmethod so you can call .buildPkgs() from other Tests to share buildPkg code (inheritance doesn’t work here, because we don’t want to inherit the test cases, too).


class testbase.FakeRpmDb

Bases: yum.packageSack.PackageSack

We use a PackagePack for a Fake rpmdb insted of the normal RPMDBPackageSack, getProvides works a little different on unversioned requirements so we have to overload an add some extra checkcode.

getProvides(name, flags=None, version=(None, None, None))

return dict { packages -> list of matching provides }


class testbase.DepsolveTests(methodName='runTest')

Bases: testbase._DepsolveTestsBase

Run depsolver on an manually set up transaction. You can add pkgs to self.rpmdb or self.tsInfo. See yum/transactioninfo.py for details. A typical test case looks like:

def testInstallPackageRequireInstalled(self):

po = FakePackage(‘zsh’, ‘1’, ‘1’, None, ‘i386’) po.addRequires(‘zip’, ‘EQ’, (None, ‘1.3’, ‘2’)) self.tsInfo.addInstall(po)

ipo = FakePackage(‘zip’, ‘1.3’, ‘2’, None, ‘i386’) self.rpmdb.addPackage(ipo)

result, msg = self.resolveCode() self.assertEquals(‘ok’, result, msg) self.assertResult((po, ipo))


Called at the start of each test.


class testbase.OperationsTests(methodName='runTest')

Bases: testbase._DepsolveTestsBase

Run a yum command (install, update, remove, ...) in a given set of installed and available pkgs. Typical test case looks like:

def testUpdate(self):
p = self.pkgs res, msg = self.runOperation([‘update’], [p.installed], [p.update]) self.assert_(res==’ok’, msg) self.assertResult((p.update,))

To avoid creating the same pkgs over and over again overload the staticmethod buildPkgs. It gets called from __init__ with self.pkgs as first parameter. As it is a static method you can call .buildPkgs() from other Tests to share buildPkg code.

runOperation(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.

Table Of Contents

Previous topic


Next topic


This Page