summaryrefslogtreecommitdiffstats
path: root/src/software/test/common.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/software/test/common.py')
-rw-r--r--src/software/test/common.py34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/software/test/common.py b/src/software/test/common.py
index ef3d157..d91f236 100644
--- a/src/software/test/common.py
+++ b/src/software/test/common.py
@@ -43,11 +43,14 @@ def remove_pkg(pkg, *args):
pkg = pkg.name
call(["rpm", "--quiet"] + list(args) + ["-e", pkg])
-def install_pkg(pkg, newer=True):
+def install_pkg(pkg, newer=True, repolist=[]):
"""
Install a specific package.
@param pkg is either package name or instance of Package
In latter case, a specific version is installed.
+ @param repolist is a list of repositories, that should be
+ used for downloading, if using yum
+ when empty, all enabled repositories are used
"""
if isinstance(pkg, rpmcache.Package):
try:
@@ -57,7 +60,7 @@ def install_pkg(pkg, newer=True):
except rpmcache.MissingRPM:
pass
pkg = pkg.name
- call(["yum", "-q", "-y", "install", pkg])
+ rpmcache.run_yum('-q', '-y', 'install', pkg, repolist=repolist)
def is_installed(pkg, newer=True):
"""
@@ -148,6 +151,11 @@ class SoftwareBaseTestCase(unittest.TestCase): #pylint: disable=R0904
self.objpath = pywbem.CIMInstanceName(
namespace="root/cimv2", classname=self.CLASS_NAME)
+ def install_pkg(self, pkg, newer=True, repolist=None):
+ if repolist is None:
+ repolist = self.test_repos
+ return install_pkg(pkg, newer, repolist)
+
def assertIsSubclass(self, cls, base_cls): #pylint: disable=C0103
"""
Checks, whether cls is subclass of base_cls from CIM perspective.
@@ -161,6 +169,21 @@ class SoftwareBaseTestCase(unittest.TestCase): #pylint: disable=R0904
return self.assertTrue(pywbem.is_subclass(self.conn,
"root/cimv2", base_cls, cls))
+ def assertEqual(self, fst, snd, *args, **kwargs):
+ if ( isinstance(fst, pywbem.CIMInstanceName)
+ and isinstance(snd, pywbem.CIMInstanceName)
+ and fst.classname == "LMI_SoftwarePackage"
+ and fst.classname == snd.classname
+ and fst.namespace == snd.namespace
+ and fst.keys() == snd.keys()
+ and all(fst[k] == snd[k] for k in ("Name", "SoftwareElementID",
+ "SoftwareElementState", "Version"))
+ and isinstance(fst["TargetOperatingSystem"], (int, long))
+ and isinstance(snd["TargetOperatingSystem"], (int, long))):
+ return True
+ return unittest.TestCase.assertEqual(
+ self, fst, snd, *args, **kwargs)
+
@classmethod
def setUpClass(cls):
cls.url = os.environ.get('LMI_CIMOM_URL', 'http://localhost:5988')
@@ -170,6 +193,11 @@ class SoftwareBaseTestCase(unittest.TestCase): #pylint: disable=R0904
cls.conn = pywbem.WBEMConnection(cls.url, (cls.user, cls.password))
cls.run_dangerous = (
os.environ.get('LMI_RUN_DANGEROUS', '0') == '1')
+ cls.test_repos = os.environ.get('LMI_SOFTWARE_TEST_REPOS', '')
+ if not cls.test_repos:
+ cls.test_repos = []
+ else:
+ cls.test_repos = cls.test_repos.split(',')
use_cache = os.environ.get('LMI_SOFTWARE_USE_CACHE', '0') == '1'
cls.cache_dir = None
if use_cache:
@@ -185,7 +213,7 @@ class SoftwareBaseTestCase(unittest.TestCase): #pylint: disable=R0904
cls.pkgdb = rpmcache.get_pkg_database(use_cache=use_cache)
for pkg in cls.pkgdb:
if not is_installed(pkg.name):
- install_pkg(pkg)
+ install_pkg(pkg, repolist=cls.test_repos)
cls.pkg_files = dict((pkg.name, get_pkg_files(pkg))
for pkg in cls.pkgdb)