Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_init_output_path_and_template(self):
reporter = Reporter(output_path="my-report.html")
assert reporter.output_path == "my-report.html"
assert reporter.template is None
def test_init_output_path_and_template(self):
reporter = Reporter(template="my_template.jinja")
assert reporter.output_path == "scanapi-report.html"
assert reporter.template == "my_template.jinja"
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")
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("html.jinja", context, False)
mocked__open.assert_called_once_with(
"scanapi-report.html", "w", newline="\n"
)
mocked__open().write.assert_called_once_with("ScanAPI Report")
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")
def test_init_output_path_and_template(self):
reporter = Reporter()
assert reporter.output_path == "scanapi-report.html"
assert reporter.template is None