Example #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
Example #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
Example #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)
Example #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
Example #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
Example #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
Example #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
Example #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)
Example #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)
Example #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
Example #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