Add centos9/rhel9 support for tripleo-get-hash

Updates the get-hash constants to allow centos9 and rhel9 as valid
choices for the os-version parameter. Adds a new test case that
tests all the valid values.

Change-Id: I93af3f7bd0b536cb3b3131b5a9d03a5c5b9731b6
This commit is contained in:
Marios Andreou 2021-10-12 13:55:51 +03:00
parent de3736a739
commit ad2e89e613
4 changed files with 36 additions and 1 deletions

View File

@ -45,4 +45,6 @@ rdo_named_tags:
os_versions:
- centos7
- centos8
- centos9
- rhel8
- rhel9

View File

@ -80,6 +80,8 @@ DEFAULT_CONFIG = {
"os_versions": [
"centos7",
"centos8",
"rhel8"
"centos9",
"rhel8",
"rhel9"
]
}

View File

@ -107,6 +107,8 @@ rdo_named_tags:
os_versions:
- centos7
- centos8
- centos9
- rhel8
- rhel9
"""

View File

@ -123,6 +123,35 @@ class TestGetHash(unittest.TestCase):
sys.argv[1:] = args
self.assertRaises(exc.TripleOHashInvalidParameter, lambda: tgh.main())
def test_valid_os_version(self, mock_config):
config_file = open("fake_config_file") # open is mocked at class level
config_yaml = yaml.safe_load(config_file.read())
config_file.close()
# interate for each supported os_version
for os_v in config_yaml['os_versions']:
if '7' in os_v:
mocked = MagicMock(
return_value=(test_fakes.TEST_COMMIT_YAML_CENTOS_7, 200))
expected_url = (
"https://trunk.rdoproject.org/{}-master/"
"current-tripleo/commit.yaml".format(os_v)
)
else:
mocked = MagicMock(
return_value=(test_fakes.TEST_REPO_MD5, 200))
expected_url = (
"https://trunk.rdoproject.org/{}-master/"
"current-tripleo/delorean.repo.md5".format(os_v)
)
with patch(
'tripleo_repos.get_hash.tripleo_hash_info.http_get',
mocked):
args = ['--os-version', "{}".format(os_v)]
sys.argv[1:] = args
main_res = tgh.main()
self.assertEqual(main_res.dlrn_url, expected_url)
self.assertEqual("{}".format(os_v), main_res.os_version)
def test_invalid_os_version(self, mock_config):
args = ['--os-version', 'rhelos99', '--component', 'tripleo']
sys.argv[1:] = args