コード例 #1
0
ファイル: test_formatting.py プロジェクト: a-tal/bladerunner
def test_results_max_length(fake_results, capfd):
    """Ensure the vertical alignment with multi line output commands."""

    fake_output = ["many", "lines", "of", "output"]
    fake_results.insert(
        0,
        {
            "name": "server_d_1",
            "results": [("obviously fake", "\n".join(fake_output))],
        }
    )
    results, options = formatting.prepare_results(
        fake_results,
        {"style": 1},
    )

    formatting._pretty_result(results[0], options, results)
    stdout, _ = capfd.readouterr()
    stdout = stdout.splitlines()

    # top line should be a space separators
    topline = str("{0}".format(options["chars"]["top"][options["style"]] * 10))
    assert topline in stdout[0]

    # then it should be the server name, separator and first line of cmd
    assert str("server_d_1") in stdout[1]
    assert options["chars"]["side"][options["style"]] in stdout[1]

    # then the multi line command should fill down the right column
    for line, fake_out in enumerate(fake_output, 1):
        assert str(fake_out) in stdout[line]

    # finally check total length
    assert len(stdout) == 5
コード例 #2
0
def test_results_max_length(fake_results, capfd):
    """Ensure the vertical alignment with multi line output commands."""

    fake_output = ["many", "lines", "of", "output"]
    fake_results.insert(
        0, {
            "name": "server_d_1",
            "results": [("obviously fake", "\n".join(fake_output))],
        })
    results, options = formatting.prepare_results(
        fake_results,
        {"style": 1},
    )

    formatting._pretty_result(results[0], options, results)
    stdout, _ = capfd.readouterr()
    stdout = stdout.splitlines()

    # top line should be a space separators
    topline = str("{0}".format(options["chars"]["top"][options["style"]] * 10))
    assert topline in stdout[0]

    # then it should be the server name, separator and first line of cmd
    assert str("server_d_1") in stdout[1]
    assert options["chars"]["side"][options["style"]] in stdout[1]

    # then the multi line command should fill down the right column
    for line, fake_out in enumerate(fake_output, 1):
        assert str(fake_out) in stdout[line]

    # finally check total length
    assert len(stdout) == 5
コード例 #3
0
ファイル: test_formatting.py プロジェクト: a-tal/bladerunner
def test_pretty_result(fake_results, capfd):
    """Ensure pretty results are correctly printed."""

    results, options = formatting.prepare_results(fake_results)

    formatting._pretty_result(results[0], options, results)

    stdout, _ = capfd.readouterr()

    for server in results[0]["names"]:
        assert str(server) in stdout
    for _, result in results[0]["results"]:
        assert str(result) in stdout
コード例 #4
0
def test_pretty_result(fake_results, capfd):
    """Ensure pretty results are correctly printed."""

    results, options = formatting.prepare_results(fake_results)

    formatting._pretty_result(results[0], options, results)

    stdout, _ = capfd.readouterr()

    for server in results[0]["names"]:
        assert str(server) in stdout
    for _, result in results[0]["results"]:
        assert str(result) in stdout
コード例 #5
0
ファイル: test_formatting.py プロジェクト: a-tal/bladerunner
def test_bottom_up_in_first_result(fake_results, capfd):
    """The first result when using a jumpbox should have a bot_up char."""

    results, options = formatting.prepare_results(
        fake_results,
        {"jump_host": "some_server", "style": 1},
    )

    formatting._pretty_result(results[0], options, results)

    stdout, _ = capfd.readouterr()

    for server in results[0]["names"]:
        assert str(server) in stdout
    for _, result in results[0]["results"]:
        assert str(result) in stdout

    assert options["chars"]["bot_up"][options["style"]] in stdout
コード例 #6
0
def test_bottom_up_in_first_result(fake_results, capfd):
    """The first result when using a jumpbox should have a bot_up char."""

    results, options = formatting.prepare_results(
        fake_results,
        {
            "jump_host": "some_server",
            "style": 1
        },
    )

    formatting._pretty_result(results[0], options, results)

    stdout, _ = capfd.readouterr()

    for server in results[0]["names"]:
        assert str(server) in stdout
    for _, result in results[0]["results"]:
        assert str(result) in stdout

    assert options["chars"]["bot_up"][options["style"]] in stdout