def write(self, results): """Part of the Reporter instance that is responsible for writing scanapi-report.html. Args: results [generator]: generator of dicts resulting of Request run(). Returns: None """ logger.info("Writing documentation") template_path = self.template if self.template else "report.html" has_external_template = bool(self.template) context = self._build_context(results) content = render(template_path, context, has_external_template) with open(self.output_path, "w", newline="\n") as doc: doc.write(content) logger.info("\nThe documentation was generated successfully.") logger.info( f"It is available at {self.output_path.resolve().as_uri()}")
def write(self, results): logger.info("Writing documentation") template_path = self.template if self.template else "html.jinja" has_external_template = True if self.template else False context = self._build_context(results) content = render(template_path, context, has_external_template) with open(self.output_path, "w", newline="\n") as doc: doc.write(content) logger.info("\nThe documentation was generated successfully.") logger.info(f"It is available at {self.output_path}")
def write(self, results): """Part of the Reporter instance that is responsible for writing scanapi-report.html.""" logger.info("Writing documentation") template_path = self.template if self.template else "report.html" has_external_template = True if self.template else False context = self._build_context(results) content = render(template_path, context, has_external_template) with open(self.output_path, "w", newline="\n") as doc: doc.write(content) logger.info("\nThe documentation was generated successfully.") logger.info(f"It is available at {abspath(self.output_path)}")
def write(self, results, open_in_browser): """Part of the Reporter instance that is responsible for writing scanapi-report.html. Args: results [generator]: generator of dicts resulting of Request run(). Returns: None """ template_path = self.template if self.template else "report.html" has_external_template = bool(self.template) context = self._build_context(results) content = render(template_path, context, has_external_template) with open(self.output_path, "w", newline="\n") as doc: doc.write(content) write_report_path(self.output_path.resolve().as_uri()) if open_in_browser: self._open_in_browser()
def test_should_call_jinja_render(self, mocked__get_template): context = {"my_context": "foo"} render("my_template.jinja", context) mocked__get_template.assert_called_once_with("my_template.jinja") mocked__get_template().render.assert_called_once_with(**context)