summaryrefslogtreecommitdiffstats
path: root/src/software
diff options
context:
space:
mode:
authorMichal Minar <miminar@redhat.com>2013-11-30 14:54:08 +0100
committerMichal Minar <miminar@redhat.com>2013-12-02 12:30:30 +0100
commit0917b987cb33b72178a76b3394bc78db22ce4427 (patch)
tree277b9ce0e6932c1c4bc770fc3de7109eafc7a2c5 /src/software
parentdc283cceaf1c09721fe67fce229aeeb3efa20390 (diff)
downloadopenlmi-providers-0917b987cb33b72178a76b3394bc78db22ce4427.tar.gz
openlmi-providers-0917b987cb33b72178a76b3394bc78db22ce4427.tar.xz
openlmi-providers-0917b987cb33b72178a76b3394bc78db22ce4427.zip
software: minor test enhancements
Added one test to SoftwareIdentityFileCheck.Invoke() method testing correct error code. Renamed testing package pkg1 to pkg2 in misc repository to match its comment. Rendering function CIMInstanceNames should behave nicely for objects of another type and return their text representation.
Diffstat (limited to 'src/software')
-rw-r--r--src/software/test/reposetup.py7
-rw-r--r--src/software/test/repository.py5
-rw-r--r--src/software/test/test_installed_software_identity.py4
-rw-r--r--src/software/test/test_software_identity_file_check.py15
-rw-r--r--src/software/test/test_software_installation_service_affects_element.py2
-rw-r--r--src/software/test/util.py2
6 files changed, 27 insertions, 8 deletions
diff --git a/src/software/test/reposetup.py b/src/software/test/reposetup.py
index 93f4429..446737c 100644
--- a/src/software/test/reposetup.py
+++ b/src/software/test/reposetup.py
@@ -188,8 +188,9 @@ REPOS = {
'openlmi-sw-test-pkg1 = 1.2.3-1%(disttag)s',
'openlmi-sw-test-pkg2 = 2:1.2.2-1%(disttag)s']
},
- # same package as pkg2 except for arch and shared directory
- 'openlmi-sw-test-pkg1-0:1.2.3-1%(disttag)s.%(basearch)s' : {
+ # same package as stable#pkg2 except for arch and shared
+ # directory
+ 'openlmi-sw-test-pkg2-1:1.2.3-1%(disttag)s.%(basearch)s' : {
'files' : {
'usr/share/openlmi-sw-test-pkg2-arch/' :
PKG_FILE_ENTRIES['pkg2'].values()[0]
@@ -465,7 +466,7 @@ def _build_pkg(rpmbuild_dir, pkg_nevra, pkg_dict):
"release" : match.group('rel'),
"pkg_arch" : match.group('arch')
}
- if match.group('arch') == 'noarch':
+ if match.group('arch') != get_yum_config().basearch:
spec_args['arch_string'] = 'BuildArch: %s\n' % match.group('arch')
else:
spec_args['arch_string'] = ''
diff --git a/src/software/test/repository.py b/src/software/test/repository.py
index d963d43..cf80385 100644
--- a/src/software/test/repository.py
+++ b/src/software/test/repository.py
@@ -30,6 +30,8 @@ import os
import re
from subprocess import call, check_output
+import util
+
RE_REPO_TAG = re.compile(
ur'^repo-(?P<tag>[a-z_-]+)[\s\u00a0]*:'
ur'[\s\u00a0]*(?P<value>.*?)[\s\u00a0]*$', re.I | re.U | re.M)
@@ -384,6 +386,5 @@ def set_repo_enabled(repo, enable):
if isinstance(repo, Repository):
repo = repo.repoid
cmd = ["yum-config-manager", "--enable" if enable else "--disable", repo]
- with open('/dev/null', 'w') as out:
- call(cmd, stdout=out, stderr=out)
+ call(cmd, stdout=util.DEV_NULL, stderr=util.DEV_NULL)
diff --git a/src/software/test/test_installed_software_identity.py b/src/software/test/test_installed_software_identity.py
index 3535294..12aa2e8 100644
--- a/src/software/test/test_installed_software_identity.py
+++ b/src/software/test/test_installed_software_identity.py
@@ -107,7 +107,7 @@ class TestInstalledSoftwareIdentity(swbase.SwTestCase):
'misc#conflict2' : False,
'misc#depend1' : False,
'misc#depend2' : False,
- 'misc#pkg1' : False,
+ 'misc#pkg2' : False,
'misc#funny-version' : True,
'misc#funny-release' : True,
})
@@ -150,7 +150,7 @@ class TestInstalledSoftwareIdentity(swbase.SwTestCase):
'misc#conflict2' : False,
'misc#depend1' : False,
'misc#depend2' : False,
- 'misc#pkg1' : False,
+ 'misc#pkg2' : False,
'misc#funny-version' : True,
'misc#funny-release' : True,
})
diff --git a/src/software/test/test_software_identity_file_check.py b/src/software/test/test_software_identity_file_check.py
index 4783076..10db11f 100644
--- a/src/software/test/test_software_identity_file_check.py
+++ b/src/software/test/test_software_identity_file_check.py
@@ -637,6 +637,21 @@ class TestSoftwareIdentityFileCheck(swbase.SwTestCase):
inst.refresh()
self.assertEqual(set(inst.FailedFlags), set([FAILED_FLAGS_MTIME]))
+ @enable_lmi_exceptions
+ @swbase.test_with_packages('stable#pkg1')
+ def test_method_invoke_on_uninstalled_package(self):
+ """
+ Test ``Invoke`` method of ``LMI_SoftwareIdentityFileCheck`` on
+ uninstalled package.
+ """
+ pkg = self.get_repo('stable')['pkg1']
+ fp = '/usr/share/openlmi-sw-test-pkg1/README'
+ objpath = self.make_op(pkg, fp)
+ inst = objpath.to_instance()
+ self.assertNotEqual(inst, None)
+ package.remove_pkg(pkg.name)
+ self.assertRaisesCIM(pywbem.CIM_ERR_NOT_FOUND, inst.Invoke)
+
@swbase.test_with_packages('stable#pkg2')
def test_method_invoke_on_symlink(self):
"""
diff --git a/src/software/test/test_software_installation_service_affects_element.py b/src/software/test/test_software_installation_service_affects_element.py
index 0ac1514..4eedbe5 100644
--- a/src/software/test/test_software_installation_service_affects_element.py
+++ b/src/software/test/test_software_installation_service_affects_element.py
@@ -92,7 +92,7 @@ class TestSoftwareInstallationServiceAffectsElement(swbase.SwTestCase):
@swbase.test_with_repos(misc=False)
@swbase.test_with_packages(**{
- 'misc#pkg1' : True,
+ 'misc#pkg2' : True,
})
def test_get_instance_with_not_available_package(self):
"""
diff --git a/src/software/test/util.py b/src/software/test/util.py
index 3c63be0..be82c6e 100644
--- a/src/software/test/util.py
+++ b/src/software/test/util.py
@@ -40,6 +40,8 @@ RE_ENVRA = re.compile(
RE_REPO = re.compile(
r'(?:^\*?)(?P<name>[^\s/]+\b)(?!\s+id)', re.MULTILINE | re.IGNORECASE)
+DEV_NULL = open('/dev/null', 'w')
+
def make_nevra(name, epoch, ver, rel, arch, with_epoch='NOT_ZERO'):
"""
@param with_epoch may be one of: