示例#1
0
    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()}")
示例#2
0
    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}")
示例#3
0
    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)}")
示例#4
0
    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()
示例#5
0
        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)