Пример #1
0
def test_csv_results(fake_results, capfd):
    """Ensure CSV results print correctly."""

    formatting.csv_results(fake_results)
    stdout, _ = capfd.readouterr()
    assert "server,command,result" in stdout
    for server in fake_results:
        assert server["name"] in stdout
        for _, results in server["results"]:
            assert results in stdout
Пример #2
0
def test_csv_results(fake_results, capfd):
    """Ensure CSV results print correctly."""

    formatting.csv_results(fake_results)
    stdout, _ = capfd.readouterr()
    assert "server,command,result" in stdout
    for server in fake_results:
        assert server["name"] in stdout
        for _, results in server["results"]:
            assert results in stdout
Пример #3
0
    def test_csv_results(self):
        """Ensure CSV results print correctly."""

        formatting.csv_results(self.fake_results, {})
        stdout = sys.stdout.getvalue().strip()
        self.assertIn("server,command,result", stdout)
        for server in self.fake_results:
            self.assertIn(server["name"], stdout)
            for _, results in server["results"]:
                self.assertIn(results, stdout)
Пример #4
0
def test_csv_on_consolidated(fake_results, capfd):
    """CSV results should still work post consolidation."""

    result_set = formatting.consolidate(fake_results)
    formatting.csv_results(result_set, {})
    stdout, _ = capfd.readouterr()
    assert "server,command,result" in stdout
    for server in result_set:
        assert " ".join(server["names"]) in stdout
        for _, results in server["results"]:
            assert results in stdout
Пример #5
0
def test_csv_custom_char(fake_results, capfd):
    """Ensure you can specify the char used in csv_results."""

    options = {"csv_char": "@"}
    formatting.csv_results(fake_results, options)
    stdout, _ = capfd.readouterr()
    assert "server@command@result" in stdout
    for server in fake_results:
        assert server["name"] in stdout
        for _, results in server["results"]:
            assert results in stdout
Пример #6
0
def test_csv_on_consolidated(fake_results, capfd):
    """CSV results should still work post consolidation."""

    result_set = formatting.consolidate(fake_results)
    formatting.csv_results(result_set, {})
    stdout, _ = capfd.readouterr()
    assert "server,command,result" in stdout
    for server in result_set:
        assert " ".join(server["names"]) in stdout
        for _, results in server["results"]:
            assert results in stdout
Пример #7
0
def test_csv_custom_char(fake_results, capfd):
    """Ensure you can specify the char used in csv_results."""

    options = {"csv_char": "@"}
    formatting.csv_results(fake_results, options)
    stdout, _ = capfd.readouterr()
    assert "server@command@result" in stdout
    for server in fake_results:
        assert server["name"] in stdout
        for _, results in server["results"]:
            assert results in stdout
Пример #8
0
    def test_csv_on_consolidated(self):
        """CSV results should still work post consolidation."""

        result_set = formatting.consolidate(self.fake_results)
        formatting.csv_results(result_set, {})
        stdout = sys.stdout.getvalue().strip()
        self.assertIn("server,command,result", stdout)
        for server in result_set:
            self.assertIn(" ".join(server["names"]), stdout)
            for _, results in server["results"]:
                self.assertIn(results, stdout)
Пример #9
0
    def test_csv_custom_char(self):
        """Ensure you can specify the char used in csv_results."""

        options = {"csv_char": "@"}
        formatting.csv_results(self.fake_results, options)
        stdout = sys.stdout.getvalue().strip()
        self.assertIn("server@command@result", stdout)
        for server in self.fake_results:
            self.assertIn(server["name"], stdout)
            for _, results in server["results"]:
                self.assertIn(results, stdout)
Пример #10
0
def cmdline_exit(results, options):
    """A buffer for selecting the correct output function and exiting.

    Args::

        results: the results dictionary from Bladerunner.run
        options: the options dictionary, uses 'style' and 'stacked' keys
    """

    if options.get("stacked"):
        stacked_results(results, options)
    elif options["style"] < 0 or options["style"] > 3:
        csv_results(results, options)
    else:
        pretty_results(results, options)

    raise SystemExit
Пример #11
0
def cmdline_exit(results, options):
    """A buffer for selecting the correct output function and exiting.

    Args::

        results: the results dictionary from Bladerunner.run
        options: the options dictionary, uses 'style' and 'stacked' keys
    """

    if options.get("stacked"):
        stacked_results(results, options)
    elif options["style"] < 0 or options["style"] > 3:
        csv_results(results, options)
    else:
        pretty_results(results, options)

    raise SystemExit