Example #1
0
    def _run_test(callback=None):
        """Shim for gen.engine with pytest."""

        runner = Bladerunner(settings)
        results = yield gen.Task(
            runner.run_threaded,
            "echo 'hello world'",
            settings["host"],
        )
        parse_for_success(results)
        if callback:
            callback()
Example #2
0
def test_get_run_thread(settings):
    """Confirm that the run_threaded method returns instantly."""

    runner = Bladerunner(settings)
    start_time = time.time()
    thread = runner.run_threaded(
        "echo 'hello world'",
        settings["host"],
        callback=parse_results,
    )
    assert time.time() - start_time < 2
    thread.join()
Example #3
0
def test_get_help_contents(option_mismatches, capfd):
    """Check the contents of --help includes all options."""

    sys.argv.append("--help")
    dummy_runner = Bladerunner()

    with pytest.raises(SystemExit):
        cmdline_entry()

    # help is printed to stdout
    message, _ = capfd.readouterr()

    for option in dummy_runner.options:
        if option in option_mismatches:
            option_key = option_mismatches[option]
        else:
            option_key = option

        assert option_key.replace("_", "-") in message
Example #4
0
def test_unknown_host_errors(settings):
    """test logging into an unknown host results in an error."""

    runner = Bladerunner(settings)
    results = runner.run("echo 'hi'", "xyz1234.qwertasdfzxcvpoiu.12awol")
    parse_for_failure(results)