Esempio n. 1
0
def test_execute_with_absent_template(temp_dir, _command_args, patched_logger_critical):
    incorrect_path = os.path.join("absent_template_dir")
    _command_args['template'] = incorrect_path

    absent_template_instance = role.Role(_command_args)
    with pytest.raises(SystemExit) as e:
        absent_template_instance.execute()

    assert e.value.code == 1
    patched_logger_critical.assert_called_once()
Esempio n. 2
0
def test_execute_with_incorrect_template(temp_dir, invalid_template_dir,
                                         _command_args,
                                         patched_logger_critical):
    _command_args['template'] = invalid_template_dir

    invalid_template_instance = role.Role(_command_args)
    with pytest.raises(SystemExit) as e:
        invalid_template_instance.execute()

    assert e.value.code == 1
    patched_logger_critical.assert_called_once()
Esempio n. 3
0
def test_execute_with_custom_template(temp_dir, custom_template_dir,
                                      custom_readme_content, _command_args):
    _command_args['template'] = custom_template_dir

    custom_template_instance = role.Role(_command_args)
    custom_template_instance.execute()

    readme_path = './test-role/README.md'
    assert os.path.isfile(readme_path)
    with open(readme_path, 'r') as readme:
        assert readme.read() == custom_readme_content

    assert os.path.isdir('./test-role/molecule/default')
    assert os.path.isdir('./test-role/molecule/default/tests')
Esempio n. 4
0
def _instance(_command_args):
    return role.Role(_command_args)
Esempio n. 5
0
def role_instance(command_args):
    return role.Role(command_args)