Пример #1
0
    def test_should_write_to_default_output(
        self,
        mocker,
        mocked__render,
        mocked__open,
        mocked__session,
        context,
    ):
        mocked__render.return_value = "ScanAPI Report"
        reporter = Reporter()
        reporter.write(fake_results)

        mocked__render.assert_called_once_with("report.html", context, False)
        mocked__open.assert_called_once_with("scanapi-report.html",
                                             "w",
                                             newline="\n")
        mocked__open().write.assert_called_once_with("ScanAPI Report")
Пример #2
0
    def test_should_write_to_custom_output(
        self,
        mocker,
        mocked__render,
        mocked__open,
        mocked__session,
        context,
    ):
        mocked__render.return_value = "ScanAPI Report"
        reporter = Reporter("./custom/report-output.html", "html")
        reporter.write(fake_results)

        mocked__render.assert_called_once_with("html", context, True)
        mocked__open.assert_called_once_with("./custom/report-output.html",
                                             "w",
                                             newline="\n")
        mocked__open().write.assert_called_once_with("ScanAPI Report")
Пример #3
0
        def test_should_handle_custom_templates(
            self,
            mocker,
            mocked__render,
            mocked__open,
            mocked__session,
            context,
        ):
            mocked__render.return_value = "ScanAPI Report"
            reporter = Reporter(template="my-template.html")
            reporter.write(fake_results)

            mocked__render.assert_called_once_with("my-template.html", context,
                                                   True)
            mocked__open.assert_called_once_with("scanapi-report.html",
                                                 "w",
                                                 newline="\n")
            mocked__open().write.assert_called_once_with("ScanAPI Report")
Пример #4
0
def write_report(results):
    reporter = Reporter(settings["output_path"], settings["template"])
    reporter.write(results)
Пример #5
0
def write_report(results):
    """ Constructs a Reporter object and calls the write method of Reporter to push
    the results to a file.
    """
    reporter = Reporter(settings["output_path"], settings["template"])
    reporter.write(results)