Esempio n. 1
0
    def test_jinjanize_01(self):
        """Renders a template which does not contains any variable."""
        # Prepare the test template
        template_str = "Saliere is the best"
        template_vars = None

        # Prepare the jinja environment
        self.jinja_env.get_template = MagicMock(return_value=self.jinja_env.from_string(template_str))

        # Jinjanize the content
        jinjanized_content = Jinjanizer.jinjanize(self.jinja_env, "", template_vars)

        # Assert
        self.assertEqual(jinjanized_content, template_str)
Esempio n. 2
0
    def test_jinjanize_02(self):
        """Renders Jinja template when the substitution variables where forgotten.

        If a variable does not have a substitution, it is simply deleted.,
        """
        # Prepare the test template
        template_str = "{{ formula_name }} is the best"
        template_vars = None

        # Prepare the jinja environment
        self.jinja_env.get_template = MagicMock(return_value=self.jinja_env.from_string(template_str))

        # Jinjanize the content
        jinjanized_content = Jinjanizer.jinjanize(self.jinja_env, "", template_vars)

        # Assert
        self.assertEqual(jinjanized_content, " is the best")
Esempio n. 3
0
    def test_jinjanize_00(self):
        """Renders a regular template.

        All the substitution variables are provided.
        """
        # Prepare the test template
        template_str = "{{ formula_name }} is the best"
        template_vars = {"formula_name": "MagickMock"}

        # Prepare the jinja environment
        self.jinja_env.get_template = MagicMock(return_value=self.jinja_env.from_string(template_str))

        # Jinjanize the content
        jinjanized_content = Jinjanizer.jinjanize(self.jinja_env, "", template_vars)

        # Assert
        self.assertEqual(jinjanized_content, "MagickMock is the best")