From 014d6b574cb62d67d1490e2de47e5591d17bc0ba Mon Sep 17 00:00:00 2001 From: Michal Minar Date: Sun, 15 Dec 2013 11:04:06 +0100 Subject: software: test fixes and improvements Fixed package installation tests that did not ensure that particular package is uninstalled before test begins. Speeded up test set up phase for TestSoftwareIdentityFileChecks and TestSoftwareIdentityChecks. (cherry picked from commit 44c28b2baeb7a99bfd8734e7f7c4f53444e56c04) --- src/software/test/test_software_identity_checks.py | 9 +++++---- src/software/test/test_software_identity_file_check.py | 5 ++--- src/software/test/test_software_installation_service.py | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/software/test/test_software_identity_checks.py b/src/software/test/test_software_identity_checks.py index c29fa47..8a8761d 100644 --- a/src/software/test/test_software_identity_checks.py +++ b/src/software/test/test_software_identity_checks.py @@ -66,9 +66,8 @@ class TestSoftwareIdentityChecks(swbase.SwTestCase): for repo in self.repodb.values(): for pkg in repo.packages: to_uninstall.add(pkg.name) - to_uninstall = [p for p in to_uninstall if package.is_pkg_installed(p)] - if to_uninstall: - subprocess.call(['/usr/bin/rpm', '--quiet', '-e'] + to_uninstall) + to_uninstall = list(package.filter_installed_packages(to_uninstall)) + package.remove_pkgs(to_uninstall) @swbase.test_with_packages('stable#pkg1') def test_get_instance(self): @@ -136,7 +135,9 @@ class TestSoftwareIdentityChecks(swbase.SwTestCase): "TargetOperatingSystem", "Version"]) self.assertEqual(ref.SoftwareElementID, pkg.nevra) self.assertIn(ref.Name, pkg_names) - self.assertEqual(ref.FailedFlags, []) + self.assertEqual(ref.FailedFlags, [], + "FailedFlags are empty for unmodified file %s:%s" + % (pkg, filepath)) pkg_names.remove(ref.Name) self.assertEqual(len(pkg_names), 0) diff --git a/src/software/test/test_software_identity_file_check.py b/src/software/test/test_software_identity_file_check.py index bb2a933..c1fb77b 100644 --- a/src/software/test/test_software_identity_file_check.py +++ b/src/software/test/test_software_identity_file_check.py @@ -125,9 +125,8 @@ class TestSoftwareIdentityFileCheck(swbase.SwTestCase): for repo in self.repodb.values(): for pkg in repo.packages: to_uninstall.add(pkg.name) - to_uninstall = [p for p in to_uninstall if package.is_pkg_installed(p)] - if to_uninstall: - subprocess.call(['/usr/bin/rpm', '--quiet', '-e'] + to_uninstall) + to_uninstall = list(package.filter_installed_packages(to_uninstall)) + package.remove_pkgs(to_uninstall) def do_check_symlink(self, pkg, filepath, inst): """ diff --git a/src/software/test/test_software_installation_service.py b/src/software/test/test_software_installation_service.py index c01d9dd..eb38f0c 100644 --- a/src/software/test/test_software_installation_service.py +++ b/src/software/test/test_software_installation_service.py @@ -328,7 +328,7 @@ class TestSoftwareInstallationService(swbase.SwTestCase): self.assertTrue(inames[0].InstanceID.endswith(pkg.nevra)) @swbase.test_with_repos('stable') - @swbase.test_with_packages(**{ 'stable#pkg1' : False }) + @swbase.test_with_packages(**{ 'pkg1' : False }) def test_install_package_sync(self): """ Try to synchronously install package. @@ -384,7 +384,7 @@ class TestSoftwareInstallationService(swbase.SwTestCase): @enable_lmi_exceptions @swbase.test_with_repos('stable') - @swbase.test_with_packages(**{ 'stable#pkg1' : False }) + @swbase.test_with_packages(**{ 'pkg1' : False }) def test_install_method_sync_without_target_and_collection(self): """ Try to synchronously install package without target and collection @@ -409,7 +409,7 @@ class TestSoftwareInstallationService(swbase.SwTestCase): or ('Job' in oparms and oparms['Job'] is None)) @swbase.test_with_repos('stable') - @swbase.test_with_packages(**{ 'stable#pkg1' : False }) + @swbase.test_with_packages(**{ 'pkg1' : False }) def test_install_package_sync_with_target_and_collection(self): """ Try to synchronously install package with target and collection @@ -439,7 +439,7 @@ class TestSoftwareInstallationService(swbase.SwTestCase): or ('Job' in oparms and oparms['Job'] is None)) @swbase.test_with_repos('stable') - @swbase.test_with_packages(**{ 'stable#pkg1' : False }) + @swbase.test_with_packages(**{ 'pkg1' : False }) def test_install_package_sync_with_collection(self): """ Try to synchronously install package with just collection given. -- cgit