From e8f31464bdb79638dc28faa71a0211ce94b5db80 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Wed, 4 Mar 2020 15:36:33 -0800 Subject: [PATCH] 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 --- tests/pylorax/test_treebuilder.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/pylorax/test_treebuilder.py b/tests/pylorax/test_treebuilder.py index 0660ec1f..5b035f84 100644 --- a/tests/pylorax/test_treebuilder.py +++ b/tests/pylorax/test_treebuilder.py @@ -110,6 +110,9 @@ class InstallBrandingTestCase(unittest.TestCase): pkgs = self.install_branding(repo_dir) 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): """Test disabled branding""" 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) 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"])