Changeset - ec01c5579795
[Not reviewed]
0 1 0
Branko Majic (branko) - 2 months ago 2024-02-10 13:51:52
branko@majic.rs
MAR-191: Refactor preseed test to use dynamic inventory instead of hard-coded release names.
1 file changed with 10 insertions and 14 deletions:
0 comments (0 inline, 0 general)
roles/preseed/molecule/default/tests/test_parameters_optional_with_overrides.py
Show inline comments
 
@@ -8,18 +8,19 @@ import testinfra.utils.ansible_runner
 
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
 
    os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('parameters-optional-with-overrides')
 

	
 
parameters_mandatory_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
 
    os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('parameters-mandatory')
 

	
 
@pytest.mark.parametrize("distribution_release", [
 
    "buster",
 
    "bullseye"
 
])
 
def test_preseed_configuration_file_content_host_without_overrides(host, distribution_release):
 
parameters_optional_with_overrides_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
 
    os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('parameters-optional-with-overrides')
 

	
 

	
 
@pytest.mark.parametrize("hostname", parameters_mandatory_hosts)
 
def test_preseed_configuration_file_content_host_without_overrides(host, hostname):
 
    """
 
    Tests content of generated preseed configuration file.
 
    """
 

	
 
    hostname = 'parameters-mandatory-%s' % distribution_release
 

	
 
    with host.sudo():
 
        preseed_file = host.file(os.path.join("/tmp/preseed_files", "%s.cfg" % hostname))
 
        preseed_file_content = preseed_file.content_string
 
@@ -45,17 +46,12 @@ d-i netcfg/get_domain string ignored-value""" in preseed_file_content
 
    assert ssh_public_key in preseed_file_content
 

	
 

	
 
@pytest.mark.parametrize("distribution_release", [
 
    "buster",
 
    "bullseye"
 
])
 
def test_preseed_configuration_file_content_host_with_overrides(host, distribution_release):
 
@pytest.mark.parametrize("hostname", parameters_optional_with_overrides_hosts)
 
def test_preseed_configuration_file_content_host_with_overrides(host, hostname):
 
    """
 
    Tests content of generated preseed configuration file.
 
    """
 

	
 
    hostname = 'parameters-optional-with-overrides-%s' % distribution_release
 

	
 
    with host.sudo():
 
        preseed_file = host.file(os.path.join("/tmp/preseed_files", "%s.cfg" % hostname))
 
        preseed_file_content = preseed_file.content_string
0 comments (0 inline, 0 general)