Changeset - df804f3e9b89
[Not reviewed]
0 2 0
Branko Majic (branko) - 4 years ago 2020-01-07 00:12:30
branko@majic.rs
MAR-148: Fixed tests for the preseed role:

- A couple of newline-related fixes (where command output now contains
them as compared to previous versions of Testinfra).
- Update path for the default inventory location.
2 files changed with 9 insertions and 5 deletions:
0 comments (0 inline, 0 general)
roles/preseed/molecule/default/tests/test_parameters_mandatory.py
Show inline comments
 
@@ -15,7 +15,11 @@ def test_preseed_directory(host):
 
    with host.sudo():
 

	
 
        # Preseed directory created at same level as inventory.
 
        preseed_directory = host.file(os.path.join('/tmp/molecule/preseed/default', 'preseed_files'))
 
        # @TODO: At this point, this path is getting uglier and
 
        #        uglier. It might be actually better to make the
 
        #        preseed_directory a mandatory parameter instead. Same
 
        #        goes for the ansible_key role parameter as well.
 
        preseed_directory = host.file(os.path.join('/tmp/molecule/preseed/default/inventory', 'preseed_files'))
 

	
 
        assert preseed_directory.is_directory
 
        assert preseed_directory.mode == 0o750
 
@@ -29,7 +33,7 @@ def test_preseed_configuration_files(host):
 
    with host.sudo():
 

	
 
        # Preseed directory created at same level as inventory.
 
        preseed_directory_path = os.path.join('/tmp/molecule/preseed/default', 'preseed_files')
 
        preseed_directory_path = os.path.join('/tmp/molecule/preseed/default/inventory', 'preseed_files')
 

	
 
        # Verify that preseed configuration files are created for all hosts.
 
        for testinfra_host in testinfra_hosts:
 
@@ -45,10 +49,10 @@ def test_preseed_configuration_file_content(host):
 
    Tests content of generated preseed configuration file.
 
    """
 

	
 
    hostname = host.run('hostname').stdout
 
    hostname = host.run('hostname').stdout.strip()
 

	
 
    with host.sudo():
 
        preseed_file = host.file(os.path.join("/tmp/molecule/preseed/default", "preseed_files", "%s.cfg" % hostname))
 
        preseed_file = host.file(os.path.join("/tmp/molecule/preseed/default/inventory", "preseed_files", "%s.cfg" % hostname))
 
        preseed_file_content = preseed_file.content_string
 
        ssh_public_key = open(os.path.join(os.path.expanduser("~"), ".ssh", "id_rsa.pub")).read().strip()
 

	
roles/preseed/molecule/default/tests/test_parameters_optional.py
Show inline comments
 
@@ -44,7 +44,7 @@ def test_preseed_configuration_file_content(host):
 
    Tests content of generated preseed configuration file.
 
    """
 

	
 
    hostname = host.run('hostname').stdout
 
    hostname = host.run('hostname').stdout.strip()
 

	
 
    with host.sudo():
 
        preseed_file = host.file(os.path.join(PRESEED_DIRECTORY, "%s.cfg" % hostname))
0 comments (0 inline, 0 general)