tests: Add tests for variant branding detection

This adds tests to make sure that the changes to _install_branding are
working as expected with or without variants.

Related: rhbz#1826479
This commit is contained in:
Brian C. Lane 2020-03-04 15:36:33 -08:00
parent 3613c12464
commit e8f31464bd

View File

@ -110,6 +110,9 @@ class InstallBrandingTestCase(unittest.TestCase):
pkgs = self.install_branding(repo_dir) pkgs = self.install_branding(repo_dir)
self.assertEqual(pkgs, ["redhat-logos", "redhat-release"]) self.assertEqual(pkgs, ["redhat-logos", "redhat-release"])
# Test with a variant set, but not available
pkgs = self.install_branding(repo_dir, variant="workstation")
def test_skip_branding(self): def test_skip_branding(self):
"""Test disabled branding""" """Test disabled branding"""
with tempfile.TemporaryDirectory(prefix="lorax.test.repo.") as repo_dir: with tempfile.TemporaryDirectory(prefix="lorax.test.repo.") as repo_dir:
@ -119,3 +122,24 @@ class InstallBrandingTestCase(unittest.TestCase):
pkgs = self.install_branding(repo_dir, skip_branding=True) pkgs = self.install_branding(repo_dir, skip_branding=True)
self.assertEqual(pkgs, []) self.assertEqual(pkgs, [])
def test_three_pkgs(self):
"""Test with a repo with generic-release, redhat-release, redhat-release-workstation package"""
# Three system-release packages, one with a variant suffix
with tempfile.TemporaryDirectory(prefix="lorax.test.repo.") as repo_dir:
makeFakeRPM(repo_dir, "generic-release", 0, "33", "1", ["/etc/system-release"], ["system-release"])
makeFakeRPM(repo_dir, "redhat-release", 0, "33", "1", ["/etc/system-release"], ["system-release"])
makeFakeRPM(repo_dir, "redhat-logos", 0, "33", "1")
makeFakeRPM(repo_dir, "redhat-release-workstation", 0, "33", "1", ["/etc/system-release"], ["system-release"])
os.system("createrepo_c " + repo_dir)
pkgs = self.install_branding(repo_dir)
self.assertEqual(pkgs, ["redhat-logos", "redhat-release"])
# Test with a variant set
pkgs = self.install_branding(repo_dir, variant="workstation")
self.assertEqual(pkgs, ["redhat-logos", "redhat-release-workstation"])
# Test with a variant set, but not available
pkgs = self.install_branding(repo_dir, variant="server")
self.assertEqual(pkgs, ["redhat-logos", "redhat-release"])