Beispiel #1
0
def test_execute_with_absent_custom_template(temp_dir, _command_args,
                                             patched_logger_critical):
    _command_args['driver_template'] = "absent_template_dir"

    absent_template_instance = scenario.Scenario(_command_args)
    with pytest.raises(SystemExit) as e:
        absent_template_instance.execute()

    assert e.value.code == 1
    patched_logger_critical.assert_called_once()
def test_execute_with_incorrect_template(temp_dir, invalid_template_dir,
                                         _command_args,
                                         patched_logger_critical):
    _command_args["driver_template"] = invalid_template_dir

    invalid_template_instance = scenario.Scenario(_command_args)
    with pytest.raises(SystemExit) as e:
        invalid_template_instance.execute()

    assert e.value.code == 1
    patched_logger_critical.assert_called_once()
def test_execute_with_custom_template(temp_dir, custom_template_dir,
                                      custom_readme_content, _command_args):
    _command_args["driver_template"] = custom_template_dir

    custom_template_instance = scenario.Scenario(_command_args)
    custom_template_instance.execute()

    assert os.path.isdir("./molecule/test-scenario")

    readme_path = "./molecule/test-scenario/README.md"
    assert os.path.isfile(readme_path)
    with open(readme_path, "r") as readme:
        assert readme.read() == custom_readme_content
Beispiel #4
0
def test_execute_with_absent_driver_in_custom_template(temp_dir, _command_args,
                                                       custom_template_dir,
                                                       patched_logger_warn):
    _command_args['driver_name'] = 'ec2'
    _command_args['driver_template'] = custom_template_dir

    absent_driver_instance = scenario.Scenario(_command_args)
    absent_driver_instance.execute()

    patched_logger_warn.assert_called_once_with(
        "Driver not found in custom template directory"
        "({driver_template}/{driver_name}), "
        "using the default template instead".format(**_command_args))

    assert os.path.isdir('./molecule/test-scenario')
    assert os.path.isdir('./molecule/test-scenario/tests')

    install_file = os.path.join(temp_dir.strpath, 'molecule', 'test-scenario',
                                'INSTALL.rst')
    with open(install_file) as f:
        content = f.read()
        assert "Amazon Web Services driver installation guide" in content
Beispiel #5
0
def _instance(_command_args):
    return scenario.Scenario(_command_args)
Beispiel #6
0
def scenario_instance(command_args):
    return scenario.Scenario(command_args)